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 54aacbd
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 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/"
endpointStoreLocationLinux = "/var/run/azure-cns/"
endpointStoreLocationWindows = "/k/azurecns/"
defaultCNINetworkConfigFileName = "10-azure.conflist"
dncApiVersion = "?api-version=2018-03-01"
poolIPAMRefreshRateInMilliseconds = 1000
Expand Down Expand Up @@ -114,6 +115,9 @@ var (
// Version is populated by make during build.
var version string

// endpointStorePath is used to create the path for EdnpointState file.
var endpointStorePath string

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

// Fill EndpointStatePath based on the platform
if os.Getenv("CNSStoreFilePath") != "" {
endpointStorePath = os.Getenv("CNSStoreFilePath")
} else {
if runtime.GOOS == "windows" {
endpointStorePath = endpointStoreLocationWindows
} else {
endpointStorePath = endpointStoreLocationLinux
}
}
go func() {
// Wait until receiving a signal.
select {
Expand Down Expand Up @@ -659,10 +673,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 54aacbd

Please sign in to comment.