diff --git a/cmd/node-disk-manager-webhook/main.go b/cmd/node-disk-manager-webhook/main.go index b4dcac38..cfbb6bb9 100644 --- a/cmd/node-disk-manager-webhook/main.go +++ b/cmd/node-disk-manager-webhook/main.go @@ -149,8 +149,6 @@ func runWebhookServer(ctx context.Context, cfg *rest.Config, options *config.Opt } func newCaches(ctx context.Context, cfg *rest.Config, threadiness int) (*resourceCaches, error) { - var starters []start.Starter // nolint: prealloc - disks, err := ctldisk.NewFactoryFromConfig(cfg) if err != nil { return nil, err @@ -168,6 +166,7 @@ func newCaches(ctx context.Context, cfg *rest.Config, threadiness int) (*resourc return nil, err } + starters := make([]start.Starter, 0, 4) starters = append(starters, disks, storageFactory, coreFactory, lhFactory) resourceCaches := &resourceCaches{ bdCache: disks.Harvesterhci().V1beta1().BlockDevice().Cache(), diff --git a/pkg/utils/command.go b/pkg/utils/command.go index eefb47e7..4c704e6e 100644 --- a/pkg/utils/command.go +++ b/pkg/utils/command.go @@ -46,14 +46,15 @@ func (exec *Executor) Execute(cmd string, args []string) (string, error) { command := cmd cmdArgs := args if exec.namespace != "" { - cmdArgs = []string{ // nolint: prealloc - "--mount=" + filepath.Join(exec.namespace, "mnt"), - "--net=" + filepath.Join(exec.namespace, "net"), - "--ipc=" + filepath.Join(exec.namespace, "ipc"), + cmdArgs = make([]string, 0, len(args)+4) + cmdArgs = append(cmdArgs, + "--mount="+filepath.Join(exec.namespace, "mnt"), + "--net="+filepath.Join(exec.namespace, "net"), + "--ipc="+filepath.Join(exec.namespace, "ipc"), cmd, - } - command = NSBinary + ) cmdArgs = append(cmdArgs, args...) + command = NSBinary } return execute(command, cmdArgs, exec.cmdTimeout) }