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 dd89db6
Show file tree
Hide file tree
Showing 6 changed files with 16 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.

16 changes: 15 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,8 +99,8 @@ 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

Check failure on line 104 in main.go

View workflow job for this annotation

GitHub Actions / Lint (ubuntu-latest)

return statements should not be cuddled if block has more than two lines (wsl)
}

Expand Down Expand Up @@ -160,7 +161,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 +349,7 @@ type options struct {
scaleTimeout time.Duration
useAzAwareHashRing bool
podAzAnnotationKey string
migrationState string
}

type controller struct {
Expand All @@ -368,6 +372,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 +437,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 +458,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 +468,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

0 comments on commit dd89db6

Please sign in to comment.