From d150ced7f7385b3e6a58cdcf3cd2bf5ed796ce4c Mon Sep 17 00:00:00 2001 From: CathyWang0329 Date: Mon, 4 Mar 2019 19:24:57 +0800 Subject: [PATCH] adapt user transfer script to new config (#2266) --- src/rest-server/config/rest_server.py | 11 +++++++---- src/rest-server/deploy/start.sh.template | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/rest-server/config/rest_server.py b/src/rest-server/config/rest_server.py index 31929d13ce..426025b666 100644 --- a/src/rest-server/config/rest_server.py +++ b/src/rest-server/config/rest_server.py @@ -21,7 +21,7 @@ def __init__(self, cluster_configuration, service_configuration, default_service self.cluster_configuration = cluster_configuration self.service_configuration = dict(default_service_configuraiton, **service_configuration) - + #### Fist check, ensure all the configured data in cluster_configuration, service_configuration, default_service_configuration is right. And nothing is miss. def validation_pre(self): machine_list = self.cluster_configuration['machine-list'] @@ -31,7 +31,7 @@ def validation_pre(self): return False, '"default-pai-admin-password" is required in rest-server' return True, None - + #### Generate the final service object model def run(self): # parse your service object model here, and return a generated dictionary @@ -50,10 +50,13 @@ def run(self): service_object_model['github-owner'] = self.service_configuration['github-owner'] service_object_model['github-repository'] = self.service_configuration['github-repository'] service_object_model['github-path'] = self.service_configuration['github-path'] + service_object_model['etcd-uris'] = ','.join('http://{0}:4001'.format(host['hostip']) + for host in machine_list + if host.get('k8s-role') == 'master') return service_object_model - - #### All service and main module (kubrenetes, machine) is generated. And in this check steps, you could refer to the service object model which you will used in your own service, and check its existence and correctness. + + #### All service and main module (kubrenetes, machine) is generated. And in this check steps, you could refer to the service object model which you will used in your own service, and check its existence and correctness. def validation_post(self, cluster_object_model): if 'yarn-frameworklauncher' not in cluster_object_model or 'webservice' not in cluster_object_model['yarn-frameworklauncher']: return False, 'yarn-frameworklauncher.webservice is required' diff --git a/src/rest-server/deploy/start.sh.template b/src/rest-server/deploy/start.sh.template index ce418e0c7d..13e11dbc52 100644 --- a/src/rest-server/deploy/start.sh.template +++ b/src/rest-server/deploy/start.sh.template @@ -21,7 +21,7 @@ pushd $(dirname "$0") > /dev/null # Check whether has etcd-uri in cluster config if so need to transfer user-data {% if cluster_cfg['rest-server']['etcd-uris'] -%} -python3 legacy_user_migrate.py -e {{ cluster_cfg['rest-server']['etcd-uris'] }} -k {{ cluster_cfg['kubernetes']['api-servers-url'] }} || exit $? +python3 legacy_user_migrate.py -e {{ cluster_cfg['rest-server']['etcd-uris'] }} -k {{ cluster_cfg['layout']['kubernetes']['api-servers-url'] }} || exit $? {% endif -%} kubectl apply --overwrite=true -f rest-server.yaml|| exit $?