This is an automated email from the ASF dual-hosted git repository.

pingsutw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git


The following commit(s) were added to refs/heads/master by this push:
     new 33201e6  SUBMARINE-1025. Use minio client in init container to create 
bucket
33201e6 is described below

commit 33201e6eaa1f1fae3f49793e7b006c7a5c7dc607
Author: jeff-901 <[email protected]>
AuthorDate: Thu Sep 16 23:09:22 2021 +0800

    SUBMARINE-1025. Use minio client in init container to create bucket
    
    ### What is this PR for?
    Migrate the minio logic to init container for submarine and mlflow pod. If 
the init container fails, let it restart.
    
    ### What type of PR is it?
    Bug Fix
    
    ### Todos
    
    ### What is the Jira issue?
    https://issues.apache.org/jira/browse/SUBMARINE-1025
    
    ### How should this be tested?
    Original e2e test.
    
    ### Screenshots (if appropriate)
    
    ### Questions:
    * Do the license files need updating? No
    * Are there breaking changes for older versions? No
    * Does this need new documentation? No
    
    Author: jeff-901 <[email protected]>
    
    Signed-off-by: Kevin <[email protected]>
    
    Closes #750 from jeff-901/SUBMARINE-1025 and squashes the following commits:
    
    46ea9abc [jeff-901] continuously try to config
    80585d03 [jeff-901] migrate create bucket to init container
---
 bin/submarine.sh                                   |  6 ----
 dev-support/docker-images/mlflow/Dockerfile        |  2 --
 dev-support/docker-images/mlflow/start.sh          | 20 -------------
 dev-support/docker-images/submarine/Dockerfile     |  6 ----
 .../docker-images/submarine/create_bucket.sh       | 35 ----------------------
 .../submarine/templates/submarine-mlflow.yaml      | 20 +++++++++++++
 .../submarine/templates/submarine-server.yaml      | 20 +++++++++++++
 7 files changed, 40 insertions(+), 69 deletions(-)

diff --git a/bin/submarine.sh b/bin/submarine.sh
index d2e74b0..e8c109b 100755
--- a/bin/submarine.sh
+++ b/bin/submarine.sh
@@ -55,10 +55,4 @@ if [[ ! -d "${SUBMARINE_LOG_DIR}" ]]; then
   $(mkdir -p "${SUBMARINE_LOG_DIR}")
 fi
 
-/usr/local/bin/create_bucket.sh
-if [ $? -ne 0 ];then
-  echo "Create submarine bucket fail" 
-  exit 1
-fi
-
 exec $JAVA_RUNNER $JAVA_OPTS -cp ${SUBMARINE_SERVER_CLASSPATH} 
${SUBMARINE_SERVER_MAIN} "$@" | tee -a "${SUBMARINE_SERVER_LOGFILE}" 2>&1
diff --git a/dev-support/docker-images/mlflow/Dockerfile 
b/dev-support/docker-images/mlflow/Dockerfile
index 5467d95..cf92a37 100644
--- a/dev-support/docker-images/mlflow/Dockerfile
+++ b/dev-support/docker-images/mlflow/Dockerfile
@@ -23,8 +23,6 @@ COPY start.sh /usr/local/bin
 
 WORKDIR /usr/local/bin
 
-RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc && chmod +x mc
-
 ENV MLFLOW_S3_ENDPOINT_URL http://submarine-minio-service:9000
 ENV AWS_ACCESS_KEY_ID submarine_minio
 ENV AWS_SECRET_ACCESS_KEY submarine_minio
diff --git a/dev-support/docker-images/mlflow/start.sh 
b/dev-support/docker-images/mlflow/start.sh
index 95df711..c96ca03 100755
--- a/dev-support/docker-images/mlflow/start.sh
+++ b/dev-support/docker-images/mlflow/start.sh
@@ -21,28 +21,8 @@
 
 set -euo pipefail
 
-# Check if the bucket "minio/mlflow" already exists
-check_minio_mlflow_bucket_exists() {
-    if /bin/bash -c "./mc ls minio/mlflow" >/dev/null 2>&1; then
-       true
-    else
-       false
-    fi
-}
-
-MLFLOW_S3_ENDPOINT_URL="http://submarine-minio-service:9000";
-AWS_ACCESS_KEY_ID="submarine_minio"
-AWS_SECRET_ACCESS_KEY="submarine_minio"
 BACKEND_URI="mysql+pymysql://mlflow:password@submarine-database:3306/mlflowdb"
 DEFAULT_ARTIFACT_ROOT="s3://mlflow"
 STATIC_PREFIX="/mlflow"
 
-/bin/bash -c "sleep 60; ./mc config host add minio ${MLFLOW_S3_ENDPOINT_URL} 
${AWS_ACCESS_KEY_ID} ${AWS_SECRET_ACCESS_KEY}"
-
-if ! check_minio_mlflow_bucket_exists; then
-       /bin/bash -c "./mc mb minio/mlflow"
-else
-       echo "Bucket minio/mlflow already exists, skipping creation."
-fi
-
 /bin/bash -c "mlflow server --host 0.0.0.0 --backend-store-uri ${BACKEND_URI} 
