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

Replace Update by Patch on K8S resource #333

Merged
merged 5 commits into from
Dec 12, 2023

Conversation

juldrixx
Copy link
Contributor

@juldrixx juldrixx commented Dec 11, 2023

Q A
Bug fix? no
New feature? yes
API breaks? no
Deprecations? no
Related tickets fixes #X, partially #Y, mentioned in #Z
License Apache 2.0

What's in this PR?

Changes to replace Update instructions by Patch instructions on K8S resources.

Why?

To prevent errors due to simultaneous updates.

Checklist

  • Implementation tested
  • Error handling code meets the guideline
  • Logging code meets the guideline
  • User guide and development docs updated (if needed)
  • Append changelog with changes

@juldrixx juldrixx requested review from mh013370 and erdrix and removed request for mh013370 December 11, 2023 15:12
@mh013370
Copy link
Member

Should we patch everywhere instead of updating to avoid these errors? If so, should we consider cases where nifikop updates k8s resources?

https://github.com/konpyutaika/nifikop/blob/master/pkg/k8sutil/resource.go#L111

CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Michael H <[email protected]>
@juldrixx
Copy link
Contributor Author

Should we patch everywhere instead of updating to avoid these errors? If so, should we consider cases where nifikop updates k8s resources?

https://github.com/konpyutaika/nifikop/blob/master/pkg/k8sutil/resource.go#L111

Not necessarily, I don't think that is necessary to patch instead of update the resources owned by NiFiKop and only manipulated by NiFiKop. The issue with the CRD, it's that they can be modified by pretty much everything like a chart HELM, Keda or even NiFiKop itself by another controller. So my changes are aimed at getting controllers to patch their resources so they won't be affected by the rest. But maybe, I'm wrong and I'm missing something 🤔.

And the work to change the Update to Patch can be heavy because you need to pass the patcher to it. But again maybe, the implementation I did is not the most effecient one 🤔. So if you see a way to do it more easly, let me know, I'm interested 😁.

@mh013370
Copy link
Member

Should we patch everywhere instead of updating to avoid these errors? If so, should we consider cases where nifikop updates k8s resources?
https://github.com/konpyutaika/nifikop/blob/master/pkg/k8sutil/resource.go#L111

Not necessarily, I don't think that is necessary to patch instead of update the resources owned by NiFiKop and only manipulated by NiFiKop. The issue with the CRD, it's that they can be modified by pretty much everything like a chart HELM, Keda or even NiFiKop itself by another controller. So my changes are aimed at getting controllers to patch their resources so they won't be affected by the rest. But maybe, I'm wrong and I'm missing something 🤔.

And the work to change the Update to Patch can be heavy because you need to pass the patcher to it. But again maybe, the implementation I did is not the most effecient one 🤔. So if you see a way to do it more easly, let me know, I'm interested 😁.

That's reasonable. The resources nifikop creates/manages wouldn't also be managed by ArgoCD, Helm CLI, etc.

I can't think of a better way, to be honest. You need to capture the patch from the original object and carry it through until you apply the patch so that does make code changes fairly significant.

….com:konpyutaika/nifikop into feat/replace_update_by_patch_on_k8s_resource
@mh013370
Copy link
Member

LGTM! Merge at your leisure

@juldrixx juldrixx merged commit 0a14e4b into master Dec 12, 2023
1 check passed
@juldrixx juldrixx deleted the feat/replace_update_by_patch_on_k8s_resource branch December 12, 2023 12:58
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.

2 participants