Merge pull request #12891 from rook/mergify/bp/release-1.11/pr-12884
object: unique username for OBC even when preceding OBC was retained (backport #12884)
This commit is contained in:
2 files changed
+10
-13
No files matched your search
@@ -68,10 +68,7 @@ func (p Provisioner) GenerateUserID(obc *v1alpha1.ObjectBucketClaim, ob *v1alpha
|
||||
return getCephUser(ob), nil
|
||||
}
|
||||
|
||||
username, err := p.genUserName(obc.Name, obc.Namespace)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "failed to generate user id for OBC")
|
||||
}
|
||||
username := p.genUserName(obc)
|
||||
|
||||
return username, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package bucket
|
||||
|
||||
import (
|
||||
"github.com/ceph/go-ceph/rgw/admin"
|
||||
"github.com/kube-object-storage/lib-bucket-provisioner/pkg/apis/objectbucket.io/v1alpha1"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@@ -47,15 +48,14 @@ func (p *Provisioner) createCephUser(username string) (accKey string, secKey str
|
||||
return u.Keys[0].AccessKey, u.Keys[0].SecretKey, nil
|
||||
}
|
||||
|
||||
func (p *Provisioner) genUserName(obcName, obcNamespace string) (string, error) {
|
||||
// user name can be deterministically generated by obc name and namespace. since there can't be
|
||||
// 2 obcs in the same namespace w/ the same name, this won't collide w/in the same k8s cluster.
|
||||
// However, it can collide in multisite setups, so use the Ceph cluster FSID
|
||||
fsid := p.clusterInfo.FSID
|
||||
if p.clusterInfo.FSID == "" {
|
||||
return "", errors.Errorf("failed to find ceph cluster FSID")
|
||||
}
|
||||
return "obc-" + obcNamespace + "-" + obcName + "-" + fsid, nil
|
||||
func (p *Provisioner) genUserName(obc *v1alpha1.ObjectBucketClaim) string {
|
||||
// A deterministic user name can be generated from the OBC's UID. We
|
||||
// cannot simply use the OBC's namespace and name, because they can be
|
||||
// reused, while the preceding bucket might be retained by reclaimPolicy.
|
||||
// But we still include namespace and name for usability. RadosGW user
|
||||
// names have a high enough length limit, so we don't need to crop the
|
||||
// "obc-namespace-name-" part.
|
||||
return "obc-" + obc.Namespace + "-" + obc.Name + "-" + string(obc.UID)
|
||||
}
|
||||
|
||||
// Delete the user and bucket created by OBC with help of radosgw-admin commands
|
||||
|
||||
Reference in new issue
Block a user