diff --git a/ci/cmd/maestro.go b/ci/cmd/maestro.go index 2bfe60bc9d..0643fde4a5 100644 --- a/ci/cmd/maestro.go +++ b/ci/cmd/maestro.go @@ -30,6 +30,7 @@ const ( bookstoreV1Label = "bookstore-v1" bookstoreV2Label = "bookstore-v2" bookWarehouseLabel = "bookwarehouse" + mySQLLabel = "mysql" ) var ( @@ -39,6 +40,7 @@ var ( bookstoreV1Selector = fmt.Sprintf("%s=%s", constants.AppLabel, bookstoreV1Label) bookstoreV2Selector = fmt.Sprintf("%s=%s", constants.AppLabel, bookstoreV2Label) bookWarehouseSelector = fmt.Sprintf("%s=%s", constants.AppLabel, bookWarehouseLabel) + mySQLSelector = fmt.Sprintf("%s=%s", constants.AppLabel, mySQLLabel) osmNamespace = utils.GetEnv(maestro.OSMNamespaceEnvVar, "osm-system") bookbuyerNS = utils.GetEnv(maestro.BookbuyerNamespaceEnvVar, "bookbuyer") @@ -59,7 +61,7 @@ var ( ) func main() { - log.Debug().Msgf("Looking for: %s/%s, %s/%s, %s/%s, %s/%s, %s/%s", bookBuyerLabel, bookbuyerNS, bookThiefLabel, bookthiefNS, bookstoreV1Label, bookstoreNS, bookstoreV2Label, bookstoreNS, bookWarehouseLabel, bookWarehouseNS) + log.Debug().Msgf("Looking for: %s/%s, %s/%s, %s/%s, %s/%s, %s/%s %s/%s", bookBuyerLabel, bookbuyerNS, bookThiefLabel, bookthiefNS, bookstoreV1Label, bookstoreNS, bookstoreV2Label, bookstoreNS, bookWarehouseLabel, bookWarehouseNS, mySQLLabel, bookWarehouseNS) kubeClient := maestro.GetKubernetesClient() @@ -159,6 +161,9 @@ func getPodNames(kubeClient kubernetes.Interface) (string, string, string, strin wg.Add(1) go maestro.WaitForPodToBeReady(kubeClient, maxWaitForPod(), bookWarehouseNS, bookWarehouseSelector, &wg) + wg.Add(1) + go maestro.WaitForPodToBeReady(kubeClient, maxWaitForPod(), bookWarehouseNS, mySQLSelector, &wg) + wg.Wait() bookBuyerPodName, err := maestro.GetPodName(kubeClient, bookbuyerNS, bookBuyerSelector) diff --git a/ci/cmd/maestro/kubernetes_tools.go b/ci/cmd/maestro/kubernetes_tools.go index 14f04feedf..5264ade755 100644 --- a/ci/cmd/maestro/kubernetes_tools.go +++ b/ci/cmd/maestro/kubernetes_tools.go @@ -13,7 +13,6 @@ import ( "time" "github.com/Azure/go-autorest/autorest/to" - mapset "github.com/deckarep/golang-set" "helm.sh/helm/v3/pkg/action" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -23,10 +22,6 @@ import ( "github.com/openservicemesh/osm/pkg/cli" ) -// We are going to wait for the Pod certain amount of time if it is in one of these statuses -// See: https://github.com/kubernetes/kubernetes/blob/d0183703cbe715c879cb42db375c7373b7f2b6a1/pkg/kubelet/kubelet_test.go#L1453-L1454 -var statusWorthWaitingFor = mapset.NewSet("ContainerCreating", "PodInitializing") - // GetPodLogs returns pod logs. func GetPodLogs(kubeClient kubernetes.Interface, namespace string, podName string, containerName string, timeSince time.Duration) string { sinceTime := metav1.NewTime(time.Now().Add(-timeSince)) @@ -252,16 +247,17 @@ func WaitForPodToBeReady(kubeClient kubernetes.Interface, totalWait time.Duratio os.Exit(1) } - for _, container := range pod.Status.ContainerStatuses { - if container.State.Waiting != nil && statusWorthWaitingFor.Contains(container.State.Waiting.Reason) { - fmt.Printf("Pod %s/%s is still initializing; Waiting %+v (%+v/%+v)\n", namespace, podName, WaitForPod, time.Since(startedWaiting), totalWait) - time.Sleep(WaitForPod) + for _, condition := range pod.Status.Conditions { + if condition.Type != corev1.PodReady { continue } - - log.Info().Msgf("Pod %q is ready!", podName) - wg.Done() - return + if condition.Status == corev1.ConditionTrue { + log.Info().Msgf("Pod %q is ready!", podName) + wg.Done() + return + } + fmt.Printf("Pod %s/%s is still initializing; Waiting %+v (%+v/%+v)\n", namespace, podName, WaitForPod, time.Since(startedWaiting), totalWait) + time.Sleep(WaitForPod) } } }