ceph: add missing ceph cluster spec

The lib-bucket-provisioner was missing the cephCluster spec so the check
in RunAdminCommandNoMultisite would fail.
This is similar to ad54ed8aac just a
different place.

Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
Sébastien Han committed 2021-07-13 18:45:39 +02:00
1 parent 32295335a1
commit 1fd76a1168
2 files changed
+23

No files matched your search

@@ -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 {
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 {
+13
View File
@@ -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"