Ejemplo n.º 1
0
def check_ping(pod, ip, retry=3):
    print "-checking ping %s on pod %s." % (ip, pod)
    while retry > 0:
        r = k8sclient.pod_exec(
            namespace, pod,
            ["bash", "-c", "ping %s -c 2 -w 5" % ip])
        if r.find("Error executing in Docker Container") == -1:
            return True
        print "retry ping %s on %s" % (ip, pod)
        retry -= 1
    print "Fail to ping %s on pod %s" % (ip, pod)
    return False
Ejemplo n.º 2
0
def check_service(pod, service, retry=3):
    print "-checking service %s on pod %s." % (service, pod)
    while retry > 0:
        try:
            r = k8sclient.pod_exec(namespace, pod, ["/opt/check.sh", service])
            if r.find("Error executing in Docker Container") == -1:
                return True
        except Exception as e:
            pass
        print "retry %s on %s." % (service, pod)
        retry -= 1
    print "Fail to connect to %s on pod %s" % (service, pod)
    return False