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

522 Коммитов

Автор SHA1 Сообщение Дата
Jackie Luc bf2b3d266d
[CNS] add config snapshot event metrics at an interval (#3140)
* feat: add and expose new ConfigSnapshotIntervalInMins config

* feat: add interval event emitting of CNS config snapshot

* lint: address lint errors

* chore: send CNS config snapshot immediately

* test: refactor test to be less coupled

* lint

* fix: remove setting default ConfigSnapshotIntervalInMins

* chore: remove unnecessary comment
2024-11-20 23:33:43 +00:00
Evan Baker eae269127e
Revert "feat: use proto in CNS usage of client-go " (#3152)
Revert "feat: use proto in CNS usage of client-go  (#3131)"

This reverts commit 082d6a6655.
2024-11-15 17:03:41 +00:00
Evan Baker c3f1a6ef9e
fix: remove PowerShell from Windows registry interactions (#2993)
remove powershell from windows registry txs

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
2024-11-13 21:22:03 +00:00
Paul Yu 42aea15a34
Fix: Add default route on delegatedNIC interface (#3109)
* add default route on delegatedNIC interface

* remove logger import

* fix linter issue

* fix comments

* format codes

* gofumpt file

* enhance comment

* Update cns/middlewares/k8sSwiftV2_linux.go

Co-authored-by: Evan Baker <rbtr@users.noreply.github.com>
Signed-off-by: Paul Yu <129891899+paulyufan2@users.noreply.github.com>

---------

Signed-off-by: Paul Yu <129891899+paulyufan2@users.noreply.github.com>
Co-authored-by: Evan Baker <rbtr@users.noreply.github.com>
2024-11-12 21:03:17 +00:00
ZetaoZhuang 9b43fb7f8d
expose MinTLSVersion config for TLS handshake (#3103)
* expose MinTLSVersion config

* address comment

* use valid TLS version in config test
2024-11-12 20:50:09 +00:00
Evan Baker 6a53d5d49b
feat: Windows HPC base image (#3105)
feat: windows hpc base image

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
2024-11-12 16:42:42 +00:00
Paul Yu 8e8a5fde51
Remove l2bridge checker on windows and l2tunnel mode (#3113)
* remove l2bridge checker and l2tunnel mode

* fix l2bridge type

* fix the comment to add an UT to ensure hcn network type is always l2bridge

* go format to fix the linter issue
2024-11-11 22:49:49 +00:00
Behzad Mirkhanzadeh c524294729
feat: adding stateless CNI support for ACI (#3085)
* feat: adding stateless CNI support for ACI

* fix:adding unit test

* addressing the comments
2024-11-08 21:18:30 +00:00
Evan Baker 082d6a6655
feat: use proto in CNS usage of client-go (#3131)
feat: use proto in client-go

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
2024-11-08 20:25:55 +00:00
Evan Baker 3c4641c1c8
feat: add IPConfig state logs/metrics to Request/Release handlers (#3050)
* feat: add IPConfig state logs/metrics to Request/Release handlers

Signed-off-by: Evan BaKer <rbtr@users.noreply.github.com>

* make metrics recording async so that it will not block ip requests

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>

---------

Signed-off-by: Evan BaKer <rbtr@users.noreply.github.com>
Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
2024-11-05 20:14:30 +00:00
Santhosh Prabhu 1c1bbaa924
feat: support for cilium + nodesubnet (#3073)
* feat: support for cilium + nodesubnet

* fix: make linter happy

* fix: make linter happy

* fix: make linter happy

* test: add test for nodesubnet

* chore: add missing files

* nicer comment

* chore: fix comment typo

* fix: update cns/restserver/nodesubnet.go

Co-authored-by: Timothy J. Raymond <timraymond@users.noreply.github.com>
Signed-off-by: Santhosh  Prabhu  <6684582+santhoshmprabhu@users.noreply.github.com>

* fix: update cns/restserver/restserver.go

Co-authored-by: Timothy J. Raymond <timraymond@users.noreply.github.com>
Signed-off-by: Santhosh  Prabhu  <6684582+santhoshmprabhu@users.noreply.github.com>

* refactor: address comments

* fix: address comments

* chore:comment cleanup

* fix: do not use bash in ip config update

* fix: address comments

* fix: make linter happy

* chore: move pipeline changes out

* test: more elaborate test including checks on IP pool state

* fix: use comments suitable for documentation

Co-authored-by: Timothy J. Raymond <timraymond@users.noreply.github.com>
Signed-off-by: Santhosh  Prabhu  <6684582+santhoshmprabhu@users.noreply.github.com>

* chore: address comments

* chore:make linter happy

* fix: address comments

* chore: typo

* chore: address comments

* fix: update comments

---------

Signed-off-by: Santhosh  Prabhu  <6684582+santhoshmprabhu@users.noreply.github.com>
Co-authored-by: Timothy J. Raymond <timraymond@users.noreply.github.com>
2024-11-05 00:24:57 +00:00
Alexander 7f0339a294
fix: pass ai metadata to telemetry during cni image build (#3095)
* fix log on ai telemetry handle create error

* fix failure to pass cni ai id at build time for cni images

* address feedback

* move ai id to hardcoded variable

* update unit test

* Revert "move ai id to hardcoded variable"

This reverts commit 666c2b0a8f.

* fix typo
2024-11-04 21:39:37 +00:00
ZetaoZhuang 7d6ce69115
change apipa network gw address from .1 to .2 (#2933)
* change gw address to .2

* refactor and add UTs

* fix lint

* fix loopback adapter default gw address

* remote address should always be .1

* address comment

* adjust comment

* ddress comment

* fix func comment

* fix loopback adapter gw
2024-10-22 19:32:56 +00:00
Santhosh Prabhu f91ab26336
feat: create a dummy NC to store secondary IPs in nodesubnet deployments with Cilium (#3057)
* WIP

* chore: first set of files for nodesubnet nc

* chore: add ipam reconciler interface

* feat: add ability to save fake nodesubnet nc

* fix: make linter happy, cleanup

* chore: cleanup

* fix: make linter happy

* fix: make linter happy

* fix: fix failing test

* refactor: remove public ipam reconciler interface

* fix: fix compile after unexporting interface

* refactor: break down IPAM reconciliation to address Evan's comment

* chore: fix comment

* fix:make linter happy

* fix: Address comments, add todo for Evan's feedback

* Address comments

* fix: fix tests
2024-10-17 23:59:40 +00:00
Santhosh Prabhu b5046a001f
Make throttling nmagent fetches for nodesubnet more dynamic (#3023)
* feat(CNS): Early work on better throttling in NMAgent fetch for nodesubnet

* feat(CNS): Update NMAgent fetches to be async with binary exponential backoff

* chore: check for empty nmagent response

* test: update test for empty response

* style: make linter happy

* chore: fix some comments

* fix: Fix bug in refresh

* refactor: Address comments

* refactor: ignore primary ip

* refactor: move refresh out of ipfetcher

* test: add ip fetcher tests

* fix: remove broken import

* fix: fix import

* fix: fix linting

* fix: fix some failing tests

* chore: Remove unused function

* test: test updates

* fix: address comments

* chore: add missed file

* chore: add comment about static interval

* feat: address Evan's comment to require Equal method on cached results

* chore: add missed file

* feat: more efficient equality

* refactor: address Evan's comment

* refactor: address Tim's comment

* fix: undo accidental commit

* fix: make linter happy

* fix: make linter happy
2024-10-14 20:54:36 +00:00
Evan Baker dbdb22d901
chore: upgrade go toolchain to 1.23 (#3022)
* chore: update to go1.23

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>

* set bpf-prog back to debian base image

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>

---------

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
2024-10-09 19:09:07 -05:00
Evan Baker f7f98d4fcb
chore: improve IPAM logging (#3049)
Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
2024-10-07 17:48:22 +00:00
Evan Baker 7938db8460
fix: add max reconcile delay interval to IPAM monitor (#3051)
add max reconcile delay interval to IPAM monitor

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
2024-10-04 23:17:44 +00:00
Jackie Luc 09f7f72d75
fix: missing logs in log file (#3028)
* fix: missing logs in log file

* fix: use logger instead of log
2024-10-02 19:21:22 +00:00
Evan Baker 1edb63f0b0
fix: make ipamv2 metrics resilient to missing custom resource definitions (#3029)
Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
2024-10-01 20:47:51 +00:00
Jackie Luc 88908aefa8
fix: HTTPRemoteRestService config missing Direct ChannelMode (#3025)
* fix: HTTPRemoteRestService config missing Direct ChannelMode

* refactor: fix lint on rewriting if-else to switch statement

* refactor: simplify copy channel mode from cnsconfig

* refactor: use safe type assertion to prevent potential panics

Co-authored-by: Timothy J. Raymond <timraymond@users.noreply.github.com>
Signed-off-by: Jackie Luc <15662837+jackieluc@users.noreply.github.com>

---------

Signed-off-by: Jackie Luc <15662837+jackieluc@users.noreply.github.com>
Co-authored-by: Timothy J. Raymond <timraymond@users.noreply.github.com>
2024-09-24 21:50:02 +00:00
Kshitija Murudi bee72ee95f
Default to accelnet behavior in CNI for SwiftV2 windows (#3020)
* modify accelnet path in cni

* remove all occurences of accelnetnic type since not sent by cns middleware

* remove all accelnet specific UTs

* remove additional UTs referring to accelnet in invoker_cns & network_test

* fix: additional UTs in endpoint_windows
invoker_mock - removed accelnet flags
2024-09-24 16:36:36 +00:00
Behzad Mirkhanzadeh a9fccfa044
fix: Handle async delete in stateless cni (#2967)
* feat: adding stateless CNI pipeline test

* feat: making change for stateless CNI pipeline

* feat: addressing the comments

* fix: fixing stateles cni yaml

* fix: stateless CNI delete fix

* fix: addressing the comments

* fix: addressing the comments and fix linter issues

* Update cns/fsnotify/fsnotify.go

Co-authored-by: tamilmani1989 <tamanoha@microsoft.com>
Signed-off-by: Behzad Mirkhanzadeh <b.mirkhanzadeh@gmail.com>

* Update cni/network/network.go

Co-authored-by: tamilmani1989 <tamanoha@microsoft.com>
Signed-off-by: Behzad Mirkhanzadeh <b.mirkhanzadeh@gmail.com>

* Update cni/network/network.go

Co-authored-by: tamilmani1989 <tamanoha@microsoft.com>
Signed-off-by: Behzad Mirkhanzadeh <b.mirkhanzadeh@gmail.com>

* fix: addressing the comments

* fix: fix the error code.

* Fix: decoupling hnsclient form CNS watcher

* fix: adding endpointmanager package to resolve platfrom specific call to HNS

* Update cns/endpointmanager/endpointmanager_linux.go

Co-authored-by: Evan Baker <rbtr@users.noreply.github.com>
Signed-off-by: Behzad Mirkhanzadeh <b.mirkhanzadeh@gmail.com>

* Update cns/service/main.go

Co-authored-by: Evan Baker <rbtr@users.noreply.github.com>
Signed-off-by: Behzad Mirkhanzadeh <b.mirkhanzadeh@gmail.com>

* Fix: addressing the comments

* fix: removing stateless CNI pipline changes form the PR

* Update cns/configuration/configuration.go

Co-authored-by: Evan Baker <rbtr@users.noreply.github.com>
Signed-off-by: Behzad Mirkhanzadeh <b.mirkhanzadeh@gmail.com>

* addressing the comment

---------

Signed-off-by: Behzad Mirkhanzadeh <b.mirkhanzadeh@gmail.com>
Co-authored-by: tamilmani1989 <tamanoha@microsoft.com>
Co-authored-by: Evan Baker <rbtr@users.noreply.github.com>
2024-09-21 16:09:30 +00:00
Santhosh Prabhu e6c2e2adf4
Add support in CNS NMAgent Client to fetch secondary IPs (#3017)
* feat(CNS): Changes for fetching secondary IPs from NMAgent in CNS

* test(CNS): Add UT for case where no fetch happens

* style: Cleanup some comments, address some linting issues

* style: address some linting issues

* style:Run gofumpt

* test: Update test

* refactor: Address comments to move business logic out of nmagent client

* chore: Add missed files

* style: Better naming, comments

* style: Better naming

* style: Better naming, comments

* chore: undo accidental edit

* style: comments

* style: naming

* style: linting issues

* feat: Address comments. Add MacAddress and IPAddress as types, refactor ip_fetcher code

* style: linting issues

* style: linting issues

* chore: remove accidental edits

* style: lower case in error messages

* chore: add missed file

* style: Rename MACAddress

* style: Address comments

* refactor: Address comments

* chore: ip_fetcher changes
2024-09-19 03:22:34 +00:00
Saksham Mittal ed2b57a0df
Add join VNET call for every AZR NC unpublish call with fixed UTs (#3016)
* add join vnet call for every AZR nc unpublish call

* add join vnet call for every AZR nc unpublish call

* modify comment with explanation

* declare vnet variable

* linter fix

* address comments
2024-09-16 00:37:47 +00:00
Saksham Mittal ce617a7589
Revert "Add join VNET call for every AZR NC unpublish call" (#3008)
Revert "Add join VNET call for every AZR NC unpublish call (#2983)"

This reverts commit b7ce09fd49.
2024-09-12 04:19:07 +00:00
Evan Baker ff46b57144
fix: add legacy IPAM metrics back to IPAMv2 (#2970)
Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
2024-09-04 16:01:25 +00:00
Saksham Mittal b7ce09fd49
Add join VNET call for every AZR NC unpublish call (#2983)
* add join vnet call for every AZR nc unpublish call

* add missing return

* linter fix

* add comment
2024-09-03 23:16:49 +00:00
Paul Yu 96711bc8ed
fix: Ignore accelnetEnable flag to disable swiftv2 Linux&&Windows for AccelentNIC (#2976)
* ignore accelnetEnable flag to fix swiftv2 Linux

* fix the comment

* remove accelnetEnable flag
2024-08-30 00:09:54 +00:00
Matthew Long a01f0a0192
feat: add device plugin support to CNS (#2886)
* feat: add device plugin support to CNS

* Add UT coverage and linter fixes

* fix windows-latest lint issues

* Update cns/deviceplugin/pluginmanager.go

Co-authored-by: Timothy J. Raymond <timraymond@users.noreply.github.com>
Signed-off-by: aggarwal0009 <127549148+aggarwal0009@users.noreply.github.com>

* remove test run output file

* linter fixes

* resolve readability related comments

* move nolint annotations inline

* remove unnecessary nolint

* update UT

* deleted gitignore for test file

* fix goroutine eak

* pr feedback cleanup

* move devicePrefix to a constant

* pr refactoring

* refactored to make PluginManager generic

* Update trackDevice to return nil

* Add documentation

* fix shutdownCh initialization in server.go

* Fix UTs

* fix merge conflict errors

---------

Signed-off-by: aggarwal0009 <127549148+aggarwal0009@users.noreply.github.com>
Co-authored-by: aggarwal0009 <127549148+aggarwal0009@users.noreply.github.com>
Co-authored-by: Timothy J. Raymond <timraymond@users.noreply.github.com>
2024-08-29 14:35:49 +00:00
Jackie Luc 0a47e178be
[CNS] Add unit tests to Standalone SwiftV2 scenario (#2932)
* chore: update comments to include field keys

* test: refactor to pass in orchestrator type for CNS mock

* chore: add swiftv2 standalone context with NMAgent

* test: add swiftv2 standalone happy path tests

* test: add comments

* test: add validation tests

* feat!: remove middleware error response overriding to unexpected error

* test: fix missing argument to refactored getTestService
2024-08-27 19:31:36 +00:00
Alexander 3e161f00bf
chore: remove cnm code (#2906)
* remove cnm code

* remove cnm refs in docs, comments, cns args, and makefile

* remove cns ipamclient as it uses cnm

* remove cns ipam client consts
2024-08-24 02:45:06 +00:00
Evan Baker 4902139f48
chore: move cns from servercore to nanoserver (#2454)
feat: migrate CNS Windows to nanoserver and pin all SHAs

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
2024-08-19 16:14:26 +00:00
QxBytes fc4da42d66
refactor: create safer command execution method (#2899)
* rename ExecuteCommand to ExecuteRawCommand

* add safer execute command method

* fix windows platform command test

* add uts and comments

* address feedback

* add parent context to execute command
2024-08-06 21:36:55 +00:00
sivakami-projects b70d041de2
feat: Create win 2025 images for CNI and CNS using windows servercore insider tags. (#2878)
Squashed commit of all changes for win-ltsc2025
2024-08-02 23:57:50 +00:00
Kshitija Murudi 6e3d2ff6f5
fetch primary mac for hns accelnet (#2857)
* fetch primary mac for hns accelnet

* downgrade winio module

* revert winio to 0.6.2

* remove replace winio old version & separate hns call into windows-only file

* fix lint errors

* rename files

* go fmt locally

* add build tags

* moving method to platform package

* refactor files to restserver
fix fmt issues, linter

* minor comment edit

* undo azure-ipam go.mod, edit minor comments

* add log line & format better main.go

* address review comments, change ctx todo

* undo temp pipeline changes

* fix: gofumpt the file linter error
2024-07-31 01:36:38 +00:00
Jaeryn 9d83ac3a37
chore: add enable k8s device plugin to cns config (#2869)
* chore: add enable k8s device plugin to cns config

* regroup EnableK8sDevicePlugin flag with other enable bools

---------

Co-authored-by: Jaeryn <tsch@microsoft.com>
2024-07-24 14:48:50 +00:00
QxBytes a33e3574bc
test: validate inputs to acn components (#2845)
* add validation for cni args and cns request values

* address feedback

* simplify regex match
2024-07-19 15:59:41 +00:00
msvik 6c50d0dcdd
feat: Add CNS API to retrieve VMUniqueID from IMDS (#2842)
* Add CNS API to retrieve VMUniqueID from IMDS

* Address the PR review comments

* Address the security comment from Evans to expose this API wherever needed

* fixed the linter error

* address the PR comments from Matt

* lowercase the struct json fields
2024-07-18 21:32:02 +00:00
Kshitija Murudi b9b8627220
Add swiftv2 middleware support for standalone service fabric scenario (windows) (#2634)
* feature: add sfswiftv2 middleware support for standalone service fabric swiftv2 windows path

* feat: add switch case for middlewaretype

* review: address comments

* pkg: move swiftv2mode for cnsconfig from configuration to cns package to avoid import-cycle

* address review comment

* linter: context check, wrap error

* linter: fix errors wrap return static err

* review: address comments:

* refactor: keep old variable enableswiftv2, initialization pattern

* address pr comments

* rename the middleware to standaloneswiftv2middleware

* remove HostSecondaryIPInfo from podIpInfo

* address review comments-1

* address review comments-2

* Update cns/service/main.go

Co-authored-by: tamilmani1989 <tamanoha@microsoft.com>
Signed-off-by: Kshitija Murudi <kmurudi@microsoft.com>

* fix an linter issue

* rename the IPConfigRequest func

* fix a comment linter issue

* fix a comment linter issue

* remove checking hnsTransparent network mdoe

* remove orchestrator checker

---------

Signed-off-by: Kshitija Murudi <kmurudi@microsoft.com>
Co-authored-by: tamilmani1989 <tamanoha@microsoft.com>
Co-authored-by: Paul Yu <129891899+paulyufan2@users.noreply.github.com>
Co-authored-by: paulyufan2 <paulyu01@outlook.com>
2024-07-10 00:07:14 +00:00
Kshitija Murudi e3b25da9d2
add prefix length from mtpnc to podipinfo & gatewayip (#2828)
* add prefix length from mtpnc to podipinfo & gatewayip

* separate getIpConfig based on OS for HNS prefix changes, add subnet in UTs

* import packages

* refactor middleware into os files after rebase w/ master

* split only the subnet-prefix assign part

* fix lint errors

* add UTs to test the function's behavior for linux vs windows

---------

Signed-off-by: Kshitija Murudi <kmurudi@microsoft.com>
Co-authored-by: paulyufan2 <paulyu01@outlook.com>
2024-07-09 22:05:42 +00:00
shreyashastantram 313ce0c4b0
feat: Adding backend interfaces support to CNS (#2693)
* Adding backend interfaces support for CNS

* Fixing the log line

* Moving backend nic functions to platform package

* Moving the pnpID fetching to platform package

* Moving the mapping to CRD mode

* Moving macaddress parsing to net package function

* removing the backend nic config

* Handling multiple interface information

* Adding error handling for macaddress parsing

* Moving pnpid mapping to swift v2  flow

* Adding pipeline vars

* Adding ut's for Happy paths

* Adding ut's for Happy paths

* Adding mtpnc check

* Rebasing with master

* Addressing lint errors

* Adding function to linux file

* Addressing lint errors

* Addressing lint comments

* Addressing Lint issues

* Modifying ut's

* removing mutex lock on cache

* Adding podnetwork instance label

* Modifying ut's after change

* Moving function out of restserver

* Moving mapping after crd intial state

* Adding the config debug statements

* removing the unused config

* Adding the debug statements

* Adding the debug statements

* Adding more debug logs

* removing log lines and adding mtpnc status check

* Moving mapping to state file

* Rebasing and removing the debug statements

* Addressing lint errors

* removing the debug pipeline changes

* Adding more coverage

* Adding test coverage and unhappy paths

* Addressing lint errors

* addressing lint errors

* Addressing lint errors
2024-07-05 23:11:00 +00:00
Paul Yu 626b05a092
add gateway on CNS to get populated (#2805)
* add primaryip and gateway on CNS

* add windows 2025 build

* remove windows 2025 build from PR
2024-06-28 14:41:35 +00:00
bohuini a6364a5de7
fix: Revert the naming change for DelegatedVMNIC on master (#2810)
Revert "fix: Modified the value of DelegatedVMNIC to resolve compatibility issue (#2801)"

This reverts commit df978d5d89.
2024-06-27 02:08:19 +00:00
bohuini df978d5d89
fix: Modified the value of DelegatedVMNIC to resolve compatibility issue (#2801)
Modified the value of const DelegatedVMNIC
2024-06-21 23:02:11 +00:00
Paul Yu 42ea498d71
build windows 2025 binaries (#2804)
* build windows 2025 binaries

* do not build images on CI/CD

* add a comment
2024-06-21 21:03:35 +00:00
Evan Baker 44fa6a0660
fix: CNS should ignore NNCs that are being deleted (#2798)
Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
2024-06-21 19:18:38 +00:00
Paul Yu 2b2d5904f3
Add default routes k8s windows (#2797)
* Add default routes k8s windows

* add os version flags 2025

* remove unnecessary line

* fix windows 2025 build version

* remove windows 2025 build from this PR

* Update cns/middlewares/k8sSwiftV2_windows.go

Co-authored-by: John Payne <89417863+jpayne3506@users.noreply.github.com>
Signed-off-by: Paul Yu <129891899+paulyufan2@users.noreply.github.com>

* fix a comment linter issue

* fix the feedback to organize log

---------

Signed-off-by: Paul Yu <129891899+paulyufan2@users.noreply.github.com>
Co-authored-by: Kshitija Murudi <kmurudi@microsoft.com>
Co-authored-by: John Payne <89417863+jpayne3506@users.noreply.github.com>
2024-06-21 02:34:04 +00:00
Evan Baker 994ba651b9
combine linux and win Dockerfiles using build targets (#2559)
Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
2024-06-17 21:53:44 +00:00
Kevin Camacho bebbe63560
Added gRPC Server Boilerplate Code for CNS (#2745)
* PB Operations

* Added gRPC Boilerplate Code

* Updated package

* Minor Fixes

* gRPC Boilerplate

* Minor Changes

* Feedback PB Changes

* Ignored dotnet

* Improved Logging

* PB Operations with Gen Code

* Cherry Picking PB Operations

* SetOrchestratorInfo Implementation

* gRPC Boilerplate Server Startup

* FIxed Merge Conflicts

* Resolved Merge Conflicts

* Removed gitignore

* Add gRPC Protobuf Files for CNS Operations (#2754)

* PB Operations

* Updated Protobuf Service Name

* Package Rename

---------

Co-authored-by: Kevin <t-kcamacho@microsoft.com>

* refactor: code changes for stateless cni and swift v2 (#2688)

* ci: changes up to endpointInternal

* ci: remove defaultInterface from invoker

* ci: change up to CreateEndpoint

* ci: changes up to CreateEndpoint()

* ci: invoker cns and UT fixes

* ci: add fixes to UT(s), capture non populated defaultInterface failures

* ci: multitenancy changes

* ci: invoker azure changes & remove all defaultInterfaceInfo possible

* ci add NICType to baremetal flow

* chore: address comments

* merge nw info fields to ep info and draft new createEndpoint function

* restruct ipamAddResult struct

* reorder code to create epinfo first, and then create network and ep based on epinfo

* add getNwInfo and generate ipamAddResult

* fix network windows.go

* create nw info first and create nw and ep dns info

* fix testIpamAddFail ut referencing wrong redeclared err variable, fix error message

* UT fix part one

* fix the getNetworkID and getNetworkInfo

* move create endpoint to network package, remove ifIndex as needed

* use function to get network id

* unify creation of nw and endpoint info by removing switch

* change functions to consume ep info instead of nw info

* remove unused variable accidentally added earlier

* update old azure ipam invoker to use ep info and change ids to network ids when appropriate

previously we renamed the NetworkInfo symbol to EndpointInfo in lots of places, but the Id in Network Info is NOT the same as Endpoint Info, so while the code compiles, code that previously used the id field of the network info struct would now be using the id field of the endpoint info struct. It should use the NetworkId field of the endpoint info struct instead.

* rename endpoint info id field to EndpointID to remove ambiguity

* change nw info to ep info in windows

* adjust comments

* move all methods in create ep info dependent on nw info to use ep info instead (windows and linux)

addSubnetToNetworkInfo, setNetworkOptions, and getEndpointPolicies. getEndpointPolicies will now take just the subnets needed as a parameter rather than the whole nw or ep info.

* make cnm compile (not necessarily correct)

* make all tests compile except endpoint test secondary client (windows and linux) (not necessarily correct)

* comment out endpoint test secondary endpoint client case to make tests compile

* address todos and comments from meeting

* remove duplicated code for populating address in ep info generation

* update EndpointCreate to support multiple infra nic

* save all endpoints to state, regardless of type, use either stateless or cni statefile

undos some changes in "move create endpoint to network package, remove ifIndex as needed"
deletion flow needs to figure out how to tell if the nic type is delegated
1 interface info : 1 endpoint info : 1 endpoint struct mapping

* fix dual nic support conditional and finding master interface ip

the master interface ip must be in a particular form where the last few bits are zeroed out based on the mask or we won't find the ip
for example, while the host subnet perfix is 10.224.0.113/16, the ip that should be passed into find master interface (subnet) should be 10.224.0.0/16 which matches one of the interfaces' ipnet (10.224.0.0/16)

* fix empty network name
when we need to create a network, we collect the network information, but if we do not find the network, we return an empty nw info and an error
when we create the endpoint we need to use endpoint info's network id, not the (possibly) empty network info struct's network id

* make network_test.go compile (linux and windows compile)

unit tests are not necessarily correct at this point

* add NICType to endpoint struct and populate it

important: when getting the endpoint state, the NIC Type field is not populated, leading to deletes not having a NIC Type; this should be changed so that getting the state populates that field
including the nic type allows us to simplify the secondary endpoints delete flow (just check if the nic type is delegated instead of checking if the secondary interfaces map is populated)

smoke tested:
linux aks podsubnet (same vm, multi vm, internet, cni statefile consistent)
linux standalone transparent vlan multitenancy (same vm, multi vm, internet, multi vnet, no connection between coke pepsi, cni statefile consistent)
windows standalone bridge multitenancy single customer (same vm connections, internet, dns only, cni statefile consistent, 2 pods deleting and recreating)

* ci: InterfaceInfo Map

* fix multitenancy_test ut by changing key

* add endpoint id to secondary ep info test since we populate the id in the actual flow

* fix cni network_test linux and ensure secondary create ep info does not break

in network_test we pass in sample delegated (secondary) data to Add which we then create endpoint info from
even with most fields empty, in linux, the ep info is created without erroring

* make invoker_cns_test linux pass

running all linux package tests for network and cni package pass (or also fail on master, like createBridge)
windows unit tests mostly all fail for the same ones on master and this branch
summary:
	- network_windows_test.go
		○ TestFailToAddIPv6DefaultRoute already fails on master
	- network_test.go
		○ 9 tests fail on master, 9 tests fail on my branch
	- manager_test.go
		○ 9 tests fail on master, 9 tests fail on my branch
	- endpoint_windows_test.go
		○ TestNewAndDeleteEndpointImplHnsV2 already timeouts on master
	- endpoint_test.go
		○ 9 tests fail on  master, 9 tests fail on my branch
	- network_windows_test.go
		○ FAIL: TestPluginSecondAddSamePodWindows/CNI_consecutive_add_already_hot_attached
		○ FAIL: TestPluginSecondAddSamePodWindows/CNI_consecutive_add_not_hot_attached
		○ We don't handle consecutive add anymore
	- network_test.go
		○ TestPluginMultitenancyAdd/Add_Happy_path fails on master and my branch (received multiple NC results [] from CNS while dualnic feature is not supported)-- we still get two items on our list/map though which is expected
	- invoker_cns_test passes
	- invoker_azure_test passes
        - multitenancy_test passes
The consecutive add tests fail but that is expected since we no longer support it.

* modify delete flow to handle multiple epinfos to delete

delete ALL endpoints related to the endpoint infos list in the event cni fails half-way through an add (one failed endpoint create and we delete all would-be-create endpoints and the state)
replace looping over deletion code "n" number of times with getting a slice of endpoint infos to delete
modify stateless cni code to retrieve a slice of network endpoint infos from a single response based on the container id (container id can be used in stateless cni for retrieval)
incorporate stateless cni changes from other branch (cns client/ipam/restserver changes)
modify get endpoint state to return slice of endpoint infos, and getting an endpoint will return an endpoint from that slice with nic type infra
move edge case where endpoint is not created in the state but ips are already allocated to immediately after retrieving all ep infos
fix mock behavior for getting all endpoints by container id
move getting network id and network info out of the loop because their values do not seem to change between iterations
move deletion of endpoint logic into a dedicated loop, and then create a dedicate loop for calling ipam delete to prevent inconsistent state

all expected unit tests on linux pass

* address feedback

* Make change to UpdateEndpointState API to support SwiftV2 for Stateless CNI

* change save state to only call update endpoint state once with a slice of endpoints, uts pass

* fix using nonexistent key by passing in current interface info directly

* fix azure ipam invoker not getting a populated network info for legacy cni

* add L1VH windows support

* add nic type to windows endpoints

* move adding an external interface code to run only when creating a new network

this change reflects prior behavior, where we would only add an external interface to the statefile if the network (after searching through all external interfaces) was not found
currently, if there are multiple interfaces that could be selected as the master, we would add each external interface to the statefile, even if the *network* is associated with one of the existing interfaces
while we would still always find the same network (thanks to having a constant NetworkId, regardless of the external interface), you could get an extra empty external interface in your statefile
this commit should remove that possibility (the extra external interface shouldn't really matter in the first place though because we always select the external interface that has a matching network created on it)
this should be os agnostic

* update comments, first todo check pass

* address some linter issues

* rename networkId to networkID in endpoint info

ran package tests in windows and linux for cni and network packages
ran package tests in linux for cns restserver
all have expected outputs (either pass, or also fails on master branch)

* address linter issues

* preserve more logs and reduce timeout for restart for debugging

* clean comments and rename for clarity

if we use the endpoint info for the network info fields, we name it nwInfo as a hint

* address more linter issues

linux network, restserver, and cni package tests pass

* Revert "preserve more logs and reduce timeout for restart for debugging"

This reverts commit 0f004925cf.

* ignore error on delete flow network query

if we are in stateful cni and do not find the network, we will not error, but when we search for the endpoint it will not be found, leading to us calling ipam invoker delete which is assumed idempotent before returning
previously we would error in stateful cni and return before calling ipam invoker delete

* delete network on endpoint delete if stateless and delegated vmnic (win + linux)

* add nic name, set nicname in linux to master interface name

stateless will key into interface map with the nicname field
in windows, the nicname field is based on the args ifname (usually eth0)
in linux, the nicname field is based on the master interface found (usually eth0)

note:
hostifname/hostvethname = linux veth pair peer in the host ns
ifname/contifname = linux veth pair peer in the container ns, in windows it's just the args ifname
nicname is something else
ifname isn't used during deletion in linux, hns id is used for deletion in windows

* return secondary interface as cni result if no infra nic found, include mac address in cni result

* address linter issue

* fix critical error where failing to add in windows stateless would lead to hns components not being deleted and add netns for hnsv2

tested by triggering a failure to save the stateless state and seeing that the hns endpoint and network are cleaned up
we use the endpoint info to clean up on "add" error, but previously, we didn't populate it with the hns ids to do so

adds netns to stateless as the presence of a valid guid in netns determines if hnsv2 is used

* set nicname used in stateless cni according to feedback

* add dummy guid to stateless delete since we assume stateless is always hnsv2

we assume that the netns value isn't used in stateless deletion

* clean up createEpInfo, declare endpoint info once

* address feedback from vipul

* change comments only

* revert change to cns package

* fix stateless cni migration flow not having nictype on migrate

* keep nwInfo variables named the same as before pr (noop)

* separate endpoint and network policies in endpoint info

behavior should not change except in hnsv1, where network policies passed into network create call will NOT include endpoint policies
endpoint policies always include network policies

* address feedback from reviewers

* address feedback and account for case where cns provides info without nic type

if nic type is empty from cns in invoker cns, we assume it is infra nic type and populate it with infra nic type

* address feedback to declare endpoint info once and populate all fields at once

moved add subnets to after endpoint info created
moved retrieval of all endpoint policies (from getEndpointPolicies and getPoliciesFromRuntimeCfg)until after endpoint info created
network policies are just passed in from the args unaltered

* use ifname instead of nicname field in endpoint struct as key in stateless

* convert macaddress only nictype is delegatedvmnic

* address feedback by removing network dns settings

* address linter issues (noop)

* address feedback and linter (noop)

* remove unused consecutive add funcs (noop)

* fix release ips when create a container without nictype using older cni and then upgrade cni and delete

if we create a pod with an older cni version, it won't have a nictype
if we upgrade cni and then delete, we should treat an empty nictype as an infra nictype and
call the invoker delete

* prevent eps with delegated nic type present on ep from also calling transparent endpoint client on delete

tested on swift v2 linux single pod add, change cni to this version, delete (ok)
then add using this cni version and delete, no extraneous transparent endpoint client calls logged

* mock get interface method for ut

searched for "NetPlugin" in all files and determined all prod use of NetPlugin goes through NewNetPlugin where we set the get interface method to the real interface get method
adds ut where the master interface (by mac) is not found

* address feedback (noop)

* add ut for handling empty nictype on cns add (noop)

* add multitenancy delete net not found ut (noop)

* add uts for multi interface infos single add call, verify endpoint id, cns to cni data conversion and vice versa, get endpoint info from container id (noop)

verifies partial success will delete all endpoints, even successfully created ones in the same cni add call

* add ut for all pods associated with container id delete in one del call, new secondary delete flow (noop)

* add two UTs

* fix a linter issue

* add ut to check endpoint ifname on new endpoint creation based on nictype (noop)

* add ut for fail to find interface by subnet (noop)

* Adding support for Stateless CNI Delete Edge case when there in no HNS ID

* fix uts

* fix linter issues

* fix ut

---------

Co-authored-by: jpayne3506 <payne.3506@gmail.com>
Co-authored-by: paulyufan2 <paulyu01@outlook.com>
Co-authored-by: AzureAhai <behzadm@microsoft.com>

* Corrected imports

* Final Commit

* Updated .gitignore

* Added dummy methods for PB operatons

* Modularized CNS

* Improved configurations

* Resolved Concflicts

* Resolved cns logic error

* Improved config structure

* Resolved Conflicts

* Updated Main

* Removed Config

* WIP: 34307edf Fixed return code

---------

Co-authored-by: Kevin <t-kcamacho@microsoft.com>
Co-authored-by: QxBytes <39818795+QxBytes@users.noreply.github.com>
Co-authored-by: jpayne3506 <payne.3506@gmail.com>
Co-authored-by: paulyufan2 <paulyu01@outlook.com>
Co-authored-by: AzureAhai <behzadm@microsoft.com>
2024-06-14 17:43:47 +00:00