Граф коммитов

39 Коммитов

Автор SHA1 Сообщение Дата
Ramiro 2a09dd3a39
fix: deadlock when os.Stat errors within rotate method (#1716)
* fix: deadlock when os.Stat errors within rotate method

* pr feedback: adding test
2023-08-10 13:16:58 -07:00
Quang Nguyen 60e5a26565
feat: CNS manages endpoints state for delegate IPAM use case (#1500)
* 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>
2022-08-23 16:42:40 -07:00
Timothy J. Raymond 297a157bef
fix: panic caused by nil Writer provided to Logger (#1228)
* 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.
2022-02-10 16:01:53 -05:00
Eng Zer Jun e812bc82b8
refactor: move from io/ioutil to io and os packages (#1096)
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>
2021-11-17 16:31:42 -06:00
Mathew Merrick fa8f665ab5
ci: add windows build pool and NPM windows dockerfile (#1073)
* build pool windows
2021-11-05 10:30:09 -07:00
Evan Baker 96bec09d41
chore: appease the linter (3/?), the big gofumpt (#987)
* gofumpt -w -s .

* small addtl cleanups after gofumpt

* rerun after rebase
2021-09-02 16:33:18 -05:00
Jaeryn 8acc37d6eb
Removing telemetry processed on HostNetAgent (#903)
Co-authored-by: Jaeryn <tsun.chu@microsoft.com>
2021-06-21 13:22:44 -07:00
Mathew Merrick 1fa243e5f5
CI: Add golint-ci (#888)
* add golint-ci

* add gofmt

* enable linters

* uncap count

* fix linting/fmt issues
2021-06-01 16:58:56 -07:00
shchen dc7ff48c78
Fix log which let log to show more readable info. (#803)
Address feedback.
2021-03-17 17:10:23 -07:00
Ramiro 685cf90b77
log rotation does not respect previous target (#797)
Submitting this as they are blocked because of Test infra issue. Change is scoped
2021-02-22 17:47:05 -08:00
Jaeryn ab1f6fc75d
Limit and rotate NPM logs (#573) 2020-06-03 13:45:38 -07:00
Ashvin Deodhar ca00635a6b
Fix CNS regression (#489)
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.
2020-01-30 09:33:35 -08:00
Zhiwei Liu 208831533d Add pid to log (#360)
* add pid to log

* fix code format
2019-07-25 22:13:44 -07:00
Yongli Chen f6bff8e3af
change telemetry to message queue and add npm (#366)
* 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
2019-06-19 14:08:35 -07:00
jaer-tsun 3043dc9736
CNS to start telemetry process and connect to it (#324)
* Spawn telemetry buffer in a separate process instead of goroutine.

* Adding an option to disable telemetry.

* Addressing some of Tamilmani's comments.
2019-04-08 16:20:05 -07:00
jaer-tsun 0012ae5344
Temporarily disabling telemetry. (#318) 2019-03-25 13:29:22 -07:00
jaer-tsun 67debca901
Add ability in CNS to setup networking for a docker container (#298)
* Limiting the size of our buffered payload to ~2MB

* CNI Update operation support

* Adding APIs for attach/detach network container to/from network.

* Updating new apis.

* Addressing Tamilmani's review/comments.

* Renaming Batch APIs and Request members for better clarity.

* Adding check for pluginsSection length before accessing element.

* Renaming ConfigureNetworkContainerNetworkingRequest to ConfigureContainerNetworkRequest.

* Adding default k8s cni paths for windows.

* Adding AzureFirstParty orchestrator type and Basic container type.

* Addressing Sushant's comments.
2019-02-26 16:04:27 -08:00
jaer-tsun 136f03caf7 Cns telemetry (#275)
Adds telemetry capability for CNS.
2018-12-12 10:45:48 -08:00
jaer-tsun 431ac08469 Enable Circleci (#220)
Enable CircleCi
2018-08-14 12:08:48 -07:00
tamilmani1989 147c4388c8 Multitenancy Support for Linux (#156)
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.
2018-07-06 11:45:47 -07:00
jaer-tsun 26bb64d90b Locking loggers in case of multi-threaded apps. (#171) 2018-06-08 09:54:42 -07:00
tamilmani1989 40237b7444
Convert time to UTC (#162)
* convert time to utc

* Added a fix in getting last reboot time.

* moved logpath from platform to log package to prevent cycle
2018-06-04 16:47:21 -07:00
Sushant Sharma c69ab4e8e4
Add APIs in CNS to support multitenancy (#106)
* 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.
2018-03-28 15:03:58 -07:00
Onur Filiz f266e98f52 Add support for log file rotation 2017-06-14 13:10:37 -07:00
Onur Filiz 437f7876d7 Added license notice to all source files 2017-02-12 02:03:39 -08:00
Onur Filiz 27d06d62d2 Updated logger to use OS-specific logfile path 2017-01-20 16:23:24 -08:00
Onur Filiz 93e8362e56 Added support to set custom log file path and name 2017-01-18 17:53:20 -08:00
Onur Filiz 62f3c06b17 Added support to set custom log file path and name 2017-01-18 16:56:59 -08:00
Onur Filiz bde3dd2dbf Added support to set custom log file path and name 2017-01-18 14:12:51 -08:00
Onur Filiz aba9634034 Separated syslog to Linux builds 2017-01-17 10:26:00 -08:00
Onur Filiz 1ecd8cd35c Enabled Windows builds by removing package depedencies 2017-01-16 14:12:48 -08:00
Onur Filiz a7c76ec18c Added logfile support and made it the default log target 2016-10-18 15:12:13 -07:00
Onur Filiz 3a5f237ebe Updated plugin initialization and logging to be more consistent 2016-09-25 21:22:01 -07:00
Onur Filiz 9b13aa09f6 Updated netlink socket calls to log at debug level 2016-06-05 20:58:47 -07:00
Onur Filiz d27c791363 Simplified and improved performance of log APIs 2016-05-02 19:26:13 -07:00
Onur Filiz df968d06d9 Fixed formatting bug in log.Printf 2016-04-15 16:29:51 -07:00
Onur Filiz e3445c49ac Added log API for basic string logging 2016-03-28 03:31:34 -07:00
Sushant Sharma d901f532e8 Fix the case for dependencies path 2016-03-21 15:40:21 -07:00
Onur Filiz efba38effa Task: 5544454 Created log package, simplified logging APIs 2016-03-01 16:52:22 -08:00