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(),