Skip to content

Commit

Permalink
unlock mutex, don't log about embedded-cluster on non-ec installs
Browse files Browse the repository at this point in the history
  • Loading branch information
laverya committed Dec 7, 2023
1 parent bb496a5 commit 726f316
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions pkg/embeddedcluster/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
23 changes: 15 additions & 8 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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")
}
Expand Down

0 comments on commit 726f316

Please sign in to comment.