Skip to content

Commit

Permalink
fix(trait): never fallback to client-side apply unless server-side ap…
Browse files Browse the repository at this point in the history
…ply 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.
  • Loading branch information
tadayosi committed Jun 21, 2021
1 parent 409b355 commit 2a60184
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/trait/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions pkg/util/test/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
package test

import (
"context"
"strings"

"github.com/apache/camel-k/pkg/apis"
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 2a60184

Please sign in to comment.