Skip to content

Conversation

rbtr
Copy link
Collaborator

@rbtr rbtr commented Mar 1, 2025

no code changes, only rearranging.
starting to break up the huge spaghetti that is main

@Copilot Copilot AI review requested due to automatic review settings March 1, 2025 00:18
@rbtr rbtr requested a review from a team as a code owner March 1, 2025 00:18
@rbtr rbtr requested a review from csfmomo March 1, 2025 00:18
@rbtr rbtr enabled auto-merge March 1, 2025 00:18
@rbtr
Copy link
Collaborator Author

rbtr commented Mar 1, 2025

/azp run Azure Container Networking PR

@rbtr rbtr self-assigned this Mar 1, 2025
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rbtr rbtr added the cns Related to CNS. label Mar 1, 2025
@rbtr rbtr requested review from pjohnst5, QxBytes and jpayne3506 March 1, 2025 00:20
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR is a chore aimed at starting the process of breaking up the large CNS main file into smaller, more manageable components.

  • Introduces a new file for version information in cns/service/version.go
  • Sets up a helper function to print application version details

Reviewed Changes

File Description
cns/service/version.go Adds a helper for printing version details

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

cns/service/version.go:1

  • [nitpick] The file is located in the 'cns/service' directory but declares 'package main'. Consider renaming it (e.g., to 'service') to align with its directory context.
package main

@rbtr rbtr requested a review from nddq March 1, 2025 00:40
Copy link
Member

@nddq nddq left a comment

Choose a reason for hiding this comment

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

afaik there is no code changes, right? also I was wondering if moving main out of cns/service would be an option down the line 🤔

@rbtr
Copy link
Collaborator Author

rbtr commented Mar 3, 2025

afaik there is no code changes, right?

No code changes, only copy/pasting.

also I was wondering if moving main out of cns/service would be an option down the line 🤔

eventually - I'm aiming for cobra. But it's very far down the line.

@rbtr rbtr requested a review from paulyufan2 March 7, 2025 20:07
Copy link

This pull request is stale because it has been open for 2 weeks with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the stale Stale due to inactivity. label Mar 22, 2025
@rbtr rbtr removed the stale Stale due to inactivity. label Mar 25, 2025
Copy link

github-actions bot commented Apr 9, 2025

This pull request is stale because it has been open for 2 weeks with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the stale Stale due to inactivity. label Apr 9, 2025
@rbtr rbtr removed the stale Stale due to inactivity. label Apr 10, 2025
@rbtr
Copy link
Collaborator Author

rbtr commented Apr 10, 2025

/azp run Azure Container Networking PR

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link

This pull request is stale because it has been open for 2 weeks with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the stale Stale due to inactivity. label Apr 25, 2025
@rbtr rbtr removed the stale Stale due to inactivity. label Apr 30, 2025
Copy link

This pull request is stale because it has been open for 2 weeks with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the stale Stale due to inactivity. label May 16, 2025
Copy link

Pull request closed due to inactivity.

@github-actions github-actions bot closed this May 23, 2025
auto-merge was automatically disabled May 23, 2025 00:01

Pull request was closed

@github-actions github-actions bot deleted the chore/refactor-cns-main branch May 23, 2025 00:01
@rbtr rbtr removed the stale Stale due to inactivity. label May 29, 2025
@rbtr rbtr restored the chore/refactor-cns-main branch May 29, 2025 22:57
@rbtr rbtr reopened this May 29, 2025
Copy link

This pull request is stale because it has been open for 2 weeks with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the stale Stale due to inactivity. label Jun 13, 2025
@rbtr rbtr added exempt-stale Keep this fresh and removed stale Stale due to inactivity. labels Jun 13, 2025
Copy link
Contributor

@pjohnst5 pjohnst5 left a comment

Choose a reason for hiding this comment

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

Yeah I think once these are also moved then we are good to go:
aks.go

  • func InitializeMultiTenantController()
  • func pollNodeInfoCRDAndUpdatePlugin()

managed.go ?

  • type NodeInterrogator
  • func registerNode()
  • func sendRegisterNodeRequest()
  • These are only used if cns is Managed channel mode

cns/restserver/nodesubnet.go
func getPodInfoByIPProvider() could go here, because there's another function func InitalizeNodeSubnet() that is already there, and is only called when channel mode is AzureHost
This actually results in a cycle

And then this one is probably a stretch, should we make an args.go for the var args = acn.ArgumentList{..}?

Super nice to be doing this! Thanks Evan!


// Prints description and version information.
func printVersion() {
fmt.Printf("Azure Container Network Service\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm just wondering if up above, it makes sense also to tear out var args = acn.ArgumentList{..} and also put it into a file like args.go or something

// Prints description and version information.
func printVersion() {
fmt.Printf("Azure Container Network Service\n")
fmt.Printf("Version %v\n", version)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should also take out type NodeInterrogator ,func registerNode() and func sendRegisterNodeRequest() and put them into a file called managed.go, or something, since they are only used if cns is in "managed" mode it seems (not sure really what that is but it could also make this file smaller)

logger.Printf("Set GlobalPodInfoScheme %v (InitializeFromCNI=%t)", cns.GlobalPodInfoScheme, cnsconfig.InitializeFromCNI)

err = InitializeCRDState(rootCtx, httpRemoteRestService, cnsconfig)
err = initializeCRDState(rootCtx, httpRemoteRestService, cnsconfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also move func InitializeMultiTenantController() into aks.go?

initialIBNICCount = 0
)

type cniConflistScenario string
Copy link
Contributor

Choose a reason for hiding this comment

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

Alright, just a few more things we may want to move out of here and into aks.go
the const:
defaultNodeInfoCRDPollInterval (maybe that doesn't really warrant a move)

The function:
func pollNodeInfoCRDAndUpdatePlugin (just the definition of the function not the function call)

@pjohnst5
Copy link
Contributor

Hi @rbtr , I took a stab at this in #4038 (since it needed a rebase) and added a few more moves
The changes you made are first, and then I added 4 more changes after that
rbtr
pjohnst5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cns Related to CNS. exempt-stale Keep this fresh
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants