Skip to content

Commit a1ae41d

Browse files
committed
refactor auth
1 parent d0c2fb5 commit a1ae41d

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

controllers/om/automation_status.go

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ func checkAutomationStatusIsGoal(as *AutomationStatus, relevantProcesses []strin
8686
goalsNotAchievedMap := map[string]int{}
8787
goalsAchievedMap := map[string]int{}
8888
authTransitionInProgress := map[string]string{}
89-
89+
9090
for _, p := range as.Processes {
9191
if !stringutil.Contains(relevantProcesses, p.Name) {
9292
continue
9393
}
9494
if p.LastGoalVersionAchieved == as.GoalVersion {
9595
goalsAchievedMap[p.Name] = p.LastGoalVersionAchieved
96-
96+
9797
// Check if authentication transitions are in the current plan
9898
// If a process has reached goal version but still has auth-related moves in plan,
9999
// it means authentication transition is likely in progress
@@ -122,9 +122,9 @@ func checkAutomationStatusIsGoal(as *AutomationStatus, relevantProcesses []strin
122122
for processName, step := range authTransitionInProgress {
123123
authTransitionMsgList = append(authTransitionMsgList, fmt.Sprintf("%s:%s", processName, step))
124124
}
125-
log.Infow("Authentication transitions still in progress, waiting for completion",
125+
log.Infow("Authentication transitions still in progress, waiting for completion",
126126
"processes", authTransitionMsgList)
127-
return false, fmt.Sprintf("authentication transitions in progress for %d processes: %s",
127+
return false, fmt.Sprintf("authentication transitions in progress for %d processes: %s",
128128
len(authTransitionInProgress), authTransitionMsgList)
129129
}
130130

@@ -140,22 +140,17 @@ func checkAutomationStatusIsGoal(as *AutomationStatus, relevantProcesses []strin
140140

141141
// isAuthenticationTransitionMove returns true if the given move is related to authentication transitions
142142
func isAuthenticationTransitionMove(move string) bool {
143-
// Authentication-related moves that can appear in the automation plan
144-
// Based on analysis of failed test showing auth transition in progress
145-
authMoves := []string{
146-
"RestartMongod", // Often involved in authentication mode changes
147-
"UpdateAuth", // Direct authentication update moves
148-
"UpdateConfig", // Configuration updates that may include auth changes
149-
"WaitForHealthy", // Waiting for cluster health after auth changes
150-
"InitiateReplSet", // ReplicaSet initialization with authentication
151-
}
152-
153-
for _, authMove := range authMoves {
154-
if move == authMove {
155-
return true
156-
}
143+
authMoves := map[string]struct{}{
144+
"RestartMongod": {},
145+
"UpdateAuth": {},
146+
"UpdateConfig": {},
147+
"WaitForHealthy": {},
148+
"InitiateReplSet": {},
157149
}
158-
return false
150+
151+
_, ok := authMoves[move]
152+
153+
return ok
159154
}
160155

161156
func areAnyAgentsInKubeUpgradeMode(as *AutomationStatus, relevantProcesses []string, log *zap.SugaredLogger) bool {

0 commit comments

Comments
 (0)