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

move unnecessary init process after startWorkers #3124

Merged
merged 1 commit into from
Aug 9, 2023
Merged

Conversation

hongzhen-ma
Copy link
Collaborator

@hongzhen-ma hongzhen-ma commented Aug 8, 2023

What type of this PR

  • Improvement

Which issue(s) this PR fixes:

Fixes #(issue-number)

WHAT

🤖 Generated by Copilot at 96dc92c

Refactor controller Run function, simplify logical switch port garbage collection, and enhance code readability in init.go.

🤖 Generated by Copilot at 96dc92c

Sing, O Muse, of the mighty controller, who rules the network
With swift and skillful logic, and refines his code with care.
He splits his Run function, and entrusts the resource init
To a helper, who performs it once, and guards it with a sync.

HOW

🤖 Generated by Copilot at 96dc92c

  • Refactor the Run function of the controller to separate the initialization of resources that affect the controller process from those that do not (link, link, link, link, link, link)
  • Move the initialization of node chassis, security groups, load balancers, vpc nat gateways, and vpc dns configs to a new function initResourceOnce in controller.go (link, link, link, link)
  • Call initResourceOnce after the workers start, using a sync.Once variable to ensure it is only executed once (link, link)
  • Add a comment to explain the rationale of the refactoring (link)
  • Simplify the garbage collection of unused resources in the ovn database by removing the logical switch port gc from the gc function in gc.go (link, link)
    • Delete the unused gcLogicalSwitchPort function from gc.go (link)
    • Rely on the existing markAndCleanLSP function, which is called periodically by a ticker, to handle the logical switch port gc (link)
  • Add empty lines to init.go for formatting purposes (link, link)

@hongzhen-ma hongzhen-ma merged commit 294e5f9 into master Aug 9, 2023
58 checks passed
@hongzhen-ma hongzhen-ma deleted the init branch August 9, 2023 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants