Skip to content

Commit 8916894

Browse files
committed
remove internal logger in favour of klog
Signed-off-by: Tariq Ibrahim <tibrahim@nvidia.com>
1 parent 6f41f70 commit 8916894

File tree

6 files changed

+12
-53
lines changed

6 files changed

+12
-53
lines changed

api/config/v1/config.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"os"
2323

2424
cli "github.com/urfave/cli/v2"
25+
"k8s.io/klog/v2"
2526

2627
"sigs.k8s.io/yaml"
2728
)
@@ -79,26 +80,20 @@ func NewConfig(c *cli.Context, flags []cli.Flag) (*Config, error) {
7980
return config, nil
8081
}
8182

82-
// logger is used to issue warning in API functions without requiring an explicit implementation.
83-
type logger interface {
84-
Warning(...interface{})
85-
Warningf(string, ...interface{})
86-
}
87-
8883
// DisableResourceNamingInConfig temporarily disable the resource renaming feature of the plugin.
8984
// This may be reenabled in a future release.
90-
func DisableResourceNamingInConfig(logger logger, config *Config) {
85+
func DisableResourceNamingInConfig(config *Config) {
9186
// Disable resource renaming through config.Resource
9287
if len(config.Resources.GPUs) > 0 || len(config.Resources.MIGs) > 0 {
93-
logger.Warning("Customizing the 'resources' field is not yet supported in the config. Ignoring...")
88+
klog.Warning("Customizing the 'resources' field is not yet supported in the config. Ignoring...")
9489
}
9590
config.Resources.GPUs = nil
9691
config.Resources.MIGs = nil
9792

9893
// Disable renaming / device selection in Sharing.TimeSlicing.Resources
99-
config.Sharing.TimeSlicing.disableResoureRenaming(logger, "timeSlicing")
94+
config.Sharing.TimeSlicing.disableResoureRenaming("timeSlicing")
10095
// Disable renaming / device selection in Sharing.MPS.Resources
101-
config.Sharing.MPS.disableResoureRenaming(logger, "mps")
96+
config.Sharing.MPS.disableResoureRenaming("mps")
10297
}
10398

10499
// parseConfig parses a config file as either YAML of JSON and unmarshals it into a Config struct.

api/config/v1/replicas.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"strings"
2424

2525
"github.com/google/uuid"
26+
"k8s.io/klog/v2"
2627
)
2728

2829
// ReplicatedResources defines generic options for replicating devices.
@@ -32,7 +33,7 @@ type ReplicatedResources struct {
3233
Resources []ReplicatedResource `json:"resources,omitempty" yaml:"resources,omitempty"`
3334
}
3435

35-
func (rrs *ReplicatedResources) disableResoureRenaming(logger logger, id string) {
36+
func (rrs *ReplicatedResources) disableResoureRenaming(id string) {
3637
if rrs == nil {
3738
return
3839
}
@@ -56,10 +57,10 @@ func (rrs *ReplicatedResources) disableResoureRenaming(logger logger, id string)
5657
}
5758
}
5859
if setsNonDefaultRename {
59-
logger.Warningf("Setting the 'rename' field in sharing.%s.resources is not yet supported in the config. Ignoring...", id)
60+
klog.Warningf("Setting the 'rename' field in sharing.%s.resources is not yet supported in the config. Ignoring...", id)
6061
}
6162
if setsDevices {
62-
logger.Warningf("Customizing the 'devices' field in sharing.%s.resources is not yet supported in the config. Ignoring...", id)
63+
klog.Warningf("Customizing the 'devices' field in sharing.%s.resources is not yet supported in the config. Ignoring...", id)
6364
}
6465

6566
}

cmd/gpu-feature-discovery/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"github.com/NVIDIA/k8s-device-plugin/internal/flags"
2222
"github.com/NVIDIA/k8s-device-plugin/internal/info"
2323
"github.com/NVIDIA/k8s-device-plugin/internal/lm"
24-
"github.com/NVIDIA/k8s-device-plugin/internal/logger"
2524
"github.com/NVIDIA/k8s-device-plugin/internal/resource"
2625
"github.com/NVIDIA/k8s-device-plugin/internal/vgpu"
2726
"github.com/NVIDIA/k8s-device-plugin/internal/watch"
@@ -170,7 +169,7 @@ func start(c *cli.Context, cfg *Config) error {
170169
if err != nil {
171170
return fmt.Errorf("unable to load config: %v", err)
172171
}
173-
spec.DisableResourceNamingInConfig(logger.ToKlog, config)
172+
spec.DisableResourceNamingInConfig(config)
174173

175174
// Print the config to the output.
176175
configJSON, err := json.MarshalIndent(config, "", " ")

cmd/mps-control-daemon/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
"github.com/NVIDIA/k8s-device-plugin/cmd/mps-control-daemon/mount"
3535
"github.com/NVIDIA/k8s-device-plugin/cmd/mps-control-daemon/mps"
3636
"github.com/NVIDIA/k8s-device-plugin/internal/info"
37-
"github.com/NVIDIA/k8s-device-plugin/internal/logger"
3837
"github.com/NVIDIA/k8s-device-plugin/internal/rm"
3938
"github.com/NVIDIA/k8s-device-plugin/internal/watch"
4039

@@ -169,7 +168,7 @@ func startDaemons(c *cli.Context, cfg *Config) ([]*mps.Daemon, bool, error) {
169168
if err != nil {
170169
return nil, false, fmt.Errorf("unable to load config: %v", err)
171170
}
172-
spec.DisableResourceNamingInConfig(logger.ToKlog, config)
171+
spec.DisableResourceNamingInConfig(config)
173172

174173
nvmllib := nvml.New()
175174
devicelib := device.New(nvmllib)

cmd/nvidia-device-plugin/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535

3636
spec "github.com/NVIDIA/k8s-device-plugin/api/config/v1"
3737
"github.com/NVIDIA/k8s-device-plugin/internal/info"
38-
"github.com/NVIDIA/k8s-device-plugin/internal/logger"
3938
"github.com/NVIDIA/k8s-device-plugin/internal/plugin"
4039
"github.com/NVIDIA/k8s-device-plugin/internal/rm"
4140
"github.com/NVIDIA/k8s-device-plugin/internal/watch"
@@ -319,7 +318,7 @@ func startPlugins(c *cli.Context, o *options) ([]plugin.Interface, bool, error)
319318
if err != nil {
320319
return nil, false, fmt.Errorf("unable to load config: %v", err)
321320
}
322-
spec.DisableResourceNamingInConfig(logger.ToKlog, config)
321+
spec.DisableResourceNamingInConfig(config)
323322

324323
driverRoot := root(*config.Flags.Plugin.ContainerDriverRoot)
325324
// We construct an NVML library specifying the path to libnvidia-ml.so.1

internal/logger/klog.go

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)