Skip to content

fix(controller): add finish logs for all gc functions#6532

Merged
oilbeater merged 2 commits intomasterfrom
fix/gc-add-finish-logs
Mar 27, 2026
Merged

fix(controller): add finish logs for all gc functions#6532
oilbeater merged 2 commits intomasterfrom
fix/gc-add-finish-logs

Conversation

@oilbeater
Copy link
Collaborator

Summary

  • All gc functions only had "start to gc ..." logs without corresponding completion logs, making it hard to tell if a gc cycle completed or hung.
  • Added "finish to gc ..." logs before each successful return in all 18 gc functions.
  • Kept klog.V(4) level for markAndCleanLSP to match its existing start log level.

Test plan

  • Verify make lint passes
  • Check controller logs to confirm matched start/finish log pairs for each gc function

🤖 Generated with Claude Code

All gc functions only had "start to gc ..." logs without corresponding
completion logs, making it difficult to determine whether a gc cycle
completed successfully or hung. Add "finish to gc ..." logs before
each successful return to improve observability and debugging.

Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
Copilot AI review requested due to automatic review settings March 27, 2026 02:19
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 27, 2026
Copy link

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.

Pull request overview

This PR improves controller GC observability by adding “finish” log lines so operators can tell whether each GC function completed (vs. potentially hanging).

Changes:

  • Add finish to gc ... logs on successful completion paths across the GC functions in pkg/controller/gc.go.
  • Keep markAndCleanLSP finish log at klog.V(4) to match its existing start-log verbosity.
  • Add separate finish logging for the DHCP options portion of gcLogicalSwitch.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +819 to 821
klog.Infof("finish to gc address set")
return nil
}
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

The new finish log won’t be emitted on the successful no-op path: this function can return nil early when len(asList) == 0 (line 810-812), after printing the start log. To ensure start/finish pairs (and to match the PR’s intent), add a finish log before that early return or use a deferred finish log that only runs on success.

Copilot uses AI. Check for mistakes.
Comment on lines +864 to 866
klog.Infof("finish to gc security group residual port groups")
return nil
}
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

The finish log is only reached when there are port groups to delete; on the successful no-op path (len(needToDelPgs) == 0) the function returns nil early (line 857-859) after logging the start message. If the goal is to detect hung GC cycles via start/finish pairs, add a finish log before that early return or use a deferred finish log that only executes on success.

Copilot uses AI. Check for mistakes.
@coveralls
Copy link

coveralls commented Mar 27, 2026

Pull Request Test Coverage Report for Build 23628132626

Details

  • 0 of 22 (0.0%) changed or added relevant lines in 1 file are covered.
  • 19 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.01%) to 24.096%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/controller/gc.go 0 22 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/controller/gc.go 19 0.9%
Totals Coverage Status
Change from base Build 23588768977: -0.01%
Covered Lines: 13360
Relevant Lines: 55445

💛 - Coveralls

Address review feedback: gcAddressSet and gcSecurityGroup had early
return paths (when nothing to gc) that were missing finish logs.

Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
@oilbeater oilbeater merged commit 023250b into master Mar 27, 2026
75 of 77 checks passed
@oilbeater oilbeater deleted the fix/gc-add-finish-logs branch March 27, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants