Skip to content

Commit

Permalink
chore: revert IsCompleted
Browse files Browse the repository at this point in the history
  • Loading branch information
kakcy committed Aug 6, 2024
1 parent a950b74 commit df69d39
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 22 deletions.
4 changes: 2 additions & 2 deletions pkg/autoops/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ func (s *AutoOpsService) UpdateAutoOpsRule(
return err
}

if autoOpsRule.IsCompleted() {
if autoOpsRule.IsFinished() || autoOpsRule.IsStopped() {
dt, err := statusAutoOpsRuleCompleted.WithDetails(&errdetails.LocalizedMessage{
Locale: localizer.GetLocale(),
Message: localizer.MustLocalize(locale.InvalidArgumentError),
Expand Down Expand Up @@ -1491,7 +1491,7 @@ func (s *AutoOpsService) checkIfHasAlreadyTriggered(
}
return false, dt.Err()
}
if autoOpsRule.IsCompleted() || autoOpsRule.Deleted {
if autoOpsRule.IsFinished() || autoOpsRule.IsStopped() || autoOpsRule.Deleted {
s.logger.Warn(
"Auto Ops Rule already triggered",
log.FieldsFromImcomingContext(ctx).AddFields(
Expand Down
4 changes: 0 additions & 4 deletions pkg/autoops/domain/auto_ops_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ func (a *AutoOpsRule) IsStopped() bool {
return a.AutoOpsStatus == proto.AutoOpsStatus_STOPPED
}

func (a *AutoOpsRule) IsCompleted() bool {
return a.IsFinished() || a.IsStopped()
}

func (a *AutoOpsRule) SetOpsType(opsType proto.OpsType) {
a.AutoOpsRule.OpsType = opsType
a.AutoOpsRule.UpdatedAt = time.Now().Unix()
Expand Down
12 changes: 0 additions & 12 deletions pkg/autoops/domain/auto_ops_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,18 +495,6 @@ func TestIsStopped(t *testing.T) {
assert.True(t, aor.IsStopped())
}

func TestIsCompleted(t *testing.T) {
t.Parallel()
aor := createAutoOpsRule(t)
assert.False(t, aor.IsCompleted())

aor.AutoOpsStatus = autoopsproto.AutoOpsStatus_STOPPED
assert.True(t, aor.IsCompleted())

aor.AutoOpsStatus = autoopsproto.AutoOpsStatus_FINISHED
assert.True(t, aor.IsCompleted())
}

func TestSetAutoOpsStatus(t *testing.T) {
t.Parallel()
aor := createAutoOpsRule(t)
Expand Down
2 changes: 1 addition & 1 deletion pkg/batch/jobs/opsevent/datetime_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (w *datetimeWatcher) Run(ctx context.Context) (lastErr error) {
}
for _, a := range autoOpsRules {
aor := &autoopsdomain.AutoOpsRule{AutoOpsRule: a}
if aor.IsCompleted() {
if aor.IsFinished() || aor.IsStopped() {
continue
}
executeClauseID, err := w.getExecuteClauseId(ctx, env.Id, aor)
Expand Down
2 changes: 1 addition & 1 deletion pkg/batch/jobs/opsevent/event_count_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (w *eventCountWatcher) Run(ctx context.Context) (lastErr error) {
}
for _, a := range autoOpsRules {
aor := &autoopsdomain.AutoOpsRule{AutoOpsRule: a}
if aor.IsCompleted() {
if aor.IsFinished() || aor.IsStopped() {
continue
}
executeId, err := w.getExecuteClauseId(ctx, env.Id, aor)
Expand Down
3 changes: 2 additions & 1 deletion pkg/batch/subscriber/processor/evaluation_events_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ func (u *evalEvtUpdater) linkOpsRulesByFeatureID(
for _, aor := range listAutoOpsRules {
r := &aodomain.AutoOpsRule{AutoOpsRule: aor}
// Ignore already triggered ops rules
if aor.FeatureId == featureID && !r.IsCompleted() {
if aor.FeatureId == featureID &&
!(r.IsFinished() || r.IsStopped()) {
rules = append(rules, aor)
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/batch/subscriber/processor/goal_events_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (u *evalGoalUpdater) linkOpsRulesByGoalID(
for _, aor := range listAutoOpsRules {
autoOpsRule := &aodomain.AutoOpsRule{AutoOpsRule: aor}
// We ignore the rules that are already triggered
if autoOpsRule.IsCompleted() {
if autoOpsRule.IsFinished() || autoOpsRule.IsStopped() {
continue
}
clauses, err := autoOpsRule.ExtractOpsEventRateClauses()
Expand Down

0 comments on commit df69d39

Please sign in to comment.