@@ -175,11 +175,6 @@ func (q *Queue) Reconcile(ctx context.Context) (reconcile.Result, error) {
175
175
// Evict returns true if successful eviction call, and false if there was an eviction-related error
176
176
func (q * Queue ) Evict (ctx context.Context , key QueueKey ) bool {
177
177
ctx = log .IntoContext (ctx , log .FromContext (ctx ).WithValues ("Pod" , klog .KRef (key .Namespace , key .Name )))
178
- evictionMessage , err := evictionReason (ctx , key , q .kubeClient )
179
- if err != nil {
180
- // XXX(cmcavoy): this should be unreachable, but we log it if it happens
181
- log .FromContext (ctx ).V (1 ).Error (err , "failed looking up pod eviction reason" )
182
- }
183
178
if err := q .kubeClient .SubResource ("eviction" ).Create (ctx ,
184
179
& corev1.Pod {ObjectMeta : metav1.ObjectMeta {Namespace : key .Namespace , Name : key .Name }},
185
180
& policyv1.Eviction {
@@ -214,18 +209,18 @@ func (q *Queue) Evict(ctx context.Context, key QueueKey) bool {
214
209
return false
215
210
}
216
211
NodesEvictionRequestsTotal .Inc (map [string ]string {CodeLabel : "200" })
217
- q .recorder .Publish (terminatorevents .EvictPod (& corev1.Pod {ObjectMeta : metav1.ObjectMeta {Name : key .Name , Namespace : key .Namespace }}, evictionMessage ))
212
+ q .recorder .Publish (terminatorevents .EvictPod (& corev1.Pod {ObjectMeta : metav1.ObjectMeta {Name : key .Name , Namespace : key .Namespace }}, evictionReason ( ctx , key , q . kubeClient ) ))
218
213
return true
219
214
}
220
215
221
- func evictionReason (ctx context.Context , key QueueKey , kubeClient client.Client ) ( string , error ) {
216
+ func evictionReason (ctx context.Context , key QueueKey , kubeClient client.Client ) string {
222
217
nodeClaim , err := node .NodeClaimForNode (ctx , kubeClient , & corev1.Node {Spec : corev1.NodeSpec {ProviderID : key .providerID }})
223
218
if err != nil {
224
- return "" , err
219
+ log .FromContext (ctx ).V (1 ).Error (err , "failed looking up pod eviction reason" )
220
+ return ""
225
221
}
226
- terminationCondition := nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDisruptionReason )
227
- if terminationCondition .IsTrue () {
228
- return terminationCondition .Message , nil
222
+ if cond := nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDisruptionReason ); cond .IsTrue () {
223
+ return cond .Reason
229
224
}
230
- return "Forceful Termination" , nil
225
+ return "Forceful Termination"
231
226
}
0 commit comments