-
Notifications
You must be signed in to change notification settings - Fork 242
enhancement: drop the redundant ApplyUnstructuredResourceImproved
return value
#1833
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
Conversation
(cc @jan--f) |
12f2bce
to
5a7e66e
Compare
Thanks, I like the slimmer interface. /lgtm |
/cc @p0lyn0mial |
cc @deads2k @p0lyn0mial to PTAL 🙏🏼 |
@@ -32,7 +32,7 @@ func DeleteAlertmanager(ctx context.Context, client dynamic.Interface, recorder | |||
|
|||
// ApplyPrometheus applies the Prometheus. | |||
func ApplyPrometheus(ctx context.Context, client dynamic.Interface, recorder events.Recorder, required *unstructured.Unstructured) (*unstructured.Unstructured, bool, error) { | |||
return ApplyUnstructuredResourceImproved(ctx, client, recorder, required, noCache, prometheusGVR, nil, nil) | |||
return ApplyUnstructuredResourceImprovedDeprecated(ctx, client, recorder, required, noCache, prometheusGVR, nil, nil) |
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.
Okay, what is the plan for switching to ApplyUnstructuredResourceImproved
?
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 was thinking of doing that early in the next release to allow enough time for folks to migrate?
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.
OK, so the only difference between these two functions is the number of returned values. Am I right?
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.
Exactly, nothing else.
Friendly ping, @p0lyn0mial for another look here please. I think the deprecation cycle should continue for a couple of releases to allow enough soak time. |
…urn value Drop the boolean return value that signified if an update happened as it is not necessary and pollutes the signature. Signed-off-by: Pranshu Srivastava <[email protected]>
5a7e66e
to
d27edb4
Compare
New changes are detected. LGTM label has been removed. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: jan--f, rexagod The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@rexagod: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
@@ -32,7 +32,7 @@ func DeleteAlertmanager(ctx context.Context, client dynamic.Interface, recorder | |||
|
|||
// ApplyPrometheus applies the Prometheus. | |||
func ApplyPrometheus(ctx context.Context, client dynamic.Interface, recorder events.Recorder, required *unstructured.Unstructured) (*unstructured.Unstructured, bool, error) { |
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.
So your plan is to change the methods, like ApplyPrometheus, to use ApplyUnstructuredResourceImproved, and at the same time, you would also break compatibility?
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 think so, down the line after enough time has passed, since the bool
value is redundant.
@@ -42,7 +42,7 @@ func DeletePrometheus(ctx context.Context, client dynamic.Interface, recorder ev | |||
|
|||
// ApplyPrometheusRule applies the PrometheusRule. | |||
func ApplyPrometheusRule(ctx context.Context, client dynamic.Interface, recorder events.Recorder, required *unstructured.Unstructured) (*unstructured.Unstructured, bool, error) { | |||
return ApplyUnstructuredResourceImproved(ctx, client, recorder, required, noCache, prometheusRuleGVR, nil, nil) |
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.
Also, what is the migration path? Do you know how the redundant parameter is used?
And do you know how many users of ApplyUnstructuredResourceImproved we have? Based on. https://github.com/search?q=org%3Aopenshift%20ApplyUnstructuredResourceImproved&type=code, not that many :)
Is there a value in introducing ApplyUnstructuredResourceImprovedDeprecated ?
Wouldn't be better to change the methods like ApplyAlertmanager ?
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.
Also, what is the migration path? Do you know how the redundant parameter is used?
The parameter is used to check if the function actually updated the object IIRC. However, this is redundant since that could be done based on the returned object, and hence that parameter does not need to be baked into the existing machinery.
And do you know how many users of ApplyUnstructuredResourceImproved we have? Based on. github.com/search?q=org%3Aopenshift%20ApplyUnstructuredResourceImproved&type=code, not that many :)
I see. This is in-line with the fact that we ourselves use the wrapper ApplyX
methods instead downstream. However, the ApplyUnstructuredResourceImproved
change here breaks these functions too, as you mentioned above, namely in:
- openshift/cluster-kube-apiserver-operator
- openshift/multiarch-tuning-operator
- openshift/loki
- openshift/cluster-storage-operator
Is there a value in introducing ApplyUnstructuredResourceImprovedDeprecated ?
Wouldn't be better to change the methods like ApplyAlertmanager ?
In the future, we want to move the focus away from ApplyX
functions, as that implies we'd need to keep library-go
in sync with every arbitrary X
monitoring CRD that is being used downstream.
This essentially creates a loop where an ApplyX
function isn't available for X
, so downstream uses ApplyUnstructuredResourceImproved
for the time being, before switching to ApplyX
when it gets merged here, which itself will always be nothing more than a caller for it, and it would rid us of the unnecessary maintenance that comes as a side-effect (users will effectively need to nil
the last two fields to achieve the same effect, as above).
EDIT: Sorry, scratch that, I forgot that ApplyX
is a part of a conventional pattern across the library, so it'd make sense to keep this so users can keep the same ApplyX
expectations for monitoring types.
Nonetheless, since all of these are essentially calling wrappers, focusing on ApplyUnstructuredResourceImproved
would make it all the more easier for us to maintain (especially helpful when a ApplyX
won't exist, or if we need a more granular control) rather than duplicating the logic across ApplyX
s (as the entirety of the update pattern is the same for all X
s).
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.
However, this is redundant since that could be done based on the returned object, and hence that parameter does not need to be baked into the existing machinery.
I think that returning a parameter indicating whether the object was updated is slightly more convenient than checking the object itself. It is not obvious how to do it. In practice, I think it would involve creating a common function to be used by the callers.
Additionally, the signature of the Apply functions aligns with the signature exposed by the Apply functions for other resources. All return the additional parameter. Here are a few examples:
Does it make sense ?
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.
It does, and seeing that this has been the convention, it wouldn't be nice to break user expectations. Closing, thank you for your review here!
Drop the boolean return value that signified if an update happened as it
is not necessary and pollutes the signature.
Signed-off-by: Pranshu Srivastava [email protected]
Blocked by (and rebased over) #1823. The relevant commit is 12f2bce.