Skip to content

Commit dcb0708

Browse files
authored
Replace custom Contains() with slices.Contains() (#3025)
Signed-off-by: Jongwoo Han <[email protected]>
1 parent 2ef5dc8 commit dcb0708

File tree

3 files changed

+6
-45
lines changed

3 files changed

+6
-45
lines changed

pkg/autohealing/healthcheck/plugin_endpoint.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ import (
2222
"fmt"
2323
"net/http"
2424
"os"
25+
"slices"
2526
"strings"
2627
"time"
2728

2829
"github.com/mitchellh/mapstructure"
2930
log "k8s.io/klog/v2"
30-
31-
"k8s.io/cloud-provider-openstack/pkg/autohealing/utils"
3231
)
3332

3433
const (
@@ -177,7 +176,7 @@ func (check *EndpointCheck) Check(ctx context.Context, node NodeInfo, controller
177176
}
178177
resp.Body.Close()
179178

180-
if !utils.ContainsInt(check.OKCodes, resp.StatusCode) {
179+
if !slices.Contains(check.OKCodes, resp.StatusCode) {
181180
log.V(4).Infof("Node %s, return code for url %s is %d, expected: %d", nodeName, url, resp.StatusCode, check.OKCodes)
182181
return check.checkDuration(ctx, node, controller, false)
183182
}

pkg/autohealing/healthcheck/plugin_nodecondition.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ package healthcheck
1919
import (
2020
"context"
2121
"fmt"
22+
"slices"
2223
"time"
2324

2425
"github.com/mitchellh/mapstructure"
2526
log "k8s.io/klog/v2"
26-
27-
"k8s.io/cloud-provider-openstack/pkg/autohealing/utils"
2827
)
2928

3029
const (
@@ -50,18 +49,18 @@ func (check *NodeConditionCheck) Check(ctx context.Context, node NodeInfo, contr
5049
nodeName := node.KubeNode.Name
5150

5251
for _, cond := range node.KubeNode.Status.Conditions {
53-
if utils.Contains(check.Types, string(cond.Type)) {
52+
if slices.Contains(check.Types, string(cond.Type)) {
5453
unhealthyDuration := time.Since(cond.LastTransitionTime.Time)
5554

5655
if len(check.ErrorValues) > 0 {
57-
if utils.Contains(check.ErrorValues, string(cond.Status)) {
56+
if slices.Contains(check.ErrorValues, string(cond.Status)) {
5857
if unhealthyDuration >= check.UnhealthyDuration {
5958
return false
6059
}
6160
log.Warningf("Node %s is unhealthy, %s: %s", nodeName, string(cond.Type), string(cond.Status))
6261
}
6362
} else if len(check.OKValues) > 0 {
64-
if !utils.Contains(check.OKValues, string(cond.Status)) {
63+
if !slices.Contains(check.OKValues, string(cond.Status)) {
6564
if unhealthyDuration >= check.UnhealthyDuration {
6665
return false
6766
}

pkg/autohealing/utils/utils.go

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)