Exemplo n.º 1
0
def forward_port(args, port, mesg):
    if args.number == -1:
        v = util.get_pods(db='rethinkdb')
    else:
        v = util.get_pods(db='rethinkdb', instance=args.number)
    v = [x for x in v if x['STATUS'] == 'Running']
    if len(v) == 0:
        raise RuntimeError("rethinkdb node {number} not available".format(number=args.number))
    print("{dashes}{mesg}{dashes}".format(mesg=mesg, dashes='\n\n'+'-'*70+'\n\n'))
    util.run(['kubectl', 'port-forward', v[0]['NAME'], '{port}:{port}'.format(port=port)])
Exemplo n.º 2
0
def forward_port(args, port, mesg):
    if args.number == -1:
        v = util.get_pods(db='rethinkdb')
    else:
        v = util.get_pods(db='rethinkdb', instance=args.number)
    v = [x for x in v if x['STATUS'] == 'Running']
    if len(v) == 0:
        raise RuntimeError("rethinkdb node {number} not available".format(number=args.number))
    print("{dashes}{mesg}{dashes}".format(mesg=mesg, dashes='\n\n'+'-'*70+'\n\n'))
    util.run(['kubectl', 'port-forward', v[0]['NAME'], '{port}:{port}'.format(port=port)])
Exemplo n.º 3
0
def status(args):
    # Get all pod names
    v = util.get_pods(run=NAME)
    print("Getting last %s lines of logs from %s pods" % (args.tail, len(v)))
    for x in v:
        lg = util.get_logs(x['NAME'], tail=args.tail,
                           container='smc-hub').splitlines()
        blocked = concurrent = 0
        for w in lg:
            if 'BLOCKED for' in w:  # 2016-07-07T17:39:23.159Z - debug: BLOCKED for 1925ms
                b = int(w.split()[-1][:-2])
                blocked = max(blocked, b)
            if 'concurrent]' in w:  # 2016-07-07T17:41:16.226Z - debug: [1 concurrent] ...
                concurrent = max(concurrent, int(w.split()[3][1:]))
        x['blocked'] = blocked
        x['concurrent'] = concurrent
        bad = util.run(
            "kubectl describe pod {name} |grep Unhealthy |tail -1 ".format(
                name=x['NAME']),
            get_output=True,
            verbose=False).splitlines()
        if len(bad) > 0:
            x['unhealthy'] = bad[-1].split()[1]
        else:
            x['unhealthy'] = ''
    print("%-30s%-12s%-12s%-12s%-12s%-12s" %
          ('NAME', 'CONCURRENT', 'BLOCKED', 'UNHEALTHY', 'RESTARTS', 'AGE'))
    for x in v:
        print("%-30s%-12s%-12s%-12s%-12s%-12s" %
              (x['NAME'], x['concurrent'], x['blocked'], x['unhealthy'],
               x['RESTARTS'], x['AGE']))
Exemplo n.º 4
0
def forward_test(args):
    v = util.get_pods(run='rethinkdb-proxy')
    v = [x for x in v if x['STATUS'] == 'Running']
    if len(v) == 0:
        print("No rethinkdb-proxy nodes available")
    else:
        print("\n\nYou may connect to rethinkdb-proxy on localhost:\n\n")
        util.run(['kubectl', 'port-forward', v[0]['NAME'], '28015:28015'])
Exemplo n.º 5
0
def forward_test(args):
    v = util.get_pods(run='rethinkdb-proxy')
    v = [x for x in v if x['STATUS'] == 'Running']
    if len(v) == 0:
        print("No rethinkdb-proxy nodes available")
    else:
        print("\n\nYou may connect to rethinkdb-proxy on localhost:\n\n")
        util.run(['kubectl', 'port-forward', v[0]['NAME'], '28015:28015'])
Exemplo n.º 6
0
def status(args):
    # Get all pod names
    v = util.get_pods(run=NAME)
    print("Getting last %s lines of logs from %s pods"%(args.tail, len(v)))
    for x in v:
        lg = util.get_logs(x['NAME'], tail=args.tail, container='smc-hub').splitlines()
        blocked = concurrent = 0
        for w in lg:
            if 'BLOCKED for' in w:   # 2016-07-07T17:39:23.159Z - debug: BLOCKED for 1925ms
                b = int(w.split()[-1][:-2])
                blocked = max(blocked, b)
            if 'concurrent]' in w:   # 2016-07-07T17:41:16.226Z - debug: [1 concurrent] ...
                concurrent = max(concurrent, int(w.split()[3][1:]))
        x['blocked'] = blocked
        x['concurrent'] = concurrent
        bad = util.run("kubectl describe pod {name} |grep Unhealthy |tail -1 ".format(name=x['NAME']), get_output=True, verbose=False).splitlines()
        if len(bad) > 0:
            x['unhealthy'] = bad[-1].split()[0]
        else:
            x['unhealthy'] = ''
    print("%-30s%-12s%-12s%-12s%-12s%-12s"%('NAME', 'CONCURRENT', 'BLOCKED', 'UNHEALTHY', 'RESTARTS', 'AGE'))
    for x in v:
        print("%-30s%-12s%-12s%-12s%-12s%-12s"%(x['NAME'], x['concurrent'], x['blocked'], x['unhealthy'], x['RESTARTS'], x['AGE']))