Skip to content
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

NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl extends ServerSideApplicable #5073

Merged
merged 4 commits into from
May 3, 2023

Conversation

pan3793
Copy link
Contributor

@pan3793 pan3793 commented Apr 26, 2023

Description

CreateOrReplaceable#createOrReplace is deprecated, and the suggestion is

@deprecated please user {@link ServerSideApplicable#serverSideApply()} or attempt a create and edit/patch operation.

This change allows the following usage easy to migrate

kubernetesClient.resourceList(resources).createOrReplace()
kubernetesClient.resourceList(resources).forceConflicts().serverSideApply()

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

@pan3793
Copy link
Contributor Author

pan3793 commented Apr 26, 2023

cc @shawkins, is the following migration right?

resources.createOrReplace()
resources.forceConflicts().serverSideApply()

@rohanKanojia
Copy link
Member

@pan3793 : Is this PR related to #5071 ?

@pan3793
Copy link
Contributor Author

pan3793 commented Apr 26, 2023

@pan3793 : Is this PR related to #5071 ?

Just a little. I found some issues(#5071) in createOrReplace, but since it was deprecated, I move to migrate instead of fix. And found this issue(independent) on investigating migration to the suggested API

@shawkins
Copy link
Contributor

shawkins commented Apr 26, 2023

cc @shawkins, is the following migration right?

With the caveat that the user may choose not to use forcing if they want to know when there are conflicting changes.

Also unlike createOrReplace if the resourceVersion is set on the resource and a replace is attempted, it will be optimistically locked.

This change allows the following usage easy to migrate

I was mixed on how many of these composite operations to expose. The user also has access to resources(), so one can do whatever with resources().forEach(...) - including error handling, which is non-existent in performOperation. So here the alternative to adding these methods is to use

resourceList(list).resources().forEach(r -> r.forceConflicts().serverSideApply())  

Tests are needed for this pr - you'll notice when this is executed that the fieldManager and forceConflicts are lost. This is because a new context is created for each resource and we're specifically propagating what is applicable to the write operations in

public <C extends Client> C clientInWriteContext(Class<C> clazz) {

@pan3793
Copy link
Contributor Author

pan3793 commented Apr 26, 2023

This is because a new context is created for each resource and we're specifically propagating what is applicable to the write operations

@shawkins thanks, but where can I find the definition of "what is applicable to the write operations"?

@shawkins
Copy link
Contributor

thanks, but where can I find the definition of "what is applicable to the write operations"?

In this case you are making forceConflicts and fieldManager applicable. They would need to be added to the context

@pan3793
Copy link
Contributor Author

pan3793 commented Apr 26, 2023

I was mixed on how many of these composite operations to expose.

I would say it's a little hard for me to figure out how to handle the deprecated method invocations of this library, many suggestions in deprecated's description link to a totally different class, w/o examples. Not like the following common case

class Foo {

  @deprecated use `barV2` instead
  void bar() { ... }

  void barV2() { ... }
}

So, I think implementing this interface makes user easy to migrate.

@pan3793
Copy link
Contributor Author

pan3793 commented Apr 26, 2023

Tests are needed for this pr - you'll notice when this is executed that the fieldManager and forceConflicts are lost.

Thanks for the tips, UT ServerSideApplyTest is added.

@pan3793 pan3793 force-pushed the server-side-apply branch 2 times, most recently from a8e51e7 to 50bc91b Compare April 27, 2023 08:38
@pan3793 pan3793 force-pushed the server-side-apply branch from 50bc91b to 6261b22 Compare April 27, 2023 09:13
@pan3793
Copy link
Contributor Author

pan3793 commented Apr 27, 2023

@shawkins could you please take another look?

@shawkins
Copy link
Contributor

Was there a reason to copy the test logic, rather than calling the methods that were already on PatchTest?

@pan3793
Copy link
Contributor Author

pan3793 commented Apr 28, 2023

@shawkins moved test case into PatchTest

@pan3793 pan3793 force-pushed the server-side-apply branch from 317f3d1 to da8b25b Compare April 28, 2023 03:24
@pan3793
Copy link
Contributor Author

pan3793 commented Apr 28, 2023

Test failure seems irrelevant.

Copy link
Contributor

@shawkins shawkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@pan3793
Copy link
Contributor Author

pan3793 commented May 2, 2023

@shawkins @manusa is there anything I can do before it gets in?

@manusa manusa added this to the 6.6.0 milestone May 3, 2023
@manusa
Copy link
Member

manusa commented May 3, 2023

@shawkins @manusa is there anything I can do before it gets in?

Looks good, thx. Releasing today.

@manusa manusa merged commit e78f053 into fabric8io:master May 3, 2023
dongjoon-hyun pushed a commit to apache/spark that referenced this pull request May 3, 2023
### What changes were proposed in this pull request?

The release notes are available at
https://github.com/fabric8io/kubernetes-client/releases/tag/v6.6.0

### Why are the changes needed?

It's basically a routine work, to keep the third-party libs up-to-date.

And fabric8io/kubernetes-client#5073 simplifies SPARK-43356

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass GA.

Closes #41034 from pan3793/SPARK-43355.

Authored-by: Cheng Pan <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
@pan3793 pan3793 deleted the server-side-apply branch May 4, 2023 01:50
LuciferYang pushed a commit to LuciferYang/spark that referenced this pull request May 10, 2023
### What changes were proposed in this pull request?

The release notes are available at
https://github.com/fabric8io/kubernetes-client/releases/tag/v6.6.0

### Why are the changes needed?

It's basically a routine work, to keep the third-party libs up-to-date.

And fabric8io/kubernetes-client#5073 simplifies SPARK-43356

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass GA.

Closes apache#41034 from pan3793/SPARK-43355.

Authored-by: Cheng Pan <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
dongjoon-hyun pushed a commit to apache/spark that referenced this pull request Jun 7, 2023
### What changes were proposed in this pull request?

The deprecation message of `createOrReplace` indicates that we should change `createOrReplace` to `serverSideApply` instead.

```
deprecated please use {link ServerSideApplicable#serverSideApply()} or attempt a create and edit/patch operation.
```

The change is not fully equivalent, but I believe it's reasonable.

> With the caveat that the user may choose not to use forcing if they want to know when there are conflicting changes.
>
> Also unlike createOrReplace if the resourceVersion is set on the resource and a replace is attempted, it will be optimistically locked.

See more details at fabric8io/kubernetes-client#5073

### Why are the changes needed?

Remove usage of deprecated API.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass GA.

Closes #41136 from pan3793/SPARK-43356.

Authored-by: Cheng Pan <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
czxm pushed a commit to czxm/spark that referenced this pull request Jun 12, 2023
### What changes were proposed in this pull request?

The deprecation message of `createOrReplace` indicates that we should change `createOrReplace` to `serverSideApply` instead.

```
deprecated please use {link ServerSideApplicable#serverSideApply()} or attempt a create and edit/patch operation.
```

The change is not fully equivalent, but I believe it's reasonable.

> With the caveat that the user may choose not to use forcing if they want to know when there are conflicting changes.
>
> Also unlike createOrReplace if the resourceVersion is set on the resource and a replace is attempted, it will be optimistically locked.

See more details at fabric8io/kubernetes-client#5073

### Why are the changes needed?

Remove usage of deprecated API.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass GA.

Closes apache#41136 from pan3793/SPARK-43356.

Authored-by: Cheng Pan <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
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.

4 participants