Skip to content

Commit 9448308

Browse files
author
Riya
committed
updated code to fix lint error
1 parent 4c39aff commit 9448308

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

cns/restserver/internalapi.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ import (
2323
"github.com/Azure/azure-container-networking/cns/types"
2424
"github.com/Azure/azure-container-networking/common"
2525
"github.com/Azure/azure-container-networking/crd/nodenetworkconfig/api/v1alpha"
26+
"github.com/labstack/gommon/log"
2627
"github.com/pkg/errors"
28+
"go.uber.org/zap"
2729
)
2830

2931
const (
@@ -640,7 +642,7 @@ func (service *HTTPRestService) CreateOrUpdateNetworkContainerInternal(req *cns.
640642
req.IPConfiguration.IPSubnet.PrefixLength)
641643
// delete the existing azure-cns file
642644
if err := os.Remove(cnsStateFilePath); err != nil && !os.IsNotExist(err) {
643-
logger.Errorf("[Azure CNS] Error deleting azure-cns state file: %v", err)
645+
log.Error("Error deleting azure-cns state file", zap.Error(err))
644646
}
645647

646648
// panic (this will force azure-cns daemonset to restart and pick up the new state with updated nnc)

cns/restserver/internalapi_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func TestReconcileNCStatePrimaryIPChangeShouldFail(t *testing.T) {
9797

9898
// Create dummy CNS state file
9999
stateFile := "/var/lib/azure-network/azure-cns.json"
100-
_ = os.WriteFile(stateFile, []byte("dummy"), 0644)
100+
_ = os.WriteFile(stateFile, []byte("dummy"), 0600)
101101
defer os.Remove(stateFile)
102102

103103
defer func() {
@@ -1701,13 +1701,13 @@ func TestCreateOrUpdateNCInternal_PrimaryCAMismatchShouldPanicAndDeleteStateFile
17011701
// Step 1: Create initial NC with PrimaryCA "10.0.0.5/24"
17021702
secondaryIPConfigs := make(map[string]cns.SecondaryIPConfig)
17031703
ipaddress := "10.0.0.6"
1704-
secIpConfig := newSecondaryIPConfig(ipaddress, -1)
1705-
ipId := uuid.New()
1706-
secondaryIPConfigs[ipId.String()] = secIpConfig
1704+
secIPConfig := newSecondaryIPConfig(ipaddress, -1)
1705+
ipID := uuid.New()
1706+
secondaryIPConfigs[ipID.String()] = secIPConfig
17071707

1708-
ncId := "test-nc"
1708+
ncID := "test-nc"
17091709
ncVersion := "-1"
1710-
req := generateNetworkContainerRequest(secondaryIPConfigs, ncId, ncVersion)
1710+
req := generateNetworkContainerRequest(secondaryIPConfigs, ncID, ncVersion)
17111711
req.IPConfiguration.IPSubnet.IPAddress = "10.0.0.5"
17121712
req.IPConfiguration.IPSubnet.PrefixLength = 24
17131713
returnCode := svc.CreateOrUpdateNetworkContainerInternal(req)
@@ -1717,13 +1717,13 @@ func TestCreateOrUpdateNCInternal_PrimaryCAMismatchShouldPanicAndDeleteStateFile
17171717
validateNetworkRequest(t, *req)
17181718

17191719
// Step 2: Prepare a request with a different PrimaryCA
1720-
reqMismatch := generateNetworkContainerRequest(secondaryIPConfigs, ncId, ncVersion)
1720+
reqMismatch := generateNetworkContainerRequest(secondaryIPConfigs, ncID, ncVersion)
17211721
reqMismatch.IPConfiguration.IPSubnet.IPAddress = "10.0.0.7" // different IP
17221722
reqMismatch.IPConfiguration.IPSubnet.PrefixLength = 24
17231723

17241724
// Step 3: Create dummy CNS state file
17251725
stateFile := "/var/lib/azure-network/azure-cns.json"
1726-
_ = os.WriteFile(stateFile, []byte("dummy"), 0644)
1726+
_ = os.WriteFile(stateFile, []byte("dummy"), 0600)
17271727
defer os.Remove(stateFile)
17281728

17291729
defer func() {

0 commit comments

Comments
 (0)