From 726f3169170e7cd01a221ec1cc1ba2cd3bc7026c Mon Sep 17 00:00:00 2001 From: Andrew Lavery Date: Thu, 7 Dec 2023 21:03:16 +0000 Subject: [PATCH] unlock mutex, don't log about embedded-cluster on non-ec installs --- pkg/embeddedcluster/monitor.go | 1 + pkg/operator/operator.go | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/pkg/embeddedcluster/monitor.go b/pkg/embeddedcluster/monitor.go index 3763deb009..a08e596186 100644 --- a/pkg/embeddedcluster/monitor.go +++ b/pkg/embeddedcluster/monitor.go @@ -66,6 +66,7 @@ func InitClusterState(ctx context.Context, client kubernetes.Interface, store st // if it is called multiple times, only one instance will run. func watchClusterState(ctx context.Context, store store.Store) { stateMut.Lock() + defer stateMut.Unlock() numReady := 0 lastState := "" for numReady < 6 { diff --git a/pkg/operator/operator.go b/pkg/operator/operator.go index ae78bb5007..9409ca25d2 100644 --- a/pkg/operator/operator.go +++ b/pkg/operator/operator.go @@ -383,6 +383,11 @@ func (o *Operator) DeployApp(appID string, sequence int64) (deployed bool, deplo return false, errors.Wrap(err, "failed to apply status informers") } + isEmbeddedCluster, err := embeddedcluster.IsEmbeddedCluster(o.k8sClientset) + if err != nil { + return false, errors.Wrap(err, "failed to check if this is an embedded cluster installation") + } + o.client.ApplyNamespacesInformer(kotsKinds.KotsApplication.Spec.AdditionalNamespaces, imagePullSecrets) o.client.ApplyHooksInformer(kotsKinds.KotsApplication.Spec.AdditionalNamespaces) @@ -409,14 +414,16 @@ func (o *Operator) DeployApp(appID string, sequence int64) (deployed bool, deplo } deployed, err = o.client.DeployApp(deployArgs) if err != nil { - go func() { - logger.Info("app deploy failed, starting cluster upgrade in the background") - err2 := embeddedcluster.MaybeStartClusterUpgrade(context.Background(), o.k8sClientset, o.store, kotsKinds.EmbeddedClusterConfig) - if err2 != nil { - logger.Error(errors.Wrap(err2, "failed to start cluster upgrade")) - } - logger.Info("cluster upgrade started") - }() + if isEmbeddedCluster { + go func() { + logger.Info("app deploy failed, starting cluster upgrade in the background") + err2 := embeddedcluster.MaybeStartClusterUpgrade(context.Background(), o.k8sClientset, o.store, kotsKinds.EmbeddedClusterConfig) + if err2 != nil { + logger.Error(errors.Wrap(err2, "failed to start cluster upgrade")) + } + logger.Info("cluster upgrade started") + }() + } return false, errors.Wrap(err, "failed to deploy app") }