Skip to content

Commit

Permalink
chore: add spec.ConfigDaemonEnvVars to the SriovOperatorConfig
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Giese <[email protected]>
  • Loading branch information
tobiasgiese committed Jul 15, 2024
1 parent 74568ed commit 7192b84
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 3 deletions.
2 changes: 2 additions & 0 deletions api/v1/sriovoperatorconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ type SriovOperatorConfigSpec struct {
DisablePlugins PluginNameSlice `json:"disablePlugins,omitempty"`
// FeatureGates to enable experimental features
FeatureGates map[string]bool `json:"featureGates,omitempty"`
// ConfigDaemonEnvVars specifies a set of environment variables to be passed to the sriov-network-config-daemon.
ConfigDaemonEnvVars map[string]string `json:"configDaemonEnvVars,omitempty"`
}

// SriovOperatorConfigStatus defines the observed state of SriovOperatorConfig
Expand Down
4 changes: 4 additions & 0 deletions bindata/manifests/daemon/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ spec:
value: "{{.ClusterType}}"
- name: DEV_MODE
value: "{{.DevMode}}"
{{- range $key, $value := .ConfigDaemonEnvVars }}
- name: "{{$key}}"
value: "{{$value}}"
{{- end }}
resources:
requests:
cpu: 100m
Expand Down
4 changes: 4 additions & 0 deletions cmd/sriov-network-config-daemon/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ func runStartCmd(cmd *cobra.Command, args []string) error {

vars.ParallelNicConfig = startOpts.parallelNicConfig

if strings.ToLower(os.Getenv("MLX_PLUGIN_FW_RESET")) == "true" {
vars.MlxFWReset = true
}

if startOpts.nodeName == "" {
name, ok := os.LookupEnv("NODE_NAME")
if !ok || name == "" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ spec:
spec:
description: SriovOperatorConfigSpec defines the desired state of SriovOperatorConfig
properties:
configDaemonEnvVars:
additionalProperties:
type: string
description: ConfigDaemonEnvVars specifies a set of environment variables
to be passed to the sriov-network-config-daemon.
type: object
configDaemonNodeSelector:
additionalProperties:
type: string
Expand Down
1 change: 1 addition & 0 deletions controllers/sriovoperatorconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func (r *SriovOperatorConfigReconciler) syncConfigDaemonSet(ctx context.Context,
data.Data["UsedSystemdMode"] = false
}
data.Data["ParallelNicConfig"] = r.FeatureGate.IsEnabled(consts.ParallelNicConfigFeatureGate)
data.Data["ConfigDaemonEnvVars"] = dc.Spec.ConfigDaemonEnvVars

envCniBinPath := os.Getenv("SRIOV_CNI_BIN_PATH")
if envCniBinPath == "" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ spec:
spec:
description: SriovOperatorConfigSpec defines the desired state of SriovOperatorConfig
properties:
configDaemonEnvVars:
additionalProperties:
type: string
description: ConfigDaemonEnvVars specifies a set of environment variables
to be passed to the sriov-network-config-daemon.
type: object
configDaemonNodeSelector:
additionalProperties:
type: string
Expand Down
10 changes: 7 additions & 3 deletions pkg/plugins/mellanox/mellanox_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/helper"
plugin "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/plugins"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars"
mlx "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vendors/mellanox"
)

Expand Down Expand Up @@ -190,9 +191,12 @@ func (p *MellanoxPlugin) Apply() error {
return nil
}
log.Log.Info("mellanox plugin Apply()")
err := p.helpers.MlxResetFW(pciAddressesToChange)
if err != nil {
return err
// Only mstfwreset if the featuregate is enabled.
if vars.MlxFWReset {
err := p.helpers.MlxResetFW(pciAddressesToChange)
if err != nil {
return err
}
}
return p.helpers.MlxConfigFW(attributesToChange)
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/vars/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ var (
// ParallelNicConfig global variable to perform NIC configuration in parallel
ParallelNicConfig = false

// MlxFWReset global variable enables mstfwreset before rebooting a node on VF changes
MlxFWReset = false

// FilesystemRoot used by test to mock interactions with filesystem
FilesystemRoot = ""

Expand Down

0 comments on commit 7192b84

Please sign in to comment.