diff --git a/pkg/array/array.go b/pkg/array/array.go index c52c43b6..57d38883 100644 --- a/pkg/array/array.go +++ b/pkg/array/array.go @@ -201,6 +201,8 @@ func GetPowerStoreArrays(fs fs.Interface, filePath string) (map[string]*PowerSto rateLimit, err := strconv.Atoi(throttlingRateLimit) if err != nil { log.Errorf("can't get throttling rate limit, using default") + } else if rateLimit < 0 { + log.Errorf("throttling rate limit is negative, using default") } else { clientOptions.SetRateLimit(uint64(rateLimit)) } diff --git a/pkg/node/node.go b/pkg/node/node.go index e0a173f0..b5d37fb5 100644 --- a/pkg/node/node.go +++ b/pkg/node/node.go @@ -1,6 +1,6 @@ /* * - * Copyright © 2021-2023 Dell Inc. or its subsidiaries. All Rights Reserved. + * Copyright © 2021-2024 Dell Inc. or its subsidiaries. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1466,16 +1466,11 @@ func (s *Service) setupHost(initiators []string, client gopowerstore.Client, arr } } - ip, err := getOutboundIP(arrayIP, s.Fs) + // Modify the host entry with the new node ID having different prefix + err := s.modifyHostName(context.Background(), client, s.nodeID, host.ID) if err != nil { - log.WithFields(log.Fields{ - "endpoint": arrayIP, - "error": err, - }).Error("Could not connect to PowerStore array") - return status.Errorf(codes.FailedPrecondition, "couldn't connect to PowerStore array: %s", err.Error()) + return fmt.Errorf("cannot update the host name %s", err.Error()) } - - s.nodeID = host.Name + "-" + ip.String() s.reusedHost = true } @@ -1484,6 +1479,17 @@ func (s *Service) setupHost(initiators []string, client gopowerstore.Client, arr return nil } +func (s *Service) modifyHostName(ctx context.Context, client gopowerstore.Client, nodeID string, hostID string) error { + modifyParams := gopowerstore.HostModify{} + modifyParams.Name = &nodeID + _, err := client.ModifyHost(ctx, &modifyParams, hostID) + if err != nil { + return err + } + log.Info("Updated nodeID ", nodeID) + return nil +} + func (s *Service) buildInitiatorsArray(initiators []string) []gopowerstore.InitiatorCreateModify { var portType gopowerstore.InitiatorProtocolTypeEnum if s.useNVME { diff --git a/pkg/node/node_test.go b/pkg/node/node_test.go index 67e57490..5091ecd9 100644 --- a/pkg/node/node_test.go +++ b/pkg/node/node_test.go @@ -1,6 +1,6 @@ /* * - * Copyright © 2021-2023 Dell Inc. or its subsidiaries. All Rights Reserved. + * Copyright © 2021-2024 Dell Inc. or its subsidiaries. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -484,6 +484,8 @@ var _ = ginkgo.Describe("CSINodeService", func() { }}, Name: "host-name", }}, nil) + clientMock.On("ModifyHost", mock.Anything, mock.Anything, "host-id"). + Return(gopowerstore.CreateResponse{ID: "host-id"}, nil) err := nodeSvc.Init() gomega.Expect(err).To(gomega.BeNil())