-
Notifications
You must be signed in to change notification settings - Fork 21
HYPERFLEET-856 - feat: add deletion observability metrics and alerts #115
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| {{- if .Values.prometheusRule.enabled }} | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: PrometheusRule | ||
| metadata: | ||
| name: {{ include "hyperfleet-api.fullname" . }} | ||
| namespace: {{ .Values.prometheusRule.namespace | default .Release.Namespace }} | ||
| labels: | ||
| {{- include "hyperfleet-api.labels" . | nindent 4 }} | ||
| {{- with .Values.prometheusRule.labels }} | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| spec: | ||
| groups: | ||
| - name: hyperfleet-api-deletion | ||
| rules: | ||
| - alert: HyperFleetResourceDeletionStuckWarning | ||
| expr: max by (namespace, resource_type)(hyperfleet_api_resource_pending_deletion_stuck) > 0 | ||
| for: {{ .Values.prometheusRule.rules.deletionStuck.for | default "5m" }} | ||
| labels: | ||
| severity: warning | ||
| annotations: | ||
| summary: "HyperFleet resources stuck in Pending Deletion state" | ||
| description: >- | ||
| {{ "{{ $value }}" }} {{ "{{ $labels.resource_type }}" }} resource(s) have been in | ||
| Pending Deletion state for more than {{ .Values.config.metrics.deletion_stuck_threshold | default "30m" }} | ||
| (stuck threshold) + {{ .Values.prometheusRule.rules.deletionStuck.for | default "5m" }} (alert delay). | ||
| runbook_url: {{ .Values.prometheusRule.rules.deletionStuck.runbookUrl | default "" | quote }} | ||
| - alert: HyperFleetResourceDeletionStuckCritical | ||
| expr: max by (namespace, resource_type)(hyperfleet_api_resource_pending_deletion_stuck) > 0 | ||
| for: {{ .Values.prometheusRule.rules.deletionTimeout.for | default "30m" }} | ||
| labels: | ||
| severity: critical | ||
| annotations: | ||
| summary: "HyperFleet resources timed out in Pending Deletion state" | ||
| description: >- | ||
| {{ "{{ $value }}" }} {{ "{{ $labels.resource_type }}" }} resource(s) have been in | ||
| Pending Deletion state for more than {{ .Values.config.metrics.deletion_stuck_threshold | default "30m" }} | ||
| (stuck threshold) + {{ .Values.prometheusRule.rules.deletionTimeout.for | default "30m" }} (alert delay). Immediate investigation required. | ||
| runbook_url: {{ .Values.prometheusRule.rules.deletionTimeout.runbookUrl | default "" | quote }} | ||
| {{- end }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package migrations | ||
|
|
||
| import ( | ||
| "gorm.io/gorm" | ||
|
|
||
| "github.com/go-gormigrate/gormigrate/v2" | ||
| ) | ||
|
|
||
| func addDeletedTimeIndexes() *gormigrate.Migration { | ||
| return &gormigrate.Migration{ | ||
| ID: "202604290001", | ||
| Migrate: func(tx *gorm.DB) error { | ||
| // Partial indexes for metrics collector queries: | ||
| // SELECT COUNT(*) FROM clusters WHERE deleted_time IS NOT NULL AND deleted_time < $1 | ||
| // SELECT COUNT(*) FROM node_pools WHERE deleted_time IS NOT NULL AND deleted_time < $1 | ||
| if err := tx.Exec("CREATE INDEX IF NOT EXISTS idx_clusters_deleted_time ON clusters(deleted_time) WHERE deleted_time IS NOT NULL;").Error; err != nil { //nolint:lll | ||
| return err | ||
| } | ||
| if err := tx.Exec("CREATE INDEX IF NOT EXISTS idx_node_pools_deleted_time ON node_pools(deleted_time) WHERE deleted_time IS NOT NULL;").Error; err != nil { //nolint:lll | ||
| return err | ||
| } | ||
| return nil | ||
| }, | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,6 +35,7 @@ var MigrationList = []*gormigrate.Migration{ | |||||||||||||||||
| addSoftDeleteSchema(), | ||||||||||||||||||
| addNodePoolOwnerDeletedIndex(), | ||||||||||||||||||
| addReconciledIndex(), | ||||||||||||||||||
| addDeletedTimeIndexes(), | ||||||||||||||||||
|
Comment on lines
+35
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Migration registration order is not ascending
Proposed fix addSoftDeleteSchema(),
- addNodePoolOwnerDeletedIndex(),
addReconciledIndex(),
+ addNodePoolOwnerDeletedIndex(),
addDeletedTimeIndexes(),📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| // Model represents the base model struct. All entities will have this struct embedded. | ||||||||||||||||||
|
|
||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.