Skip to content

Commit

Permalink
chore: add feature gate MlxFWReset
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Giese <[email protected]>
  • Loading branch information
tobiasgiese committed Jul 12, 2024
1 parent 74568ed commit 83927ff
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
3 changes: 3 additions & 0 deletions bindata/manifests/daemon/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ spec:
{{- if .ParallelNicConfig }}
- --parallel-nic-config
{{- end }}
{{- if .MlxFWReset }}
- --mlx-fw-reset
{{- end }}
env:
- name: NODE_NAME
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions cmd/sriov-network-config-daemon/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ var (
systemd bool
disabledPlugins stringList
parallelNicConfig bool
mlxFWReset bool
}
)

Expand All @@ -94,6 +95,7 @@ func init() {
startCmd.PersistentFlags().BoolVar(&startOpts.systemd, "use-systemd-service", false, "use config daemon in systemd mode")
startCmd.PersistentFlags().VarP(&startOpts.disabledPlugins, "disable-plugins", "", "comma-separated list of plugins to disable")
startCmd.PersistentFlags().BoolVar(&startOpts.parallelNicConfig, "parallel-nic-config", false, "perform NIC configuration in parallel")
startCmd.PersistentFlags().BoolVar(&startOpts.mlxFWReset, "mlx-fw-reset", false, "enable Mellanox FW reset before reboot")
}

func runStartCmd(cmd *cobra.Command, args []string) error {
Expand All @@ -108,6 +110,7 @@ func runStartCmd(cmd *cobra.Command, args []string) error {
}

vars.ParallelNicConfig = startOpts.parallelNicConfig
vars.MlxFWReset = startOpts.mlxFWReset

if startOpts.nodeName == "" {
name, ok := os.LookupEnv("NODE_NAME")
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["MlxFWReset"] = r.FeatureGate.IsEnabled(consts.MellanoxFWResetFeatureGate)

envCniBinPath := os.Getenv("SRIOV_CNI_BIN_PATH")
if envCniBinPath == "" {
Expand Down
3 changes: 3 additions & 0 deletions pkg/consts/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ const (

// MetricsExporterFeatureGate: enable SriovNetworkMetricsExporter on the same node as where the config-daemon run
MetricsExporterFeatureGate = "metricsExporter"

// MellanoxFWResetFeatureGate: enables mstfwreset before rebooting a node on VF changes
MellanoxFWResetFeatureGate = "mlxFWReset"
)

const (
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 83927ff

Please sign in to comment.