Skip to content

Commit 9325541

Browse files
authored
Allow to set additional fields for the admin client logger (#1714)
1 parent 5d08896 commit 9325541

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

fdbclient/admin_client.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,3 +728,23 @@ func (client *cliAdminClient) GetCoordinatorSet() (map[string]fdbv1beta2.None, e
728728
func (client *cliAdminClient) SetKnobs(knobs []string) {
729729
client.knobs = knobs
730730
}
731+
732+
// WithValues will update the logger used by the current AdminClient to contain the provided key value pairs. The provided
733+
// arguments must be even.
734+
func (client *cliAdminClient) WithValues(keysAndValues ...interface{}) {
735+
newLogger := client.log.WithValues(keysAndValues...)
736+
client.log = newLogger
737+
738+
// Update the FDB library client logger
739+
realFdbClient, ok := client.fdbLibClient.(*realFdbLibClient)
740+
if ok {
741+
realFdbClient.logger = newLogger
742+
}
743+
744+
// Update the command runner logger
745+
cmdRunner, ok := client.cmdRunner.(*realCommandRunner)
746+
if !ok {
747+
return
748+
}
749+
cmdRunner.log = newLogger
750+
}

pkg/fdbadminclient/admin_client.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ import (
2727
// AdminClient describes an interface for running administrative commands on a
2828
// cluster
2929
type AdminClient interface {
30-
// GetStatus gets the database's status
30+
// GetStatus gets the database's status.
3131
GetStatus() (*fdbv1beta2.FoundationDBStatus, error)
3232

33-
// ConfigureDatabase sets the database configuration
33+
// ConfigureDatabase sets the database configuration.
3434
ConfigureDatabase(configuration fdbv1beta2.DatabaseConfiguration, newDatabase bool, version string) error
3535

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

106-
// GetMaintenanceZone gets current maintenance zone, if any
106+
// GetMaintenanceZone gets current maintenance zone, if any.
107107
GetMaintenanceZone() (string, error)
108108

109-
// SetMaintenanceZone places zone into maintenance mode
109+
// SetMaintenanceZone places zone into maintenance mode.
110110
SetMaintenanceZone(zone string, timeoutSeconds int) error
111111

112-
// Reset maintenance mode
112+
// ResetMaintenanceMode resets the maintenance mode.
113113
ResetMaintenanceMode() error
114+
115+
// WithValues will update the logger used by the current AdminClient to contain the provided key value pairs. The provided
116+
// arguments must be even.
117+
WithValues(keysAndValues ...interface{})
114118
}

pkg/fdbadminclient/mock/admin_client_mock.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,3 +1018,7 @@ func (client *AdminClient) GetWorstDurabilityLag() (fdbv1beta2.FoundationDBStatu
10181018
lagInfo, ok := client.LagInfo["worstDurabilityLag"]
10191019
return lagInfo, ok
10201020
}
1021+
1022+
// WithValues will update the logger used by the current AdminClient to contain the provided key value pairs. The provided
1023+
// arguments must be even.
1024+
func (client *AdminClient) WithValues(_ ...interface{}) {}

0 commit comments

Comments
 (0)