Skip to content

Commit 5ed0a04

Browse files
authored
[magnum-auto-healer] use github.com/google/uuid package (#2708)
Drop support of the outdated github.com/pborman/uuid
1 parent 7bfb2eb commit 5ed0a04

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/container-storage-interface/spec v1.9.0
77
github.com/go-chi/chi/v5 v5.0.8
88
github.com/google/uuid v1.6.0
9-
github.com/gophercloud/gophercloud/v2 v2.1.2-0.20241016132526-1c4dd03733fe
9+
github.com/gophercloud/gophercloud/v2 v2.2.0
1010
github.com/gophercloud/utils/v2 v2.0.0-20240701101423-2401526caee5
1111
github.com/hashicorp/go-version v1.6.0
1212
github.com/kubernetes-csi/csi-lib-utils v0.13.0
@@ -15,7 +15,6 @@ require (
1515
github.com/mitchellh/mapstructure v1.5.0
1616
github.com/onsi/ginkgo/v2 v2.19.0
1717
github.com/onsi/gomega v1.33.1
18-
github.com/pborman/uuid v1.2.1
1918
github.com/sirupsen/logrus v1.9.3
2019
github.com/spf13/cobra v1.8.1
2120
github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,15 @@ github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLe
220220
github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af h1:kmjWCqn2qkEml422C2Rrd27c3VGxi6a/6HNq8QmHRKM=
221221
github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
222222
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
223-
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
224223
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
225224
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
226225
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
227226
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
228227
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
229228
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
230229
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
231-
github.com/gophercloud/gophercloud/v2 v2.1.2-0.20241016132526-1c4dd03733fe h1:cbowqLRC8NQOuuJl/CkO7C0cCWJ0hAGt+V0Cz+XDWfI=
232-
github.com/gophercloud/gophercloud/v2 v2.1.2-0.20241016132526-1c4dd03733fe/go.mod h1:f2hMRC7Kakbv5vM7wSGHrIPZh6JZR60GVHryJlF/K44=
230+
github.com/gophercloud/gophercloud/v2 v2.2.0 h1:STqqnSXuhcg1OPBOZ14z6JDm8fKIN13H2bJg6bBuHp8=
231+
github.com/gophercloud/gophercloud/v2 v2.2.0/go.mod h1:f2hMRC7Kakbv5vM7wSGHrIPZh6JZR60GVHryJlF/K44=
233232
github.com/gophercloud/utils/v2 v2.0.0-20240701101423-2401526caee5 h1:/mLIQMTyjIVfiwQkknJS9XxEPLFuB70ss+ZrofChBf8=
234233
github.com/gophercloud/utils/v2 v2.0.0-20240701101423-2401526caee5/go.mod h1:3tI9DoiOJFBkqbOeAPqPns/QUnMCiflwYBvgR6KJdM4=
235234
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
@@ -327,8 +326,6 @@ github.com/opencontainers/runtime-spec v1.0.3-0.20220909204839-494a5a6aca78 h1:R
327326
github.com/opencontainers/runtime-spec v1.0.3-0.20220909204839-494a5a6aca78/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
328327
github.com/opencontainers/selinux v1.11.0 h1:+5Zbo97w3Lbmb3PeqQtpmTkMwsW5nRI3YaLpt7tQ7oU=
329328
github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec=
330-
github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw=
331-
github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
332329
github.com/pelletier/go-toml/v2 v2.0.7 h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9CjgDb8Us=
333330
github.com/pelletier/go-toml/v2 v2.0.7/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
334331
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=

pkg/autohealing/cloudprovider/openstack/provider.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
"github.com/gophercloud/gophercloud/v2/openstack/orchestration/v1/stackresources"
3535
"github.com/gophercloud/gophercloud/v2/openstack/orchestration/v1/stacks"
3636
"github.com/gophercloud/gophercloud/v2/pagination"
37-
uuid "github.com/pborman/uuid"
3837
apiv1 "k8s.io/api/core/v1"
3938
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4039
"k8s.io/apimachinery/pkg/util/sets"
@@ -47,6 +46,7 @@ import (
4746
"k8s.io/cloud-provider-openstack/pkg/autohealing/config"
4847
"k8s.io/cloud-provider-openstack/pkg/autohealing/healthcheck"
4948
"k8s.io/cloud-provider-openstack/pkg/client"
49+
"k8s.io/cloud-provider-openstack/pkg/util"
5050
)
5151

5252
const (
@@ -383,12 +383,11 @@ func (provider CloudProvider) Repair(nodes []healthcheck.NodeInfo) error {
383383
if isWorkerNode {
384384
for _, n := range nodes {
385385
nodesToReplace := sets.NewString()
386-
machineID := uuid.Parse(n.KubeNode.Status.NodeInfo.MachineID)
387-
if machineID == nil {
388-
log.Warningf("Failed to get the correct server ID for server %s", n.KubeNode.Name)
386+
serverID, err := util.UUID(n.KubeNode.Status.NodeInfo.MachineID)
387+
if err != nil {
388+
log.Warningf("Failed to get the correct server ID for server %s: %v", n.KubeNode.Name, err)
389389
continue
390390
}
391-
serverID := machineID.String()
392391

393392
if processed, err := provider.firstTimeRepair(n, serverID, firstTimeRebootNodes); err != nil {
394393
log.Warningf("Failed to process if the node %s is in first time repair , error: %v", serverID, err)
@@ -451,12 +450,11 @@ func (provider CloudProvider) Repair(nodes []healthcheck.NodeInfo) error {
451450
}
452451

453452
for _, n := range nodes {
454-
machineID := uuid.Parse(n.KubeNode.Status.NodeInfo.MachineID)
455-
if machineID == nil {
456-
log.Warningf("Failed to get the correct server ID for server %s", n.KubeNode.Name)
453+
serverID, err := util.UUID(n.KubeNode.Status.NodeInfo.MachineID)
454+
if err != nil {
455+
log.Warningf("Failed to get the correct server ID for server %s: %v", n.KubeNode.Name, err)
457456
continue
458457
}
459-
serverID := machineID.String()
460458

461459
if processed, err := provider.firstTimeRepair(n, serverID, firstTimeRebootNodes); err != nil {
462460
log.Warningf("Failed to process if the node %s is in first time repair , error: %v", serverID, err)
@@ -507,7 +505,11 @@ func (provider CloudProvider) Repair(nodes []healthcheck.NodeInfo) error {
507505

508506
// Remove the broken nodes from the cluster
509507
for _, n := range nodes {
510-
serverID := uuid.Parse(n.KubeNode.Status.NodeInfo.MachineID).String()
508+
serverID, err := util.UUID(n.KubeNode.Status.NodeInfo.MachineID)
509+
if err != nil {
510+
log.Warningf("Failed to get the correct server ID for server %s: %v", n.KubeNode.Name, err)
511+
continue
512+
}
511513
if _, found := firstTimeRebootNodes[serverID]; found {
512514
log.Infof("Skip node delete for %s because it's repaired by reboot", serverID)
513515
continue

0 commit comments

Comments
 (0)