Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify host name with updated prefix #343

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
santhoshatdell marked this conversation as resolved.
Show resolved Hide resolved
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