Repository navigation
Fix #6663: skip auto-inferred trait defaults in .status.traits - #6667
Conversation
Fixes #6663 The integration status was including auto-inferred trait values such as container.expose and service.enabled that the user never explicitly set. This happened because executedTraitCondition() serialized all non-zero fields from the in-memory trait structs (including values set by auto-detection in Configure()), and the subsequent Merge() with mergo.WithOverride propagated them into Status.Traits. Change the Apply() function to only copy Spec.Traits into Status.Traits without merging the executed traits. This ensures the status only reflects what the user explicitly configured.
4227d7d to
d240fb3
Compare
squakez
left a comment
There was a problem hiding this comment.
Thanks for the PR. However this is completely wrong. Please, make sure to understand the entire logic before applying this again. In theory we should only skip the defaults values not recording them in the API trait type.
Yeah sorry you're right, my bad for blindly trusting Codex too much. I think option B would be a more thorough approach, but it involves wider changes. What do you think? |
|
Hello, no problem. Yeah, option B would be the right choice. I think it just affects a couple of fields, at least in the case reported in the issue. |
Keep storing executed traits in Integration status, but stop writing auto-detected defaults back into serialized API trait fields. - service: use a local enabled flag instead of mutating t.Enabled - container: store auto expose in an unexported field and stop writing inferred RunAsUser into t.RunAsUser during Apply - restore Status.Traits merge with executed traits in trait.Apply Fixes #6663
squakez
left a comment
There was a problem hiding this comment.
Some minor changes in one test, the rest is good, thanks!
- capture traits return value and assert Service is nil in TestServiceWithKnativeServiceDisabledInIntegrationPlatform - replace conditional check with direct nil assertion in TestServiceAutoConfiguration
Thank you for reviewing, done. |
Fixes #6663
Summary
Previous approach (stopping executed traits from being written to
Status.Traits) was incorrect — it broke thefeat(api): store executed traits in statuscontract used by GitOps export and platform/profile propagation.This revision keeps executed traits in status but stops auto-inferred defaults from leaking into serialized API trait fields (Option B):
enabledis carried in a local variable instead of mutatingt.Enabledexposeis stored in an unexported field; inferred OpenShiftRunAsUseris applied to the container security context without writing back tot.RunAsUserStatus.TraitsScope
This PR covers the traits called out in #6663 (
container,service). Similar auto-writeback patterns exist inknative-service,knative,cron, andmastertraits and can be addressed in follow-up PRs.Testing
TestAutoInferredServiceTraitsDoNotLeakIntoStatus— HTTP integration creates a Service butStatus.Traitsstays emptyTestUserSpecifiedTraitValuesStillAppearInStatus— user-setcontainer.portis still recorded in statusRunAsUser/service.enabledin serialized traitsgo test ./pkg/trait/...andmake lintpass