Skip to content

Commit f4a3c9b

Browse files
committed
address comment
1 parent e869e49 commit f4a3c9b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

cns/hnsclient/hnsclient_windows.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ func CreateHostNCApipaEndpoint(
576576
return endpoint.Id, nil
577577
}
578578

579-
adhocAdjustIPConfig(&localIPConfiguration)
579+
adjustIPConfig(&localIPConfiguration)
580580
if network, err = createHostNCApipaNetwork(localIPConfiguration); err != nil {
581581
logger.Errorf("[Azure CNS] Failed to create HostNCApipaNetwork. Error: %v", err)
582582
return "", err
@@ -608,8 +608,11 @@ func CreateHostNCApipaEndpoint(
608608
return endpoint.Id, nil
609609
}
610610

611-
// adhocAdjustIPConfig applies adhoc change on gw IP address
612-
func adhocAdjustIPConfig(localIPConfiguration *cns.IPConfiguration) {
611+
// adjustIPConfig applies change on gw IP address.
612+
// currently cns using the same ip address "169.254.128.1" for both apipa gw and loopback adapter. This cause conflict
613+
// issue when hns get restarted and not able to rehydrate the apipa endpoints. This func is to overwrite the address to 169.254.128.2
614+
// when the gateway address is 169.254.128.1
615+
func adjustIPConfig(localIPConfiguration *cns.IPConfiguration) {
613616
// When gw address is 169.254.128.1, should use .2 instead. If gw address is not .1, that mean this value is
614617
// configured from dnc, we should keep it
615618
if localIPConfiguration.GatewayIPAddress == "169.254.128.1" {

cns/hnsclient/hnsclient_windows_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestAdhocAdjustIPConfig(t *testing.T) {
2828
for _, tt := range tests {
2929
tt := tt
3030
t.Run(tt.name, func(t *testing.T) {
31-
adhocAdjustIPConfig(&tt.ipConfig)
31+
adjustIPConfig(&tt.ipConfig)
3232
assert.Equal(t, tt.expected.GatewayIPAddress, tt.ipConfig.GatewayIPAddress)
3333
})
3434
}

0 commit comments

Comments
 (0)