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

fix(CSI-297): nfsTargetIps override is handled incorreclty when empty #374

Merged
merged 1 commit into from
Oct 23, 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: 1 addition & 1 deletion pkg/wekafs/apiclient/interfacegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (a *ApiClient) GetNfsInterfaceGroup(ctx context.Context, name string) *Inte
// TODO: need to do it much more sophisticated way to distribute load
func (a *ApiClient) GetNfsMountIp(ctx context.Context, interfaceGroupName string) (string, error) {
// if override is set, use it
if len(a.Credentials.NfsTargetIPs) > 0 {
if len(a.Credentials.NfsTargetIPs) > 0 && a.Credentials.NfsTargetIPs[0] != "" {
ips := a.Credentials.NfsTargetIPs
idx := rand.Intn(len(ips))
ip := ips[idx]
Expand Down
3 changes: 3 additions & 0 deletions pkg/wekafs/wekafs.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ func (api *ApiStore) fromSecrets(ctx context.Context, secrets map[string]string,
nfsTargetIpsRaw := strings.TrimSpace(strings.ReplaceAll(strings.TrimSuffix(secrets["nfsTargetIps"], "\n"), "\n", ","))
nfsTargetIps = func() []string {
var ret []string
if nfsTargetIpsRaw == "" {
return ret
}
for _, s := range strings.Split(nfsTargetIpsRaw, ",") {
ret = append(ret, strings.TrimSpace(strings.TrimSuffix(s, "\n")))
}
Expand Down