Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes race condition when deleting alertmanager, prometheus and thanosruler instances #5954

Merged
merged 3 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/alertmanager/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,11 @@ func (c *Operator) sync(ctx context.Context, key string) error {
return fmt.Errorf("failed to set Alertmanager type information: %w", err)
}

// Check if the Alertmanager instance is marked for deletion.
if c.rr.DeletionInProgress(am) {
return nil
}

if am.Spec.Paused {
return nil
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/prometheus/agent/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,12 @@ func (c *Operator) sync(ctx context.Context, key string) error {
}

logger := log.With(c.logger, "key", key)

// Check if the Agent instance is marked for deletion.
if c.rr.DeletionInProgress(p) {
return nil
}

if p.Spec.Paused {
level.Info(logger).Log("msg", "the resource is paused, not reconciling")
return nil
Expand Down
5 changes: 5 additions & 0 deletions pkg/prometheus/server/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,11 @@ func (c *Operator) sync(ctx context.Context, key string) error {
logger := log.With(c.logger, "key", key)
logDeprecatedFields(logger, p)

// Check if the Prometheus instance is marked for deletion.
if c.rr.DeletionInProgress(p) {
return nil
}

if err := operator.CheckStorageClass(ctx, c.canReadStorageClass, c.kclient, p.Spec.Storage); err != nil {
return err
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/thanos/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,11 @@ func (o *Operator) sync(ctx context.Context, key string) error {
return errors.Wrap(err, "failed to set ThanosRuler type information")
}

// Check if the Thanos instance is marked for deletion.
if o.rr.DeletionInProgress(tr) {
return nil
}

if tr.Spec.Paused {
return nil
}
Expand Down