-
Notifications
You must be signed in to change notification settings - Fork 2k
Add support for transforming objects in shared informers #2148
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
* | ||
* @param transformFunc the transform function | ||
*/ | ||
void setTransformFunc(Function<KubernetesObject, KubernetesObject> transformFunc); |
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.
lets define a functional interface named TransformFunc
to align w/ the upsteam, also the original go function returns an error upon failure, so i think we should declare a checked exception e.g. throws ObjectTransformException
. the unit test should also cover the failure path when the checked exception is thrown.
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 the original go function returns an error upon failure, so i think we should declare a checked exception e.g.
throws ObjectTransformException
.
The exception handling references addIndexers
, which returns an error in client-go while in client-java it doesn't declare an exception
https://github.com/kubernetes/kubernetes/blob/v1.23.4/staging/src/k8s.io/client-go/tools/cache/shared_informer.go#L189
java/util/src/main/java/io/kubernetes/client/informer/impl/DefaultSharedIndexInformer.java
Lines 287 to 292 in a5a7ce9
public void addIndexers(Map<String, Function<ApiType, List<String>>> indexers) { | |
if (started) { | |
throw new IllegalStateException("cannot add indexers to a running informer"); | |
} | |
indexer.addIndexers(indexers); | |
} |
Do you mean something like this?
public interface TransformFunc {
/**
* @param the original object to be transformed
* @return the transformed object
*/
KubernetesObject transform(KubernetesObject object) throws ObjectTransformException;
}
or keep it aligned with addIndexers
?
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.
Do you mean something like this?
yes, thats exactly what i thought, as for addIndexers
, i think we can keep it, it's the legacy code and it's working.
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, fixed
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.
@dddddai thanks! one outstanding comment otherwise lgtm
Signed-off-by: dddddai <[email protected]>
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dddddai, yue9944882 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes #2146