From 2a60184eb1b85cb6b4986f7019c4924942a19cf6 Mon Sep 17 00:00:00 2001 From: Tadayoshi Sato Date: Mon, 21 Jun 2021 21:47:07 +0900 Subject: [PATCH] fix(trait): never fallback to client-side apply unless server-side apply is incombatible CSA support is mainly kept for compatibility reason and will ultimately be removed, so it should only be used as fallback when SSA is known to be unavailable. --- pkg/trait/deployer.go | 3 +++ pkg/util/test/client.go | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/pkg/trait/deployer.go b/pkg/trait/deployer.go index 7c7dc96811..6b357cc1d1 100644 --- a/pkg/trait/deployer.go +++ b/pkg/trait/deployer.go @@ -96,6 +96,9 @@ func (t *deployerTrait) Apply(e *Environment) error { } else if isIncompatibleServerError(err) { t.L.Info("Fallback to client-side apply to patch resources") hasServerSideApply = false + } else { + // Keep server-side apply unless server is incompatible with it + return err } } if err := t.clientSideApply(env, resource); err != nil { diff --git a/pkg/util/test/client.go b/pkg/util/test/client.go index 69c8f05ae2..46d4fc4890 100644 --- a/pkg/util/test/client.go +++ b/pkg/util/test/client.go @@ -18,6 +18,7 @@ limitations under the License. package test import ( + "context" "strings" "github.com/apache/camel-k/pkg/apis" @@ -105,6 +106,11 @@ func (c *FakeClient) GetCurrentNamespace(kubeConfig string) (string, error) { return "", nil } +// Patch mimicks patch for server-side apply and simply creates the obj +func (c *FakeClient) Patch(ctx context.Context, obj controller.Object, patch controller.Patch, opts ...controller.PatchOption) error { + return c.Create(ctx, obj) +} + func (c *FakeClient) Discovery() discovery.DiscoveryInterface { return &FakeDiscovery{ DiscoveryInterface: c.Interface.Discovery(),