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

ceph: add missing ceph cluster spec #8310

Merged
merged 1 commit into from
Jul 13, 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
10 changes: 10 additions & 0 deletions pkg/operator/ceph/object/bucket/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,16 @@ func (p *Provisioner) setAdminOpsAPIClient() error {
return errors.Wrapf(err, "failed to get ceph object store %q", p.objectStoreName)
}

cephCluster, err := p.getCephCluster()
if err != nil {
return errors.Wrapf(err, "failed to get ceph cluster in namespace %q", p.clusterInfo.Namespace)
}
if cephCluster == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would the cluster be nil? If getCephCluster() returns Items[0], seems like it shouldn't be nil

return errors.Errorf("failed to read ceph cluster in namespace %q, it's nil", p.clusterInfo.Namespace)
}
// Set the Ceph Cluster Spec so that we can fetch the admin ops key properly when multus is enabled
p.objectContext.CephClusterSpec = cephCluster.Spec

// Fetch the object store admin ops user
accessKey, secretKey, err := cephObject.GetAdminOPSUserCredentials(p.objectContext, &cephObjectStore.Spec)
if err != nil {
Expand Down
13 changes: 13 additions & 0 deletions pkg/operator/ceph/object/bucket/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ func (p *Provisioner) getObjectStore() (*cephv1.CephObjectStore, error) {
return store, err
}

func (p *Provisioner) getCephCluster() (*cephv1.CephCluster, error) {
cephCluster, err := p.context.RookClientset.CephV1().CephClusters(p.clusterInfo.Namespace).List(context.TODO(), metav1.ListOptions{})
if err != nil {
return nil, errors.Wrapf(err, "failed to list ceph clusters in namespace %q", p.clusterInfo.Namespace)
}
if len(cephCluster.Items) == 0 {
return nil, errors.Errorf("failed to find ceph cluster in namespace %q", p.clusterInfo.Namespace)
}

// This is a bit weak, but there will always be a single cluster per namespace anyway
return &cephCluster.Items[0], err
}

func randomString(n int) string {

var letterRunes = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
Expand Down