@@ -103,30 +103,37 @@ func (a *actionEnforceResignLeadership) CheckProgress(ctx context.Context) (bool
103103 }
104104
105105 // Lets start resign job if required
106- if j , ok := a .actionCtx .Get (a .action , resignLeadershipJobID ); ok && j != "" {
106+ if j , ok := a .actionCtx .Get (a .action , resignLeadershipJobID ); ok && j != "" && j != "N/A" {
107107 _ , jobStatus := agencyState .Target .GetJob (state .JobID (j ))
108108 switch jobStatus {
109109 case state .JobPhaseFailed :
110110 a .log .Error ("Resign server job failed" )
111111 // Remove key
112- a .actionCtx .Add (resignLeadershipJobID , "" , true )
112+ a .actionCtx .Add (resignLeadershipJobID , "N/A " , true )
113113 return false , false , nil
114114 case state .JobPhaseFinished :
115115 a .log .Info ("Job finished" )
116116 // Remove key
117- a .actionCtx .Add (resignLeadershipJobID , "" , true )
117+ a .actionCtx .Add (resignLeadershipJobID , "N/A " , true )
118118 case state .JobPhaseUnknown :
119119 a .log .Str ("status" , string (jobStatus )).Error ("Resign server job unknown status" )
120120 return false , false , nil
121121 default :
122122 return false , false , nil
123123 }
124124
125+ a .actionCtx .Add (resignLeadershipJobID , "N/A" , true )
126+
125127 // Job is Finished, check if we are not a leader anymore
126128 if agencyState .PlanLeaderServers ().Contains (state .Server (m .ID )) {
127129 // We are still a leader!
128- a .log .Warn ("DBServers is still a leader for shards" )
129- return false , false , nil
130+ if agencyState .PlanLeaderServersWithFailOver ().Contains (state .Server (m .ID )) {
131+ // We need to retry
132+ a .log .Warn ("DBServer is still a leader for shards" )
133+ return false , false , nil
134+ }
135+ // Nothing to do as RF is set to 1
136+ a .log .Warn ("DBServer is still a leader for shards, but ReplicationFactor is set to 1" )
130137 }
131138 return true , false , nil
132139 }
0 commit comments