Skip to content

Commit

Permalink
Merge pull request #343 from dell/bug-1458-node-prefix
Browse files Browse the repository at this point in the history
Modify host name with updated prefix
  • Loading branch information
suryagupta4 authored Sep 11, 2024
2 parents 0efdeeb + 404c7be commit 3108c1d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions pkg/array/array.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
24 changes: 15 additions & 9 deletions pkg/node/node.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
}

Expand All @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion pkg/node/node_test.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 3108c1d

Please sign in to comment.