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

fix(feature): uses server-side apply to reconile #1098

Conversation

bartoszmajsak
Copy link
Contributor

@bartoszmajsak bartoszmajsak commented Jul 4, 2024

Description

Aligns reconcile strategy for Managed() features to rely on Server-side apply rather than Update. The SSA approach is used by deploy package when reconciling kustomize resources, so keeping it the same makes sense.

The previous one, based on client.Update call, tries to overwrite the entire resource rather than using a patch operation, which can lead to errors when trying to overwrite immutable fields such as:

failed to update object test-namespace/knative-local-gateway: Service "knative-local-gateway" is invalid: [metadata.resourceVersion: Invalid value: "": must be specified for an update, spec.clusterIP: Invalid value: "": field is immutable]

Additional changes

  • if "managed" annotation is present in one of the resources being part of the feature it will be respected
  • reworked tests to be more self-descriptive. Extracted funcs were adding more hops while reading the code before understanding what was actually happening

How Has This Been Tested?

In make we trust.

Screenshot or short clip

Merge criteria

  • You have read the contributors guide.
  • Commit messages are meaningful - have a clear and concise summary and detailed explanation of what was changed and why.
  • Pull Request contains a description of the solution, a link to the JIRA issue, and to any dependent or related Pull Request.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Aligns reconcile strategy for Managed() features to rely on Server-side
apply rather than Update. Former apprach is used by deploy package when
reconciling kustomize resources. Later tries to overwrite the entire resource
rather than using patch which can lead to errors when trying to
overwrite immutable fields such as:

```
failed to update object test-namespace/knative-local-gateway: Service "knative-local-gateway" is invalid: [metadata.resourceVersion: Invalid value: "": must be specified for an update, spec.clusterIP: Invalid value: "": field is immutable]
```

Additional changes
- if "managed" annotation is present in one of the resources being part
  of the feature it will be respected
- reworked tests to be more self-descriptive. extracted funcs were
  adding more hops while reading the code before understanding what is
actually happening
if errJSON != nil {
return fmt.Errorf("error converting yaml to json: %w", errJSON)
}
return cli.Patch(ctx, target, client.RawPatch(k8stypes.ApplyPatchType, data), client.ForceOwnership, client.FieldOwner("rhods-operator"))
Copy link
Member

Choose a reason for hiding this comment

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

rhods-operator ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Took it from the existing trusted bundle one. As I don't pass any owner here (like with deploy/kustomize) I thought using the same should be fine. The naming is outdated, I agree, but if we want to change it, let's change in both places in other PR.

@openshift-ci openshift-ci bot added the lgtm label Jul 4, 2024
Copy link

openshift-ci bot commented Jul 4, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zdtsw

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Jul 4, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 9b68ea8 into opendatahub-io:incubation Jul 4, 2024
8 checks passed
bartoszmajsak added a commit to bartoszmajsak/opendatahub-operator that referenced this pull request Jul 8, 2024
Ensures each test case deploys resources in their own namespaces to
avoid sharing state between tests (sometimes unintentionally).

Follow up to opendatahub-io#1098
openshift-merge-bot bot pushed a commit that referenced this pull request Jul 8, 2024
Ensures each test case deploys resources in their own namespaces to
avoid sharing state between tests (sometimes unintentionally).

Follow up to #1098
VaishnaviHire pushed a commit to VaishnaviHire/opendatahub-operator that referenced this pull request Jul 24, 2024
Aligns reconcile strategy for Managed() features to rely on Server-side
apply rather than Update. Former apprach is used by deploy package when
reconciling kustomize resources. Later tries to overwrite the entire resource
rather than using patch which can lead to errors when trying to
overwrite immutable fields such as:

```
failed to update object test-namespace/knative-local-gateway: Service "knative-local-gateway" is invalid: [metadata.resourceVersion: Invalid value: "": must be specified for an update, spec.clusterIP: Invalid value: "": field is immutable]
```

Additional changes
- if "managed" annotation is present in one of the resources being part
  of the feature it will be respected
- reworked tests to be more self-descriptive. extracted funcs were
  adding more hops while reading the code before understanding what is
actually happening

(cherry picked from commit 9b68ea8)
VaishnaviHire pushed a commit to VaishnaviHire/opendatahub-operator that referenced this pull request Jul 24, 2024
Ensures each test case deploys resources in their own namespaces to
avoid sharing state between tests (sometimes unintentionally).

Follow up to opendatahub-io#1098

(cherry picked from commit 67309b6)
VaishnaviHire pushed a commit to VaishnaviHire/opendatahub-operator that referenced this pull request Jul 24, 2024
Aligns reconcile strategy for Managed() features to rely on Server-side
apply rather than Update. Former apprach is used by deploy package when
reconciling kustomize resources. Later tries to overwrite the entire resource
rather than using patch which can lead to errors when trying to
overwrite immutable fields such as:

```
failed to update object test-namespace/knative-local-gateway: Service "knative-local-gateway" is invalid: [metadata.resourceVersion: Invalid value: "": must be specified for an update, spec.clusterIP: Invalid value: "": field is immutable]
```

Additional changes
- if "managed" annotation is present in one of the resources being part
  of the feature it will be respected
- reworked tests to be more self-descriptive. extracted funcs were
  adding more hops while reading the code before understanding what is
actually happening

(cherry picked from commit 9b68ea8)
VaishnaviHire pushed a commit to VaishnaviHire/opendatahub-operator that referenced this pull request Jul 24, 2024
Ensures each test case deploys resources in their own namespaces to
avoid sharing state between tests (sometimes unintentionally).

Follow up to opendatahub-io#1098

(cherry picked from commit 67309b6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants