@@ -133,7 +133,7 @@ func (pl *ServiceAffinity) PreFilter(ctx context.Context, cycleState *framework.
133
133
134
134
s , err := pl .createPreFilterState (pod )
135
135
if err != nil {
136
- return framework .NewStatus ( framework . Error , fmt .Sprintf ("could not create preFilterState: %v " , err ))
136
+ return framework .AsStatus ( fmt .Errorf ("could not create preFilterState: %w " , err ))
137
137
}
138
138
cycleState .Write (preFilterStateKey , s )
139
139
return nil
@@ -151,7 +151,7 @@ func (pl *ServiceAffinity) PreFilterExtensions() framework.PreFilterExtensions {
151
151
func (pl * ServiceAffinity ) AddPod (ctx context.Context , cycleState * framework.CycleState , podToSchedule * v1.Pod , podToAdd * v1.Pod , nodeInfo * framework.NodeInfo ) * framework.Status {
152
152
s , err := getPreFilterState (cycleState )
153
153
if err != nil {
154
- return framework .NewStatus ( framework . Error , err . Error () )
154
+ return framework .AsStatus ( err )
155
155
}
156
156
157
157
// If addedPod is in the same namespace as the pod, update the list
@@ -172,7 +172,7 @@ func (pl *ServiceAffinity) AddPod(ctx context.Context, cycleState *framework.Cyc
172
172
func (pl * ServiceAffinity ) RemovePod (ctx context.Context , cycleState * framework.CycleState , podToSchedule * v1.Pod , podToRemove * v1.Pod , nodeInfo * framework.NodeInfo ) * framework.Status {
173
173
s , err := getPreFilterState (cycleState )
174
174
if err != nil {
175
- return framework .NewStatus ( framework . Error , err . Error () )
175
+ return framework .AsStatus ( err )
176
176
}
177
177
178
178
if len (s .matchingPodList ) == 0 ||
@@ -239,12 +239,12 @@ func (pl *ServiceAffinity) Filter(ctx context.Context, cycleState *framework.Cyc
239
239
240
240
node := nodeInfo .Node ()
241
241
if node == nil {
242
- return framework .NewStatus ( framework . Error , "node not found" )
242
+ return framework .AsStatus ( fmt . Errorf ( "node not found" ) )
243
243
}
244
244
245
245
s , err := getPreFilterState (cycleState )
246
246
if err != nil {
247
- return framework .NewStatus ( framework . Error , err . Error () )
247
+ return framework .AsStatus ( err )
248
248
}
249
249
250
250
pods , services := s .matchingPodList , s .matchingPodServices
@@ -257,7 +257,7 @@ func (pl *ServiceAffinity) Filter(ctx context.Context, cycleState *framework.Cyc
257
257
if len (filteredPods ) > 0 {
258
258
nodeWithAffinityLabels , err := pl .sharedLister .NodeInfos ().Get (filteredPods [0 ].Spec .NodeName )
259
259
if err != nil {
260
- return framework .NewStatus ( framework . Error , "node not found" )
260
+ return framework .AsStatus ( fmt . Errorf ( "node not found" ) )
261
261
}
262
262
addUnsetLabelsToMap (affinityLabels , pl .args .AffinityLabels , labels .Set (nodeWithAffinityLabels .Node ().Labels ))
263
263
}
@@ -275,12 +275,12 @@ func (pl *ServiceAffinity) Filter(ctx context.Context, cycleState *framework.Cyc
275
275
func (pl * ServiceAffinity ) Score (ctx context.Context , state * framework.CycleState , pod * v1.Pod , nodeName string ) (int64 , * framework.Status ) {
276
276
nodeInfo , err := pl .sharedLister .NodeInfos ().Get (nodeName )
277
277
if err != nil {
278
- return 0 , framework .NewStatus ( framework . Error , fmt .Sprintf ("getting node %q from Snapshot: %v " , nodeName , err ))
278
+ return 0 , framework .AsStatus ( fmt .Errorf ("getting node %q from Snapshot: %w " , nodeName , err ))
279
279
}
280
280
281
281
node := nodeInfo .Node ()
282
282
if node == nil {
283
- return 0 , framework .NewStatus ( framework . Error , fmt .Sprintf ("node not found" ))
283
+ return 0 , framework .AsStatus ( fmt .Errorf ("node not found" ))
284
284
}
285
285
286
286
// Pods matched namespace,selector on current node.
@@ -313,7 +313,7 @@ func (pl *ServiceAffinity) NormalizeScore(ctx context.Context, _ *framework.Cycl
313
313
reduceResult := make ([]float64 , len (scores ))
314
314
for _ , label := range pl .args .AntiAffinityLabelsPreference {
315
315
if err := pl .updateNodeScoresForLabel (pl .sharedLister , scores , reduceResult , label ); err != nil {
316
- return framework .NewStatus ( framework . Error , err . Error () )
316
+ return framework .AsStatus ( err )
317
317
}
318
318
}
319
319
0 commit comments