From d391f791352f8d55e8b4af0dbce6b10c2fbcc0bc Mon Sep 17 00:00:00 2001 From: Renmin Date: Tue, 4 Feb 2020 21:51:28 +0800 Subject: [PATCH] fix for Init Action (#2980) * should can work * didn't delete configmap for mpdev verify * done Co-authored-by: renmingu <40223865+renmingu@users.noreply.github.com> --- manifests/gcp_marketplace/deployer/Dockerfile | 14 ++++++++-- .../gcp_marketplace/deployer/init_action.sh | 9 +++++-- .../deployer/overlay_deploy.sh | 27 +++++++++++++++++++ .../deployer/overlay_deploy_with_tests.sh | 27 +++++++++++++++++++ 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 manifests/gcp_marketplace/deployer/overlay_deploy.sh create mode 100644 manifests/gcp_marketplace/deployer/overlay_deploy_with_tests.sh diff --git a/manifests/gcp_marketplace/deployer/Dockerfile b/manifests/gcp_marketplace/deployer/Dockerfile index ede5959dab41..c0ed49aa5127 100644 --- a/manifests/gcp_marketplace/deployer/Dockerfile +++ b/manifests/gcp_marketplace/deployer/Dockerfile @@ -9,9 +9,19 @@ RUN tar -C /usr/local/gcloud -xf /tmp/google-cloud-sdk.tar.gz RUN /usr/local/gcloud/google-cloud-sdk/install.sh ENV PATH $PATH:/usr/local/gcloud/google-cloud-sdk/bin -# move the old entrypoint, because mpdev tool will call it directly, whatever entrypoint is. +# move the old entrypoint RUN mv /bin/deploy.sh /bin/core_deploy.sh -ADD deployer/init_action.sh /bin/deploy.sh +RUN mv /bin/deploy_with_tests.sh /bin/core_deploy_with_tests.sh + +# RUN awk '{sub(/clean_iam_resources.sh/,"clean_action.sh\n\nclean_iam_resources.sh")}1' /bin/core_deploy_with_tests.sh > /bin/new_deploy_with_tests.sh + +ADD deployer/init_action.sh /bin/init_action.sh +RUN chmod 755 /bin/init_action.sh + +ADD deployer/overlay_deploy.sh /bin/deploy.sh RUN chmod 755 /bin/deploy.sh +ADD deployer/overlay_deploy_with_tests.sh /bin/deploy_with_tests.sh +RUN chmod 755 /bin/deploy_with_tests.sh + ENTRYPOINT ["/bin/bash", "/bin/deploy.sh"] \ No newline at end of file diff --git a/manifests/gcp_marketplace/deployer/init_action.sh b/manifests/gcp_marketplace/deployer/init_action.sh index 88c3bf54771a..83958309c859 100644 --- a/manifests/gcp_marketplace/deployer/init_action.sh +++ b/manifests/gcp_marketplace/deployer/init_action.sh @@ -28,6 +28,12 @@ function set_bucket_and_configmap() { # Detect GCP project GCP_PROJECT_ID=$(curl -H "Metadata-Flavor: Google" -w '\n' "http://metadata.google.internal/computeMetadata/v1/project/project-id") + # Check whether ConfigMap is already exist + if kubectl get configmap ${CONFIG_NAME}; then + echo "Already has a configmap map there" + return 0 + fi + for i in $(seq 1 ${NUM_RETRIES}) do bucket_is_set=true @@ -65,5 +71,4 @@ export NAMESPACE set_bucket_and_configmap "${NAME}-default" 10 -# Invoke normal deployer routine. -/bin/bash /bin/core_deploy.sh +echo "init_action done" \ No newline at end of file diff --git a/manifests/gcp_marketplace/deployer/overlay_deploy.sh b/manifests/gcp_marketplace/deployer/overlay_deploy.sh new file mode 100644 index 000000000000..1efc77351c85 --- /dev/null +++ b/manifests/gcp_marketplace/deployer/overlay_deploy.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# Pre-install Init Action +/bin/bash /bin/init_action.sh + +# Invoke normal deployer routine. +/bin/bash /bin/core_deploy.sh + +# Return core deployment status +code=$? +echo "deployment return code: ${code}" +exit $code \ No newline at end of file diff --git a/manifests/gcp_marketplace/deployer/overlay_deploy_with_tests.sh b/manifests/gcp_marketplace/deployer/overlay_deploy_with_tests.sh new file mode 100644 index 000000000000..ed7e0808a974 --- /dev/null +++ b/manifests/gcp_marketplace/deployer/overlay_deploy_with_tests.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# Pre-install Init Action +/bin/bash /bin/init_action.sh + +# Invoke normal deployer routine. +/bin/bash /bin/core_deploy_with_tests.sh + +# Return core deployment status +code=$? +echo "deployment return code: ${code}" +exit $code \ No newline at end of file