Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

2.1 KB
Raw Blame
{{- /*
    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.
  */}}

apiVersion: v1
kind: Pod
metadata:
  name: {{ include "gravitino-lance-rest-server.fullname" . }}-test-connection
  namespace: {{ include "gravitino-lance-rest-server.namespace" . }}
  annotations:
    helm.sh/hook: test
    helm.sh/hook-delete-policy: hook-succeeded
spec:
  containers:
    - name: test-connection
      image: curlimages/curl:latest
      command:
        - /bin/sh
        - -c
        - |
          max_attempts=30
          attempt=0
          success=false

          while [ $attempt -lt $max_attempts ]; do
            http_code=$(curl -s -o /tmp/body -w "%{http_code}" "http://${SERVICE_NAME}:${SERVICE_PORT}${TEST_PATH}")
            if [ "$http_code" = "200" ] && grep -qi "namespace" /tmp/body; then
              success=true
              break
            else
              echo "Attempt $((attempt + 1)) failed with code ${http_code:-n/a}" && cat /tmp/body || true
              sleep 2
            fi
            attempt=$((attempt + 1))
          done

          if [ "$success" = true ]; then
            exit 0
          else
            exit 1
          fi
      env:
        - name: SERVICE_NAME
          value: {{ .Values.service.name | quote }}
        - name: SERVICE_PORT
          value: {{ .Values.service.port | quote }}
        - name: TEST_PATH
          value: "/lance/v1/namespace/%24/list"
  restartPolicy: Never