--default-artifact-root ${DEFAULT_ARTIFACT_ROOT} --static-prefix 
${STATIC_PREFIX}"
\ No newline at end of file
diff --git a/dev-support/docker-images/submarine/Dockerfile 
b/dev-support/docker-images/submarine/Dockerfile
index f038407..eb77fa7 100644
--- a/dev-support/docker-images/submarine/Dockerfile
+++ b/dev-support/docker-images/submarine/Dockerfile
@@ -38,12 +38,6 @@ ADD ./tmp/submarine-site.xml "/opt/submarine-current/conf/"
 ADD ./tmp/submarine.sh "/opt/submarine-current/bin/"
 ADD ./tmp/mysql-connector-java-5.1.39.jar "/opt/submarine-current/lib/"
 
-# Create submarine Bucket
-WORKDIR /usr/local/bin
-RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc && chmod +x mc
-RUN wget https://dl.k8s.io/release/v1.15.11/bin/linux/amd64/kubectl && chmod 
+x kubectl
-COPY create_bucket.sh /usr/local/bin
-
 WORKDIR /opt/submarine-current
 
 # Submarine port
diff --git a/dev-support/docker-images/submarine/create_bucket.sh 
b/dev-support/docker-images/submarine/create_bucket.sh
deleted file mode 100755
index 826407e..0000000
--- a/dev-support/docker-images/submarine/create_bucket.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-set -euo pipefail
-
-S3_ENDPOINT_URL="http://submarine-minio-service:9000";
-AWS_ACCESS_KEY_ID="submarine_minio"
-AWS_SECRET_ACCESS_KEY="submarine_minio"
-
-
-# Wait for minio pod to setup
-/bin/bash -c "kubectl wait --for=condition=ready pod -l 
app=submarine-minio-pod; mc config host add minio ${S3_ENDPOINT_URL} 
${AWS_ACCESS_KEY_ID} ${AWS_SECRET_ACCESS_KEY}"
-
-# Create if the bucket "minio/submarine" not exists
-
-if /bin/bash -c "mc ls minio/submarine" >/dev/null 2>&1; then
-    echo "Bucket minio/submarine already exists, skipping creation."
-else
-    /bin/bash -c "mc mb minio/submarine"
-fi
diff --git a/helm-charts/submarine/templates/submarine-mlflow.yaml 
b/helm-charts/submarine/templates/submarine-mlflow.yaml
index 0caaac4..4083466 100644
--- a/helm-charts/submarine/templates/submarine-mlflow.yaml
+++ b/helm-charts/submarine/templates/submarine-mlflow.yaml
@@ -62,6 +62,26 @@ spec:
       labels:
         app: submarine-mlflow-pod
     spec:
+      initContainers:
+      - name: submarine-mlflow-initcontainer
+        image: "minio/mc"
+        command: ["/bin/bash", "-c", 
+        "cnt=0;
+        while ! /bin/bash -c 'mc config host add minio 
http://submarine-minio-service:9000 
+        submarine_minio submarine_minio' 2>&1; 
+        do
+          sleep 15;
+          ((cnt=cnt+1));
+          if [ $cnt -eq 80 ];then
+            echo 'ERROR: wait too long for minio pod';
+            exit 1;
+          fi;
+        done;
+        if /bin/bash -c 'mc ls minio/mlflow' >/dev/null 2>&1; then
+          echo 'Bucket minio/mlflow already exists, skipping creation.';
+        else
+          /bin/bash -c 'mc mb minio/mlflow';
+        fi;"]
       containers:
       - name: submarine-mlflow-container
         image: apache/submarine:mlflow-0.6.0-SNAPSHOT
diff --git a/helm-charts/submarine/templates/submarine-server.yaml 
b/helm-charts/submarine/templates/submarine-server.yaml
index 5a3f063..697f832 100644
--- a/helm-charts/submarine/templates/submarine-server.yaml
+++ b/helm-charts/submarine/templates/submarine-server.yaml
@@ -54,6 +54,26 @@ spec:
       {{ end }}
     spec:
       serviceAccountName: "{{ .Values.submarine.server.name }}"
+      initContainers:
+      - name: submarine-server-initcontainer
+        image: "minio/mc"
+        command: ["/bin/bash", "-c", 
+        "cnt=0;
+        while ! /bin/bash -c 'mc config host add minio 
http://submarine-minio-service:9000 
+        submarine_minio submarine_minio' 2>&1; 
+        do
+          sleep 15;
+          ((cnt=cnt+1));
+          if [ $cnt -eq 80 ];then
+            echo 'ERROR: wait too long for minio pod';
+            exit 1;
+          fi;
+        done;
+        if /bin/bash -c 'mc ls minio/submarine' >/dev/null 2>&1; then
+          echo 'Bucket minio/submarine already exists, skipping creation.';
+        else
+          /bin/bash -c 'mc mb minio/submarine';
+        fi;"]
       containers:
       - name: "{{ .Values.submarine.server.name }}"
         env:

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to