Skip to content

Improve logging and fix status patch issue - #47

Merged
anton-paulovich merged 1 commit into
masterfrom
refactor-error-handling
Aug 28, 2026
Merged

Improve logging and fix status patch issue#47
anton-paulovich merged 1 commit into
masterfrom
refactor-error-handling

Conversation

@anton-paulovich

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI lite review requested due to automatic review settings August 28, 2026 10:52

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.

Pull request overview

This PR reduces log noise during CloudProfile reconciliation and addresses a status patch failure mode by ensuring overly long metav1.Condition.Message values are truncated to Kubernetes’ maximum length.

Changes:

  • Lowered verbosity of per-update reconciliation logs to V(1) in the CloudProfile controller.
  • Truncated the “apply failed” condition message to avoid exceeding Kubernetes’ Condition.Message length limit.
  • Removed a verbose log when skipping USI image variants in the Glance source.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
controllers/cloud_profile.go Reduces reconcile log verbosity and truncates condition messages to prevent status patch failures.
cloudprofilesync/ossync/source/glance/os_source.go Removes a verbose skip log when filtering USI image variants during version parsing.

💡 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
Copilot AI review requested due to automatic review settings August 28, 2026 10:59
@anton-paulovich
anton-paulovich force-pushed the refactor-error-handling branch from 5503492 to c7b6cdc Compare August 28, 2026 10:59

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.

Pull request overview

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

Suppressed comments (1)

controllers/cloud_profile.go:266

  • truncateConditionMessage slices the string at an arbitrary byte offset. If the message contains multi-byte UTF-8 characters, this can split a rune and produce invalid UTF-8; Go’s JSON encoding will replace invalid sequences, which can also change the final byte length and potentially re-trigger the original status-patch validation error.

Consider truncating on a UTF-8 rune boundary while still enforcing the byte limit.

		return msg
	}
	const suffix = "...[truncated]"
	return msg[:maxConditionMessageLen-len(suffix)] + suffix
}

@anton-paulovich
anton-paulovich force-pushed the refactor-error-handling branch from c7b6cdc to 32ed6fd Compare August 28, 2026 11:16
Signed-off-by: Anton Paulovich <a.paulovich@sap.com>
Copilot AI review requested due to automatic review settings August 28, 2026 11:18
@anton-paulovich
anton-paulovich force-pushed the refactor-error-handling branch from 32ed6fd to 9c373cd Compare August 28, 2026 11:18
@anton-paulovich

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@github-actions

Copy link
Copy Markdown

Merging this branch will decrease overall coverage

Impacted Packages Coverage Δ 🤖
github.com/cobaltcore-dev/cloud-profile-sync/cloudprofilesync/k8ssync/source/landscape 78.54% (ø)
github.com/cobaltcore-dev/cloud-profile-sync/cloudprofilesync/ossync 95.28% (ø)
github.com/cobaltcore-dev/cloud-profile-sync/cloudprofilesync/ossync/source/glance 67.50% (-0.27%) 👎
github.com/cobaltcore-dev/cloud-profile-sync/controllers 70.59% (-0.23%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/cobaltcore-dev/cloud-profile-sync/cloudprofilesync/k8ssync/source/landscape/landscape_source.go 78.54% (ø) 233 183 50
github.com/cobaltcore-dev/cloud-profile-sync/cloudprofilesync/ossync/os_image_updater.go 95.28% (ø) 106 101 5
github.com/cobaltcore-dev/cloud-profile-sync/cloudprofilesync/ossync/source/glance/os_source.go 67.50% (-0.27%) 120 (-1) 81 (-1) 39 👎
github.com/cobaltcore-dev/cloud-profile-sync/controllers/cloud_profile.go 47.41% (+0.09%) 116 (+4) 55 (+2) 61 (+2) 👍

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.

Changed unit test files

  • github.com/cobaltcore-dev/cloud-profile-sync/cloudprofilesync/ossync/os_image_updater_test.go

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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

controllers/cloud_profile.go:266

  • truncateConditionMessage slices the string by byte length. If the message contains non-ASCII characters, this can cut in the middle of a multi-byte UTF-8 rune and produce an invalid UTF-8 string, which can be rejected by the API server (or cause confusing output). Truncate at a rune boundary while still enforcing the byte limit.
	const suffix = "...[truncated]"
	return msg[:maxConditionMessageLen-len(suffix)] + suffix
}

Comment thread controllers/cloud_profile.go
@anton-paulovich
anton-paulovich merged commit 18c29b6 into master Aug 28, 2026
8 checks passed
@anton-paulovich
anton-paulovich deleted the refactor-error-handling branch August 28, 2026 12:34
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.

3 participants