-
Notifications
You must be signed in to change notification settings - Fork 105
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
Fix unknown fields warnings and possibility to suppress finalizer ones #786
Conversation
Signed-off-by: Hasan Turken <[email protected]>
@@ -63,21 +64,6 @@ type Unstructured struct { | |||
unstructured.Unstructured | |||
} | |||
|
|||
// Reference to a claim. | |||
type Reference struct { |
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.
If I simply added a Reference type under composite package, I was getting import cycle. So, I moved them into a separate reference
package.
5e5b686
to
a34fc1d
Compare
if err := fieldpath.Pave(c.Object).GetValueInto("spec.compositionRevisionRef", out); err != nil { | ||
return nil | ||
} | ||
return out | ||
} | ||
|
||
// SetCompositionRevisionReference of this resource claim. | ||
func (c *Unstructured) SetCompositionRevisionReference(ref *corev1.ObjectReference) { | ||
func (c *Unstructured) SetCompositionRevisionReference(ref *corev1.LocalObjectReference) { |
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.
if err := fieldpath.Pave(c.Object).GetValueInto("spec.resourceRef", out); err != nil { | ||
return nil | ||
} | ||
return out | ||
} | ||
|
||
// SetResourceReference of this composite resource claim. | ||
func (c *Unstructured) SetResourceReference(ref *corev1.ObjectReference) { | ||
func (c *Unstructured) SetResourceReference(ref *reference.Composite) { |
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.
func (c *Unstructured) GetCompositionRevisionReference() *corev1.ObjectReference { | ||
out := &corev1.ObjectReference{} | ||
func (c *Unstructured) GetCompositionRevisionReference() *corev1.LocalObjectReference { | ||
out := &corev1.LocalObjectReference{} |
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.
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.
not a huge fan of suppressing warnings, I would have probably preferred to keep them there and fix them in a follow-up PR.
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.
Thanks for continuing to tackle issues quickly for v1.18 @turkenh!! a few questions for you 🙇♂️
pkg/resource/fake/mocks.go
Outdated
|
||
// ManagedResourceReferencer is a mock that implements ManagedResourceReferencer interface. | ||
type ManagedResourceReferencer struct{ Ref *corev1.ObjectReference } | ||
type ManagedResourceReferencer struct{ Ref *reference.Composite } |
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.
are these updates to ManagedResourceReferencer
correct? Because it is called ManagedResource*
, I would expect them not to only specifically point to a Composite
now 🤔
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.
Great catch! Fixing linter issues one by one and not sure how/why I changed this one 🤔
pkg/warning/warning.go
Outdated
// accidental conflicts with other finalizer writers. | ||
func DomainQualifiedFinalizer(domain string) regexp.Regexp { | ||
return *regexp.MustCompile( | ||
fmt.Sprintf("^metadata.finalizers:.*%s.*prefer a domain-qualified finalizer name to avoid accidental conflicts with other finalizer writers$", domain), |
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.
will this check start to fail once we pick up https://github.com/kubernetes/kubernetes/pull/127303/files which changes the warning message?
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.
Yes, correct. Logs would appear again until we adapt the regexp.
I'll drop the finalizer log suppressing part.
pkg/warning/warning.go
Outdated
*/ | ||
|
||
// Package warning contains utilities for handling warnings. | ||
package warning |
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.
i'm wondering how essential this is actually - it doesn't fix the underlying issue right, it just hides it from the logs? i'm wondering if we just live with the warnings in the logs now, and resolve them with a real fix during the 1.19 milestone, instead of hiding them for now and maybe forgetting about them. What do you think?
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.
I'll drop the last commit, e.g., finalizer log suppressing, since both you and @phisco prefer keeping logs around instead, and I am not too opinionated, at least to consider something that important doing last minute :)
Signed-off-by: Hasan Turken <[email protected]>
1f25008
to
70499a4
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.
Thanks @turkenh for quick responses to the questions and feedback!! 🤩
Successfully created backport PR for |
Description of your changes
This PR aims to clean up warnings observed in crossplane/crossplane#6043 by:
Suppressing "prefer a domain-qualified finalizer" until we properly migrate them to the suggested format.Together with the accompanying PR in Crossplane, I could validate that former warnings disappeared with the changes here.
This PR introduces a new package,warning
, with thewarning.LoggingHandler
implementing rest.WarningHandler interface. This supports deduplication just like the current handler Crossplane uses, but it also uses provided crossplane runtime logger so that warnings logged as structured logs* and also enables discarding logs matching provided regular expressions. I opted to put this into crossplane runtime since we may want to leverage it in other repositories, e.g. providers, as well.I have:
earthly +reviewable
to ensure this PR is ready for review.Linked a PR or a docs tracking issue to document this change.backport release-x.y
labels to auto-backport this PR.Need help with this checklist? See the cheat sheet.