Skip to content

add debug logs - #51

Closed
adziauho wants to merge 2 commits into
masterfrom
add-debug-logs
Closed

adziauho wants to merge 2 commits into
masterfrom
add-debug-logs

Conversation

@adziauho

@adziauho adziauho commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI lite review requested due to automatic review settings September 3, 2026 14:53
Signed-off-by: Aliaksei Dziauho <a.dziauho@sap.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new CloudProfile spec JSON logging can leak provider-specific configuration and does unnecessary work even when verbose logging is disabled, so it should be guarded/redacted and error-aware before merging.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adds additional logging to the controller reconciliation flow to improve observability when reconciling ManagedCloudProfile resources and applying the generated Gardener CloudProfile.

Changes:

  • Log reconcile triggers with object generation/resourceVersion and log when status patches are skipped/issued.
  • Log the CreateOrPatch operation result for the generated CloudProfile and (on updates) emit a spec “before/after” debug log.
File summaries
File Description
controllers/managedcloudprofile_controller.go Adds verbose reconcile/status-patch debug logs to improve traceability of reconciliation progress.
controllers/cloud_profile.go Adds logging around CreateOrPatch operations and emits a spec “diff” log for updated CloudProfiles.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread controllers/cloud_profile.go Outdated
Comment thread controllers/cloud_profile.go
Copilot AI review requested due to automatic review settings September 3, 2026 15:06
Signed-off-by: Aliaksei Dziauho <a.dziauho@sap.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new spec-diff logging can expose large and potentially sensitive provider configuration at runtime and should be adjusted/redacted before merging.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

controllers/cloud_profile.go:66

  • CloudProfile patch operation is logged at verbosity 0, so it will show up on every reconcile (even when nothing changes), which can be noisy for a controller that requeues periodically. Consider making this a debug-level log (V(1)) so it’s only emitted when higher verbosity is enabled.
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +67 to +77
if op == controllerutil.OperationResultUpdated && log.V(1).Enabled() {
beforeJSON, err := json.Marshal(specBefore)
if err != nil {
log.Error(err, "failed to marshal spec before")
}
afterJSON, err := json.Marshal(cloudProfile.Spec)
if err != nil {
log.Error(err, "failed to marshal spec after")
}
log.V(1).Info("CloudProfile spec diff", "before", string(beforeJSON), "after", string(afterJSON))
}
Copilot AI review requested due to automatic review settings September 3, 2026 15:09
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/cobaltcore-dev/cloud-profile-sync/controllers 74.74% (+1.05%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/cobaltcore-dev/cloud-profile-sync/controllers/cloud_profile.go 61.07% (+2.59%) 131 (+13) 80 (+11) 51 (+2) 👍
github.com/cobaltcore-dev/cloud-profile-sync/controllers/managedcloudprofile_controller.go 100.00% (ø) 42 (+6) 42 (+6) 0

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

@adziauho adziauho closed this Sep 3, 2026
@adziauho
adziauho deleted the add-debug-logs branch September 3, 2026 15:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Current CloudProfile logging is noisy/misordered (logs before error handling) and includes potentially sensitive/large spec dumps at low verbosity, plus a misleading “skipping retry” message.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

controllers/cloud_profile.go:70

  • CloudProfile patch operation is logged at info level and the spec before/after log runs before the err != nil handling. This can add noisy logs and also prints full CloudProfileSpec JSON (which may include large/sensitive fields like caBundle / providerConfig) at V(1). Consider only logging after a successful CreateOrPatch, lowering to V(1) for the operation, and moving the full spec dump behind a higher verbosity (and only when marshaling succeeds).
	log.Info("CloudProfile patch operation", "operation", op)
	if op == controllerutil.OperationResultUpdated && log.V(1).Enabled() {
		beforeJSON, err := json.Marshal(specBefore)
		if err != nil {
			log.Error(err, "failed to marshal spec before")
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

return fmt.Errorf("failed to patch ManagedCloudProfile status: %w", statusErr)
}
if apierrors.IsInvalid(err) {
log.Error(err, "CloudProfile is invalid, skipping retry")
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.

4 participants