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

Use replace_resource only if resource already exists #111

Merged
merged 6 commits into from
Aug 28, 2024

Conversation

knatsu-summer
Copy link
Contributor

Related Issue

Supports #ISSUE_NUMBER

Related PRs

This PR is not dependent on any other PR

What this PR does / why we need it

Encountering a 404 error when user uses _replace_resource option to deploy a resource that is not currently in the environment.
I would like to add logic to use _apply_resource instead of _replace_resource when first deploying.

Special notes for your reviewer

If applicable**

  • this PR contains documentation
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

What gif most accurately describes how I feel towards this PR?

Example of a gif

Signed-off-by: knatsu-summer <[email protected]>
Copy link
Collaborator

@HonakerM HonakerM left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@gabe-l-hart gabe-l-hart left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! It looks like we need to get the other unit tests passing before merging

@knatsu-summer
Copy link
Contributor Author

knatsu-summer commented Aug 28, 2024

@gabe-l-hart @HonakerM
I made some updates but the unit tests are still failing.
The failure comes from this line

>       assert changed
E       assert False

I tested it locally and added some log prints., it seems that the resource is not being updated after replace function.
The data and path used for replace (PUT method):

  • request body:
{
    "kind": "Foo",
    "apiVersion": "foo.bar.com/v1",
    "metadata": {
        "name": "bar",
        "namespace": "test",
        "managedFields": null
    },
    "spec": {
        "some": "key_1"
    }
}
  • request path:

/apis/foo.bar.com/v1/namespaces/test/foos/bar

The values of current and apply_res are the same as follows::

current: {'apiVersion': 'foo.bar.com/v1', 'kind': 'Foo', 'metadata': {'name': 'bar', 'namespace': 'test', 'managedFields': None}}, 
apply_res:{'apiVersion': 'foo.bar.com/v1', 'kind': 'Foo', 'metadata': {'name': 'bar', 'namespace': 'test', 'managedFields': None}}

I tried server_side_apply and it works as expected.
Do you have any thoughts?

knatsu-summer and others added 3 commits August 28, 2024 21:04
Signed-off-by: knatsu-summer <[email protected]>
Signed-off-by: knatsu-summer <[email protected]>
The update body was accidentally being discarded in favor of the current
cluster state.

Branch: deploymeshod_replace

Signed-off-by: Gabe Goodhart <[email protected]>
@gabe-l-hart
Copy link
Collaborator

@knatsu-summer this found a pretty gnarly bug in the KubMock implementation of PUT. I've pushed a commit that should get the tests in line.

Copy link
Collaborator

@gabe-l-hart gabe-l-hart left a comment

Choose a reason for hiding this comment

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

With the fix in kub_mock, this should be good to go!

@gabe-l-hart gabe-l-hart merged commit fb06355 into IBM:main Aug 28, 2024
6 checks passed
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.

3 participants