Skip to content

Commit

Permalink
Allow to set additional fields for the admin client logger (#1714)
Browse files Browse the repository at this point in the history
  • Loading branch information
johscheuer authored Jul 4, 2023
1 parent 5d08896 commit 9325541
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
20 changes: 20 additions & 0 deletions fdbclient/admin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,3 +728,23 @@ func (client *cliAdminClient) GetCoordinatorSet() (map[string]fdbv1beta2.None, e
func (client *cliAdminClient) SetKnobs(knobs []string) {
client.knobs = knobs
}

// WithValues will update the logger used by the current AdminClient to contain the provided key value pairs. The provided
// arguments must be even.
func (client *cliAdminClient) WithValues(keysAndValues ...interface{}) {
newLogger := client.log.WithValues(keysAndValues...)
client.log = newLogger

// Update the FDB library client logger
realFdbClient, ok := client.fdbLibClient.(*realFdbLibClient)
if ok {
realFdbClient.logger = newLogger
}

// Update the command runner logger
cmdRunner, ok := client.cmdRunner.(*realCommandRunner)
if !ok {
return
}
cmdRunner.log = newLogger
}
14 changes: 9 additions & 5 deletions pkg/fdbadminclient/admin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import (
// AdminClient describes an interface for running administrative commands on a
// cluster
type AdminClient interface {
// GetStatus gets the database's status
// GetStatus gets the database's status.
GetStatus() (*fdbv1beta2.FoundationDBStatus, error)

// ConfigureDatabase sets the database configuration
// ConfigureDatabase sets the database configuration.
ConfigureDatabase(configuration fdbv1beta2.DatabaseConfiguration, newDatabase bool, version string) error

// ExcludeProcesses starts evacuating processes so that they can be removed
Expand Down Expand Up @@ -103,12 +103,16 @@ type AdminClient interface {
// SetKnobs sets the Knobs that should be used for the commandline call.
SetKnobs([]string)

// GetMaintenanceZone gets current maintenance zone, if any
// GetMaintenanceZone gets current maintenance zone, if any.
GetMaintenanceZone() (string, error)

// SetMaintenanceZone places zone into maintenance mode
// SetMaintenanceZone places zone into maintenance mode.
SetMaintenanceZone(zone string, timeoutSeconds int) error

// Reset maintenance mode
// ResetMaintenanceMode resets the maintenance mode.
ResetMaintenanceMode() error

// WithValues will update the logger used by the current AdminClient to contain the provided key value pairs. The provided
// arguments must be even.
WithValues(keysAndValues ...interface{})
}
4 changes: 4 additions & 0 deletions pkg/fdbadminclient/mock/admin_client_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -1018,3 +1018,7 @@ func (client *AdminClient) GetWorstDurabilityLag() (fdbv1beta2.FoundationDBStatu
lagInfo, ok := client.LagInfo["worstDurabilityLag"]
return lagInfo, ok
}

// WithValues will update the logger used by the current AdminClient to contain the provided key value pairs. The provided
// arguments must be even.
func (client *AdminClient) WithValues(_ ...interface{}) {}

0 comments on commit 9325541

Please sign in to comment.