Skip to content

Commit

Permalink
Fix #1107: simplify applier code
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaferraro committed Jan 12, 2022
1 parent 0198461 commit 5520b63
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions pkg/client/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,20 @@ func (c *defaultClient) ServerOrClientSideApplier() ServerOrClientSideApplier {
func (a *ServerOrClientSideApplier) Apply(ctx context.Context, object ctrl.Object) error {
once := false
var err error
// nolint: ifshort
needsRetry := false
a.tryServerSideApply.Do(func() {
once = true
if err = a.serverSideApply(ctx, object); err != nil {
if isIncompatibleServerError(err) {
log.Info("Fallback to client-side apply for installing resources")
a.hasServerSideApply.Store(false)
err = nil
} else {
needsRetry = true
}
} else {
a.hasServerSideApply.Store(true)
}
})
if needsRetry {
a.tryServerSideApply = sync.Once{}
}
if err != nil {
a.tryServerSideApply = sync.Once{}
return err
}
if v := a.hasServerSideApply.Load(); v.(bool) {
Expand Down

0 comments on commit 5520b63

Please sign in to comment.