fix(kv): log migration events at debug level to avoid spam (#20572)
parent
f6669f7512
commit
ebd37c8b9a
|
@ -7,7 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
influxdb "github.com/influxdata/influxdb/v2"
|
"github.com/influxdata/influxdb/v2"
|
||||||
"github.com/influxdata/influxdb/v2/kv"
|
"github.com/influxdata/influxdb/v2/kv"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -148,6 +148,11 @@ func (m *Migrator) Up(ctx context.Context) error {
|
||||||
return wrapErr(err)
|
return wrapErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
migrationsToDo := len(m.Specs[lastMigration:])
|
||||||
|
if migrationsToDo > 0 {
|
||||||
|
m.logger.Info("Bringing up metadata migrations", zap.Int("migration_count", migrationsToDo))
|
||||||
|
}
|
||||||
|
|
||||||
for idx, spec := range m.Specs[lastMigration:] {
|
for idx, spec := range m.Specs[lastMigration:] {
|
||||||
startedAt := m.now()
|
startedAt := m.now()
|
||||||
migration := Migration{
|
migration := Migration{
|
||||||
|
@ -218,7 +223,12 @@ func (m *Migrator) Down(ctx context.Context) (err error) {
|
||||||
return wrapErr(err)
|
return wrapErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := len(migrations) - 1; i >= 0; i-- {
|
migrationsToDo := len(migrations)
|
||||||
|
if migrationsToDo > 0 {
|
||||||
|
m.logger.Info("Tearing down metadata migrations", zap.Int("migration_count", migrationsToDo))
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := migrationsToDo - 1; i >= 0; i-- {
|
||||||
migration := migrations[i]
|
migration := migrations[i]
|
||||||
|
|
||||||
m.logMigrationEvent(DownMigrationState, migration.Migration, "started")
|
m.logMigrationEvent(DownMigrationState, migration.Migration, "started")
|
||||||
|
@ -238,7 +248,12 @@ func (m *Migrator) Down(ctx context.Context) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Migrator) logMigrationEvent(state MigrationState, mig Migration, event string) {
|
func (m *Migrator) logMigrationEvent(state MigrationState, mig Migration, event string) {
|
||||||
m.logger.Info(fmt.Sprintf("Migration %q %s (%s)", mig.Name, event, state))
|
m.logger.Debug(
|
||||||
|
"Executing metadata migration",
|
||||||
|
zap.String("migration_name", mig.Name),
|
||||||
|
zap.String("target_state", state.String()),
|
||||||
|
zap.String("migration_event", event),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Migrator) walk(ctx context.Context, store kv.Store, fn func(id influxdb.ID, m Migration)) error {
|
func (m *Migrator) walk(ctx context.Context, store kv.Store, fn func(id influxdb.ID, m Migration)) error {
|
||||||
|
|
Loading…
Reference in New Issue