Skip to content

Commit

Permalink
fix: retry Experiment ReplicaSet scaling conflict errors
Browse files Browse the repository at this point in the history
Signed-off-by: Jesse Suen <[email protected]>
  • Loading branch information
jessesuen committed Jan 15, 2022
1 parent 0f93f9b commit 417b390
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions experiments/replicaset.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import (
"fmt"
"time"

"github.com/argoproj/argo-rollouts/utils/defaults"
timeutil "github.com/argoproj/argo-rollouts/utils/time"

log "github.com/sirupsen/logrus"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/api/errors"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
patchtypes "k8s.io/apimachinery/pkg/types"
Expand All @@ -20,10 +18,12 @@ import (

"github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1"
"github.com/argoproj/argo-rollouts/utils/conditions"
"github.com/argoproj/argo-rollouts/utils/defaults"
experimentutil "github.com/argoproj/argo-rollouts/utils/experiment"
logutil "github.com/argoproj/argo-rollouts/utils/log"
"github.com/argoproj/argo-rollouts/utils/record"
replicasetutil "github.com/argoproj/argo-rollouts/utils/replicaset"
timeutil "github.com/argoproj/argo-rollouts/utils/time"
)

const (
Expand Down Expand Up @@ -268,7 +268,11 @@ func (ec *experimentContext) scaleReplicaSetAndRecordEvent(rs *appsv1.ReplicaSet
}
scaled, newRS, err := ec.scaleReplicaSet(rs, newScale, scalingOperation)
if err != nil {
// TODO(jessesuen): gracefully handle conflict issues
if !k8serrors.IsConflict(err) {
ec.log.Warnf("Retrying ReplicaSet '%s' scaling: %s", rs.Name, err)
ec.enqueueExperimentAfter(ec.ex, time.Second)
return false, nil, nil
}
msg := fmt.Sprintf("Failed to scale %s %s: %v", rs.Name, scalingOperation, err)
ec.recorder.Warnf(ec.ex, record.EventOptions{EventReason: "ReplicaSetUpdateError"}, msg)
} else {
Expand Down

0 comments on commit 417b390

Please sign in to comment.