예제 #1
0
def waiting_until_service_ready(servicename, total_time=216000):

    while servicestatus.is_service_ready(servicename) != True:

        print "{0} is not ready yet. Please wait for a moment!".format(servicename)
        time.sleep(10)
        total_time = total_time - 10

        if total_time < 0:
            print "An issue occure when starting up {0}".format(servicename)
            sys.exit(1)

    print "{0} is ready!".format(servicename)
예제 #2
0
def main():

    setup_logging()

    service_config = load_yaml_config("service.yaml")

    for serv in service_config['servicelist']:

        if 'stopscript' not in service_config['servicelist'][serv]:
            continue

        # Cleanup cluster-configuration will lose secret of private registry.
        # Then the cleaning-image will be failed to pull.
        if serv == 'cluster-configuration':
            continue

        clean_service(service_config, serv)

    shell_cmd = "kubectl create -f ./bootstrap/cleaning/cleaning.yaml"
    error_msg = "failed to start clean up job to every node"
    execute_shell(shell_cmd, error_msg)

    timeout = 1800

    while servicestatus.is_service_ready('cleaning-one-shot') != True:

        logger.info(
            "The cleaning job not finish yet. Pleas wait for a moment!")
        time.sleep(5)

        timeout = timeout - 5
        if timeout < 0:
            logger.error(
                "Failed cleaning your cluster. please check the cleaning job and delete it manually."
            )
            logger.error(
                "To delete the image, please run -- kubectl delete ds cleaning-one-shot"
            )
            sys.exit(1)

    shell_cmd = "kubectl delete ds cleaning-one-shot"
    error_msg = "Successfully to delete cleaning-one-shot"
    execute_shell(shell_cmd, error_msg)

    clean_service(service_config, 'cluster-configuration')

    logger.info("The cleaning job finished!")
예제 #3
0
def main():

    service_config = load_yaml_config("service.yaml")

    for serv in service_config['servicelist']:

        if 'stopscript' not in service_config['servicelist'][serv]:
            continue

        shell_cmd = 'chmod a+x ./bootstrap/{0}/{1}'.format(
            serv, service_config['servicelist'][serv]['stopscript'])
        error_msg = 'Failed make the {0} stop script executable'.format(serv)
        execute_shell(shell_cmd, error_msg)

        shell_cmd = './bootstrap/{0}/{1}'.format(
            serv, service_config['servicelist'][serv]['stopscript'])
        error_msg = 'Failed stop the service {0}'.format(serv)
        execute_shell(shell_cmd, error_msg)

    shell_cmd = "kubectl create -f ./bootstrap/cleaning/cleaning.yaml"
    error_msg = "failed to start clean up job to every node"
    execute_shell(shell_cmd, error_msg)

    timeout = 1800

    while servicestatus.is_service_ready('cleaning-one-shot') != True:

        print "The cleaning job not finish yet. Pleas wait for a moment!"
        time.sleep(5)

        timeout = timeout - 5
        if timeout < 0:
            print "Failed cleaning your cluster. please check the cleaning job and delete it manually."
            print "To delete the image, please run -- kubectl delete ds cleaning-one-shot"
            sys.exit(1)

    shell_cmd = "kubectl delete ds cleaning-one-shot"
    error_msg = "Successfully to delete cleaning-one-shot"
    execute_shell(shell_cmd, error_msg)

    print "The cleaning job finished!"
예제 #4
0
def service_status_check(servicename):

    if servicestatus.is_service_ready(servicename) != True:
        print "{0} is not ready yet!".format(servicename)
        sys.exit(1)