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

add pantheon migration state metrics #4

Merged
merged 5 commits into from
Aug 19, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type CmdConfig struct {
ScaleTimeout time.Duration
useAzAwareHashRing bool
podAzAnnotationKey string
migrationState string
}

func parseFlags() CmdConfig {
Expand All @@ -98,6 +99,7 @@ func parseFlags() CmdConfig {
flag.DurationVar(&config.ScaleTimeout, "scale-timeout", defaultScaleTimeout, "A timeout to wait for receivers to really start after they report healthy")
flag.BoolVar(&config.useAzAwareHashRing, "use-az-aware-hashring", false, "A boolean to use az aware hashring to comply with Thanos v0.32+")
flag.StringVar(&config.podAzAnnotationKey, "pod-az-annotation-key", "", "pod annotation key for AZ Info, If not specified or key not found, will use sts name as AZ key")
flag.StringVar(&config.migrationState, "migration-state", "no-state", "[Databricks Internal] internal pantheon migration state info")
flag.Parse()

return config
Expand Down Expand Up @@ -160,7 +162,9 @@ func main() {
scaleTimeout: config.ScaleTimeout,
useAzAwareHashRing: config.useAzAwareHashRing,
podAzAnnotationKey: config.podAzAnnotationKey,
migrationState: config.migrationState,
}

c := newController(klient, logger, opt)
c.registerMetrics(reg)
done := make(chan struct{})
Expand Down Expand Up @@ -346,6 +350,7 @@ type options struct {
scaleTimeout time.Duration
useAzAwareHashRing bool
podAzAnnotationKey string
migrationState string
}

type controller struct {
Expand All @@ -368,6 +373,7 @@ type controller struct {
configmapLastSuccessfulChangeTime prometheus.Gauge
hashringNodes *prometheus.GaugeVec
hashringTenants *prometheus.GaugeVec
pantheonMigrationState *prometheus.GaugeVec
}

func newController(klient kubernetes.Interface, logger log.Logger, o *options) *controller {
Expand Down Expand Up @@ -432,6 +438,13 @@ func newController(klient kubernetes.Interface, logger log.Logger, o *options) *
},
[]string{"name"},
),
pantheonMigrationState: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "thanos_receive_controller_pantheon_migration_state",
Help: "pantheon migration state",
},
[]string{"migration_state"},
),
}
}

Expand All @@ -446,6 +459,7 @@ func (c *controller) registerMetrics(reg *prometheus.Registry) {
c.configmapChangeErrors.WithLabelValues(create).Add(0)
c.configmapChangeErrors.WithLabelValues(update).Add(0)
c.configmapChangeErrors.WithLabelValues(other).Add(0)
c.pantheonMigrationState.WithLabelValues(c.options.migrationState).Add(1)
reg.MustRegister(
c.reconcileAttempts,
c.reconcileErrors,
Expand All @@ -455,6 +469,7 @@ func (c *controller) registerMetrics(reg *prometheus.Registry) {
c.configmapLastSuccessfulChangeTime,
c.hashringNodes,
c.hashringTenants,
c.pantheonMigrationState,
)
}
}
Expand Down
1 change: 1 addition & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@ func TestControllerWithAzAware(t *testing.T) {
port: port,
scheme: "http",
useAzAwareHashRing: true,
migrationState: "hello",
}
klient := fake.NewSimpleClientset()
cleanUp := setupController(ctx, t, klient, opts)
Expand Down
Loading