Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: SWIFT v2 Middlewares #2390

Merged
merged 14 commits into from
Jan 19, 2024
Merged

refactor: SWIFT v2 Middlewares #2390

merged 14 commits into from
Jan 19, 2024

Conversation

nddq
Copy link
Contributor

@nddq nddq commented Nov 15, 2023

Reason for Change:

Currently, our SWIFT v2's middleware for handling IP configs request is not implemented as a "true middleware" but rather, being another branch of code that would be invoke within the default IP configs request handler if CNS is running in SWIFT v2 scenario. This PR aims to refractor our current implementation so that the default handler would be wrapped by the middleware function instead, so there would be no branching within the default handler functions. This is not a blocking requirement for ongoing SWIFT v2 testing.

Issue Fixed:

Requirements:

Notes:

@nddq nddq added cns Related to CNS. swift-v2 labels Nov 15, 2023
@nddq nddq requested a review from rbtr November 15, 2023 17:29
@nddq nddq self-assigned this Nov 15, 2023
cns/api.go Outdated
@@ -51,15 +51,13 @@ type HTTPService interface {
AttachSWIFTv2Middleware(middleware SWIFTv2Middleware)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to AttachMiddleware and pass Middleware interface?

@rbtr rbtr changed the title refractor: SWIFT v2 Middlewares refactor: SWIFT v2 Middlewares Nov 15, 2023
@nddq nddq force-pushed the feat/middlewares branch 3 times, most recently from 2c89aa1 to bb52bed Compare November 16, 2023 21:49
@nddq nddq marked this pull request as ready for review November 17, 2023 00:16
@nddq nddq requested a review from a team as a code owner November 17, 2023 00:16
@nddq nddq force-pushed the feat/middlewares branch 3 times, most recently from 80dfa6b to 40a8390 Compare November 21, 2023 06:18
}, errors.New("failed to validate ip configs request")
}
// If the pod is not v2, return the response from the handler
if !req.SecondaryInterfacesExist {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: since we're calling defaultHandler anyway - we can move line 53 above the if statement, and just return ipConfigsResp,err on line 50

rbtr
rbtr previously approved these changes Dec 1, 2023
Copy link
Contributor

@rbtr rbtr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with suggestions

cns/restserver/ipam_test.go Outdated Show resolved Hide resolved
@nddq nddq force-pushed the feat/middlewares branch 2 times, most recently from 6e7cb94 to 2284957 Compare December 11, 2023 15:21
@nddq nddq requested review from rbtr and miguelgoms December 11, 2023 15:31
rbtr
rbtr previously approved these changes Dec 11, 2023
@nddq nddq force-pushed the feat/middlewares branch from f949c48 to 249dd99 Compare January 16, 2024 22:07
rbtr
rbtr previously approved these changes Jan 16, 2024
kmurudi
kmurudi previously approved these changes Jan 16, 2024
Copy link
Contributor

@kmurudi kmurudi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm as per refactoring/renaming middleware & funcs, to be tested in standalone to verify changes

@nddq nddq dismissed stale reviews from kmurudi and rbtr via db323f8 January 17, 2024 17:08
@nddq nddq requested review from kmurudi and rbtr January 18, 2024 14:17
miguelgoms
miguelgoms previously approved these changes Jan 18, 2024
@nddq nddq added this pull request to the merge queue Jan 18, 2024
Merged via the queue into master with commit 25996f7 Jan 19, 2024
14 checks passed
@nddq nddq deleted the feat/middlewares branch January 19, 2024 00:31
alam-tahmid pushed a commit that referenced this pull request Jan 26, 2024
* refractor: swift v2 middleware

* revert: unexport getTestService

* fix: linter

* fix: linter issue

* refactor: generic renaming of middlewares-related code in cns

* refactor: change type of swiftv2middleware

* address feedbacks

* rename for clarity

* missed some renaming

* renaming

* addressed comments

* add UT for no-op releasing ip config for v2 pod even if its mtpnc is not ready

* pass in SWIFTv2Mode as string

* typed SWIFTV2Mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cns Related to CNS. swift-v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants