Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: always return nil clusterInfo on failure #9347

Merged
merged 3 commits into from Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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