diff --git a/cmd/climc/shell/policies.go b/cmd/climc/shell/policies.go index 5bf125cfd2..ec9cd07bec 100644 --- a/cmd/climc/shell/policies.go +++ b/cmd/climc/shell/policies.go @@ -184,6 +184,18 @@ func init() { return nil }) + type PolicyAdminCapableOptions struct { + } + R(&PolicyAdminCapableOptions{}, "policy-admin-capable", "Check admin capable", func(s *mcclient.ClientSession, args *PolicyAdminCapableOptions) error { + auth.InitFromClientSession(s) + policy.EnableGlobalRbac(15*time.Second, 15*time.Second) + + capable := policy.PolicyManager.IsAdminCapable(s.GetToken()) + fmt.Printf("%v\n", capable) + + return nil + }) + type PolicyExplainOptions struct { Request []string `help:"explain request, in format of key:is_admin:service:resource:action:extra"` } diff --git a/pkg/cloudcommon/policy/global.go b/pkg/cloudcommon/policy/global.go index 2604c16b4f..266d8e2c2b 100644 --- a/pkg/cloudcommon/policy/global.go +++ b/pkg/cloudcommon/policy/global.go @@ -6,6 +6,8 @@ import ( ) func EnableGlobalRbac(refreshInterval time.Duration, retryInterval time.Duration) { - consts.EnableRbac() - PolicyManager.start(refreshInterval, retryInterval) + if !consts.IsRbacEnabled() { + consts.EnableRbac() + PolicyManager.start(refreshInterval, retryInterval) + } } diff --git a/pkg/scheduler/manager/task_queue.go b/pkg/scheduler/manager/task_queue.go index 0fffd0268d..0a413c8703 100644 --- a/pkg/scheduler/manager/task_queue.go +++ b/pkg/scheduler/manager/task_queue.go @@ -200,8 +200,8 @@ type TaskManager struct { func NewTaskManager(stopCh <-chan struct{}) *TaskManager { return &TaskManager{ taskExecutorQueueManager: NewTaskExecutorQueueManager(stopCh), - stopCh: stopCh, - lock: sync.Mutex{}, + stopCh: stopCh, + lock: sync.Mutex{}, } }