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

update rbac and fix minio user not exist error #4366

Merged
merged 2 commits into from Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions controllers/account/config/rbac/role.yaml
Expand Up @@ -37,6 +37,18 @@ rules:
- configmaps/status
verbs:
- get
- apiGroups:
- ""
resources:
- secrets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- account.sealos.io
resources:
Expand Down
20 changes: 17 additions & 3 deletions controllers/account/controllers/namespace_controller.go
Expand Up @@ -325,9 +325,11 @@ func (r *NamespaceReconciler) suspendObjectStorage(ctx context.Context, namespac

err := r.setOSUserStatus(ctx, user, Disabled)
if err != nil {
r.Log.Error(err, "failed to suspend object storage")
r.Log.Error(err, "failed to suspend object storage", "user", user)
return err
}

r.Log.Info("suspend object storage", "user", user)
return nil
}

Expand All @@ -337,9 +339,11 @@ func (r *NamespaceReconciler) resumeObjectStorage(ctx context.Context, namespace

err := r.setOSUserStatus(ctx, user, Enabled)
if err != nil {
r.Log.Error(err, "failed to resume object storage")
r.Log.Error(err, "failed to resume object storage", "user", user)
return err
}

r.Log.Info("resume object storage", "user", user)
return nil
}

Expand Down Expand Up @@ -367,7 +371,17 @@ func (r *NamespaceReconciler) setOSUserStatus(ctx context.Context, user string,
r.OSAdminClient = oSAdminClient
}

err := r.OSAdminClient.SetUserStatus(ctx, user, madmin.AccountStatus(status))
users, err := r.OSAdminClient.ListUsers(ctx)
if err != nil {
r.Log.Error(err, "failed to list minio user", "user", user)
return err
}

if _, ok := users[user]; !ok {
return nil
}

err = r.OSAdminClient.SetUserStatus(ctx, user, madmin.AccountStatus(status))
if err != nil {
r.Log.Error(err, "failed to set user status", "user", user, "status", status)
return err
Expand Down
18 changes: 18 additions & 0 deletions controllers/account/deploy/manifests/deploy.yaml.tmpl
Expand Up @@ -734,6 +734,18 @@ rules:
- configmaps/status
verbs:
- get
- apiGroups:
- ""
resources:
- secrets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- account.sealos.io
resources:
Expand Down Expand Up @@ -1296,6 +1308,12 @@ spec:
value: "604800"
- name: DebtDetectionCycleSeconds
value: "30"
- name: OSAdminSecret
value: '{{ .OSAdminSecret }}'
- name: OSInternalEndpoint
value: '{{ .OSInternalEndpoint }}'
- name: oSNamespace
Copy link
Member

Choose a reason for hiding this comment

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

oSNamespace --> OSNamespace

value: '{{ .OSNamespace }}'
envFrom:
- secretRef:
name: payment-secret
Expand Down