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") }