Skip to content

Commit

Permalink
making change to CNSendpointStorePath
Browse files Browse the repository at this point in the history
  • Loading branch information
behzad-mir committed Nov 28, 2023
1 parent 20bc807 commit 35227c8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions cns/service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ const (
name = "azure-cns"
pluginName = "azure-vnet"
endpointStoreName = "azure-endpoints"
endpointStoreLocation = "/var/run/azure-cns/"
endpointStoreLocation_Linux = "/var/run/azure-cns/"

Check warning on line 84 in cns/service/main.go

View workflow job for this annotation

GitHub Actions / Lint (1.20.x, ubuntu-latest)

var-naming: don't use underscores in Go names; const endpointStoreLocation_Linux should be endpointStoreLocationLinux (revive)

Check warning on line 84 in cns/service/main.go

View workflow job for this annotation

GitHub Actions / Lint (1.21.x, ubuntu-latest)

var-naming: don't use underscores in Go names; const endpointStoreLocation_Linux should be endpointStoreLocationLinux (revive)
endpointStoreLocation_Windows = "/k/azurecns/"

Check warning on line 85 in cns/service/main.go

View workflow job for this annotation

GitHub Actions / Lint (1.20.x, ubuntu-latest)

var-naming: don't use underscores in Go names; const endpointStoreLocation_Windows should be endpointStoreLocationWindows (revive)

Check warning on line 85 in cns/service/main.go

View workflow job for this annotation

GitHub Actions / Lint (1.21.x, ubuntu-latest)

var-naming: don't use underscores in Go names; const endpointStoreLocation_Windows should be endpointStoreLocationWindows (revive)
defaultCNINetworkConfigFileName = "10-azure.conflist"
dncApiVersion = "?api-version=2018-03-01"
poolIPAMRefreshRateInMilliseconds = 1000
Expand Down Expand Up @@ -113,6 +114,7 @@ var (

// Version is populated by make during build.
var version string
var endpointStorePath string

// Command line arguments for CNS.
var args = acn.ArgumentList{
Expand Down Expand Up @@ -335,6 +337,16 @@ func init() {
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM)

//populating EndpointStatePath based on the platform

Check failure on line 340 in cns/service/main.go

View workflow job for this annotation

GitHub Actions / Lint (1.20.x, ubuntu-latest)

commentFormatting: put a space between `//` and comment text (gocritic)

Check failure on line 340 in cns/service/main.go

View workflow job for this annotation

GitHub Actions / Lint (1.21.x, ubuntu-latest)

commentFormatting: put a space between `//` and comment text (gocritic)
if os.Getenv("CNSStoreFilePath") != "" {
endpointStorePath = os.Getenv("CNSStoreFilePath")
} else {
if runtime.GOOS == "windows" {
endpointStorePath = endpointStoreLocation_Windows
} else {
endpointStorePath = endpointStoreLocation_Linux
}
}
go func() {
// Wait until receiving a signal.
select {
Expand Down Expand Up @@ -659,10 +671,6 @@ func main() {
}
defer endpointStoreLock.Unlock() // nolint

endpointStorePath := endpointStoreLocation
if runtime.GOOS == "windows" {
endpointStorePath = os.Getenv("CNSStoreFilePath")
}
err = platform.CreateDirectory(endpointStorePath)
if err != nil {
logger.Errorf("Failed to create File Store directory %s, due to Error:%v", storeFileLocation, err.Error())
Expand Down

0 comments on commit 35227c8

Please sign in to comment.