Merge pull request #9354 from rook/mergify/bp/release-1.8/pr-9347

core: always return nil clusterInfo on failure (backport #9347)
This commit is contained in:
Travis Nielsen authored and GitHub committed 2021-12-08 11:22:42 -07:00
commit bf7a6d6e5b
2 files changed
+8 -4

No files matched your search

+5 -1
View File
@@ -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)
+3 -3
View File
@@ -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
@@ -155,7 +155,7 @@ 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"])
@@ -163,7 +163,7 @@ func CreateOrLoadClusterInfo(clusterdContext *clusterd.Context, context context.
}
if err := ValidateCephCSIConnectionSecrets(clusterdContext, namespace); err != nil {
return clusterInfo, maxMonID, monMapping, err
return nil, maxMonID, monMapping, err
}
return clusterInfo, maxMonID, monMapping, nil