Skip to content

Commit

Permalink
fix(CSI-297): nfsTargetIps override is handled incorreclty when empty (
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyberezansky authored Oct 23, 2024
2 parents d32d10f + d4e3b21 commit a691c37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
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

0 comments on commit a691c37

Please sign in to comment.