Skip to content
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
4 changes: 2 additions & 2 deletions cns/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ func SetCNSConfigDefaults(config *CNSConfig) {
config.SyncHostNCTimeoutMs = 500 //nolint:gomnd // default times
}
if config.PopulateHomeAzCacheRetryIntervalSecs == 0 {
// set the default PopulateHomeAzCache retry interval to 15 seconds
config.PopulateHomeAzCacheRetryIntervalSecs = 15
// set the default PopulateHomeAzCache retry interval to 30 seconds
config.PopulateHomeAzCacheRetryIntervalSecs = 30
}
if config.WireserverIP == "" {
config.WireserverIP = "168.63.129.16"
Expand Down
2 changes: 1 addition & 1 deletion cns/configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func TestSetCNSConfigDefaults(t *testing.T) {
KeyVaultSettings: KeyVaultSettings{
RefreshIntervalInHrs: 12,
},
PopulateHomeAzCacheRetryIntervalSecs: 15,
PopulateHomeAzCacheRetryIntervalSecs: 30,
WireserverIP: "168.63.129.16",
},
},
Expand Down
7 changes: 7 additions & 0 deletions cns/restserver/homeazmonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ func (h *HomeAzMonitor) Populate(ctx context.Context) {
return
}

// validate home az value, HomeAz is a uint, so it's value >=0
if azResponse.HomeAz == 0 {
returnMessage := fmt.Sprintf("[HomeAzMonitor] invalid home az value from nmagent: %d", azResponse.HomeAz)
returnCode := types.UnexpectedError
h.update(returnCode, returnMessage, cns.HomeAzResponse{IsSupported: true})
return
}
h.update(types.Success, "Get Home Az succeeded", cns.HomeAzResponse{IsSupported: true, HomeAz: azResponse.HomeAz})
}

Expand Down
13 changes: 13 additions & 0 deletions cns/restserver/homeazmonitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ func TestHomeAzMonitor(t *testing.T) {
cns.HomeAzResponse{},
false,
},
{
"api supported but home az value is not valid",
&fakes.NMAgentClientFake{
SupportedAPIsF: func(ctx context.Context) ([]string, error) {
return []string{GetHomeAzAPIName}, nil
},
GetHomeAzF: func(ctx context.Context) (nmagent.AzResponse, error) {
return nmagent.AzResponse{HomeAz: 0}, nil
},
},
cns.HomeAzResponse{IsSupported: true},
true,
},
{
"api supported but got unexpected errors",
&fakes.NMAgentClientFake{
Expand Down