-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: Adding debug log for assume already applied #5198
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
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe change introduces a logger parameter to the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
522fe46 to
0c01eca
Compare
0c01eca to
d3f5055
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
internal/queue/queue.go (2)
301-338:GetReadyWithDependencies(logger)preserves behavior; consider a small split to address complexityThe new logger parameter is threaded cleanly: dependency-ordering logic is unchanged, and the method still holds only an
RLockwhile scanning entries, so concurrency guarantees remain intact. TheIgnoreDependencyOrderfast path continues to return allStatusReadyentries as before.SonarCloud’s cognitive-complexity warning here is marginal (just over the threshold). If you want to quiet it without changing behavior, you could split the two branches into helpers that assume the lock is already held, e.g.
getReadyIgnoringOrderUnsafe()andgetReadyRespectingOrderUnsafe(l log.Logger), and haveGetReadyWithDependenciesjust handle locking and dispatch.
344-383: Dependency readiness logic with logging looks sound; complexity could be trimmedThe updated
areDependenciesReadyUnsafecorrectly:
- Treats dependencies missing from the queue as “ready” while adding useful debug logs, with an extra, more specific message when
unitsMapindicatesExecution.AssumeAlreadyApplied.- Honors
IgnoreDependencyErrorsby allowing scheduling when dependency statuses are terminal (isTerminal), aligning with the destroy/ignore-error tests and withareDependentsReadyUnsafe.- Accesses
unitsMapand entries only under the caller-heldRLock, which matches howSetUnitsMapwrites under a fullLock, so map access stays data-race free.Functionally this looks solid. SonarCloud’s cognitive-complexity warning here is mostly due to the nested nil/map checks and the IgnoreDependencyErrors branch. If desired, you could extract the “dependency not in queue” block (including the logging and unitsMap handling) into a helper like
depsMissingButAssumedReady(l, dep component.Component) boolto make this function flatter while keeping behavior identical.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
internal/queue/queue.go(4 hunks)internal/queue/queue_test.go(33 hunks)internal/runner/runnerpool/controller.go(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
⚙️ CodeRabbit configuration file
Review the Go code for quality and correctness. Make sure that the Go code follows best practices, is performant, and is easy to understand and maintain.
Files:
internal/runner/runnerpool/controller.gointernal/queue/queue.gointernal/queue/queue_test.go
🧠 Learnings (1)
📚 Learning: 2025-02-10T13:36:19.542Z
Learnt from: levkohimins
Repo: gruntwork-io/terragrunt PR: 3723
File: cli/commands/stack/action.go:160-160
Timestamp: 2025-02-10T13:36:19.542Z
Learning: The project uses a custom error package `github.com/gruntwork-io/terragrunt/internal/errors` which provides similar functionality to `fmt.Errorf` but includes stack traces. Prefer using this package's error functions (e.g., `errors.Errorf`, `errors.New`) over the standard library's error handling.
Applied to files:
internal/queue/queue_test.go
🧬 Code graph analysis (2)
internal/queue/queue.go (1)
pkg/log/log.go (1)
Debugf(72-74)
internal/queue/queue_test.go (2)
test/helpers/logger/logger.go (1)
CreateLogger(9-14)internal/queue/queue.go (1)
NewQueue(220-298)
🪛 GitHub Check: SonarCloud Code Analysis
internal/queue/queue.go
[failure] 301-301: Refactor this method to reduce its Cognitive Complexity from 16 to the 15 allowed.
[failure] 344-344: Refactor this method to reduce its Cognitive Complexity from 23 to the 15 allowed.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Pull Request has non-contributor approval
🔇 Additional comments (3)
internal/runner/runnerpool/controller.go (1)
109-112: Logger propagation into the queue looks correctPassing
lintodr.q.GetReadyWithDependencies(l)keeps dependency-resolution logs on the same logger as the rest of the controller and does not change locking or control flow. No changes requested.internal/queue/queue_test.go (2)
3-11: Using the test helper logger to satisfy the new signature is appropriateImporting
test/helpers/loggerand relying onlogger.CreateLogger()keeps tests decoupled from production logging configuration while satisfyingGetReadyWithDependencies(logger)’s contract. Looks good.
254-1012: Tests correctly exercise the newGetReadyWithDependencies(logger)contractAll updated tests now pass a
log.Loggerinstance intoGetReadyWithDependencies, either via a sharedl := logger.CreateLogger()or inline calls, and the assertions still verify the intended queue behavior (includingIgnoreDependencyErrors+ destroy flows). The changes are consistent and do not introduce new edge cases.
Description
Adds some simple debug logs to track that units are being included in the queue despite dependents being excluded.
TODOs
Read the Gruntwork contribution guidelines.
Release Notes (draft)
Added / Removed / Updated [X].
Migration Guide
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.