Skip to content

Commit

Permalink
Merge pull request #9354 from rook/mergify/bp/release-1.8/pr-9347
Browse files Browse the repository at this point in the history
core: always return nil clusterInfo on failure (backport #9347)
  • Loading branch information
travisn committed Dec 8, 2021
2 parents 3ceaaaa + e58939a commit bf7a6d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion pkg/operator/ceph/cluster/cluster.go
Expand Up @@ -168,7 +168,11 @@ func (c *ClusterController) initializeCluster(cluster *cluster) error {

clusterInfo, _, _, err := mon.LoadClusterInfo(c.context, c.OpManagerCtx, cluster.Namespace)
if err != nil {
logger.Infof("clusterInfo not yet found, must be a new cluster")
if errors.Is(err, mon.ClusterInfoNoClusterNoSecret) {
logger.Info("clusterInfo not yet found, must be a new cluster.")
} else {
return errors.Wrap(err, "failed to load cluster info")
}
} else {
clusterInfo.OwnerInfo = cluster.ownerInfo
clusterInfo.SetName(c.namespacedName.Name)
Expand Down
6 changes: 3 additions & 3 deletions pkg/operator/ceph/cluster/mon/config.go
Expand Up @@ -104,7 +104,7 @@ func CreateOrLoadClusterInfo(clusterdContext *clusterd.Context, context context.

clusterInfo, err = createNamedClusterInfo(clusterdContext, namespace)
if err != nil {
return nil, maxMonID, monMapping, errors.Wrap(err, "failed to create mon secrets")
return nil, maxMonID, monMapping, errors.Wrap(err, "failed to create initial cluster info")
}
clusterInfo.Context = context

Expand Down Expand Up @@ -155,15 +155,15 @@ func CreateOrLoadClusterInfo(clusterdContext *clusterd.Context, context context.
if clusterInfo.CephCred.Secret == adminSecretNameKey {
secret, err := clusterdContext.Clientset.CoreV1().Secrets(namespace).Get(context, OperatorCreds, metav1.GetOptions{})
if err != nil {
return clusterInfo, maxMonID, monMapping, err
return nil, maxMonID, monMapping, err
}
// Populate external credential
clusterInfo.CephCred.Username = string(secret.Data["userID"])
clusterInfo.CephCred.Secret = string(secret.Data["userKey"])
}

if err := ValidateCephCSIConnectionSecrets(clusterdContext, namespace); err != nil {
return clusterInfo, maxMonID, monMapping, err
return nil, maxMonID, monMapping, err
}

return clusterInfo, maxMonID, monMapping, nil
Expand Down

0 comments on commit bf7a6d6

Please sign in to comment.