Skip to content

Commit

Permalink
update rbac and fix minio user not exist error
Browse files Browse the repository at this point in the history
  • Loading branch information
nowinkeyy committed Nov 30, 2023
1 parent 67dd44e commit 1bf17ab
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
12 changes: 12 additions & 0 deletions controllers/account/config/rbac/role.yaml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
value: '{{ .OSNamespace }}'
envFrom:
- secretRef:
name: payment-secret
Expand Down

0 comments on commit 1bf17ab

Please sign in to comment.