Skip to content

Commit

Permalink
add pantheon migration state
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherzli committed Aug 16, 2024
1 parent 4397ac9 commit 278f1fa
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 239 deletions.
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ linters:
- perfsprint
- maligned
- gosec
<<<<<<< HEAD
- gocognit
=======
>>>>>>> 2753f3f (support az aware hashring and multiple sts in one hashring (#129))

linters-settings:
errcheck:
Expand Down
4 changes: 0 additions & 4 deletions .idea/thanos-receive-controller.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

225 changes: 0 additions & 225 deletions .idea/workspace.xml

This file was deleted.

15 changes: 14 additions & 1 deletion 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,7 +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.Parse()
flag.StringVar(&config.migrationState, "migration-state", "no-state", "[Databricks Internal] internal pantheon migration state info")

return config
}
Expand Down Expand Up @@ -160,6 +161,7 @@ func main() {
scaleTimeout: config.ScaleTimeout,
useAzAwareHashRing: config.useAzAwareHashRing,
podAzAnnotationKey: config.podAzAnnotationKey,
migrationState: config.migrationState,
}
c := newController(klient, logger, opt)
c.registerMetrics(reg)
Expand Down Expand Up @@ -346,6 +348,7 @@ type options struct {
scaleTimeout time.Duration
useAzAwareHashRing bool
podAzAnnotationKey string
migrationState string
}

type controller struct {
Expand All @@ -368,6 +371,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 +436,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 +457,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(0)
reg.MustRegister(
c.reconcileAttempts,
c.reconcileErrors,
Expand All @@ -455,6 +467,7 @@ func (c *controller) registerMetrics(reg *prometheus.Registry) {
c.configmapLastSuccessfulChangeTime,
c.hashringNodes,
c.hashringTenants,
c.pantheonMigrationState,
)
}
}
Expand Down

0 comments on commit 278f1fa

Please sign in to comment.