bluek8s / kubedirector

Kubernetes Director (aka KubeDirector) for deploying and managing stateful applications on Kubernetes
Apache License 2.0
401 stars 91 forks source link

Migrate Client().Update() calls back to Patch() calls #194

Open don-milos opened 5 years ago

don-milos commented 5 years ago

When KubeDirector was migrated from operator-sdk version v0.0.6 to v0.8.1 the calls to sdk.Patch() were replaced with calls to Client().Update() because the Patch() API was removed. The Update() call replaces the entire resource object instead of a few selected fields in the object. Also, the objects now contain a ResourceVersion and if the update object is not at the latest ResourceVersion then the update fails with an IsConflict error with a message to try again with an up to date object. To recover from this error additional code was added to fetch the most recent version of the object, patch it, and then try the update again with the patched object.

The Patch() API is supposed to reintroduced in the next release of the K8s controller-runtime library. When a stable release with the Patch() API is available we need to port the KubeDirector back to using patch instead of update and remove all the retry logic from the code.

joel-bluedata commented 5 years ago

FYI version 0.2.0 of the controller-runtime is now out.

Won't try to uptake this until we're done merging the initial set of operator-sdk changes into the master branch. (And may need to wait until operator-sdk moves to use that version of controller-runtime.)

joel-bluedata commented 5 years ago

We can keep an eye on this file to see what version of controller-runtime is currently being used by the SDK: https://github.com/operator-framework/operator-sdk/blob/master/internal/pkg/scaffold/gopkgtoml.go

joel-bluedata commented 4 years ago

Next operator SDK release after v0.10.0 should use controller runtime 0.2.0.

Some relevant docs in this change: https://github.com/operator-framework/operator-sdk/commit/947a464dbe968b8af147049e76e40f787ccb0847 especially in CHANGELOG.md and in doc/user/client.md.

The default CRD file naming pattern also seems different now.

Code generation tags may have changed?

joel-bluedata commented 4 years ago

Yep, releases v0.11.0 and later of the operator SDK use the controller-runtime that has PATCH support.

joel-bluedata commented 4 years ago

However when we update past v0.8.2, we'll have to finally transition from using dep to using Go modules instead, which, sigh. There's always something!

Created issue #222 for that.

joel-bluedata commented 4 years ago

Starting work on porting to new operator SDK in https://github.com/joel-bluedata/kubedirector/tree/sdk

joel-bluedata commented 4 years ago

Using new SDK now.

joel-bluedata commented 4 years ago

Not a blocker for 0.5.0, but it would be nice to tackle at least some of these so I will leave this on the 0.5.0 milestone for now.