* rebase
* linting
* rebase
* missing if condition for releaseIPConfig
* update azure-cns.yaml and add UTs
* rebase
* update program iptables changes
* linting
* fix broken tests
* fix podinfoprovider returns error when key is not found
* log when no endpoint state exist when reconcilling
* not remove endpoint state file on failure to read in restserver.restoreState()
* addressed comments
* update acn tag
* go get on acn
* addressed comments
Co-authored-by: Evan Baker <rbtr@users.noreply.github.com>
* fix: panic caused by nil Writer provided to Logger
In the log.(*Logger).Init method, several different strategies are
considered based on the configuration provided by the user. In one
common case, a rotating log file is opened and the log output is tee-ed
into it. If there is any issue with opening that log file, the
`log.(*Log).SetOutput` method is never invoked on the underlying logger.
Since this standard library logger was created with `nil` passed as the
`io.Writer`, this results in a nil pointer deref panic. The error
causing the issue is also not surfaced to the user.
This initializes the standard library logger with the `io.Discard`
writer. This adheres to the original intention here, while also being a
safer alternative to nil (effectively writes are to /dev/null). Also,
the error is written out to stderr, in the hopes that an operator will
be able to diagnose and fix the issue (in the absense of a correct
logger configuration).
Finally, the logger initialization has been moved to a new
function, `log.NewLoggerE` that properly exposes the underlying error.
The original function, `NewLogger`, has been modified to use this
function instead and has been marked Deprecated.
* Remove redundant types in function signatures
The linter correctly pointed out that the types are redundant here.
While ordinarily I tend to leave them if the ellision appears in the
middle of the signature, I respect the linter's decision :)
* Change NewLoggerE test to use TempDir
Rather than trying to pull a non-existant path out of thin air and
hoping that it doesn't exist, this instead uses os.TempDir to create a
guaranteed-empty directory. From within the newly-created tempdir we try
to use a non-existent path. This is better both on a single platform,
but also has the benefit of working well on Windows too.
* Fix test to use os.MkdirTemp instead of os.TempDir
The intention of this test was to create a new temporary directory
rather than use the system's temporary directory. This mistake was
pointed out by @rbtr in a code review (thanks!).
* Fix nil logger under error conditions
When an error is present, we want to return both the error and the
logger to guarantee that a usable logger is always present. This returns
the logger in all circumstances and documents that fact in the godoc for
this function.
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
log.SetTarget creates the log file under log directory using golang os package. Whenever code sets the log directory, it needed to call SetTarget to create the actual log file under that directory. In the recent logger changes, InitLogger by default set the log directory to the current folder. This created the log file in the current folder. The code then set the log directory to a different location without a subsequent call to log.SetTarget. This resulted into the logger to not find the actual log file in the set log directory.
This fix updates the logger InitLogger function to accept the log directory to create the file in correct log directory. To avoid having such issue, this fix also combines the function calls to set log directory and set target into a single function. This prevents any out of order calls resulting into such issue.
* change telemetry to message queue and add npm
* remove [Azure-NPM] prefix
* remove npmreport url
* fair scheduling
* holds up to 1k reports for each type
* fix cap on reports
* Spawn telemetry buffer in a separate process instead of goroutine.
* Adding an option to disable telemetry.
* Addressing some of Tamilmani's comments.
This PR adds the following capabilities
1. Support to create and connect containers to different Azure Vnets. Every VlanId corresponds to a different Azure Vnet.
2. SNAT support for containers to reach Internet using the container's host IP as the SNAT address.
Both the above options are controlled by the config parameters in Azure CNI.
* APIs to support multitenancy in Azure.
* Add support to create, update, and delete network containers (adapters) in windows hosts
* Add API to query host for programmed version of a container
* Add API to retrieve interface given a container ID
* Add support for custom log directory.