diff --git a/bindata/manifests/daemon/daemonset.yaml b/bindata/manifests/daemon/daemonset.yaml index b5126ae28e..7b45496a3b 100644 --- a/bindata/manifests/daemon/daemonset.yaml +++ b/bindata/manifests/daemon/daemonset.yaml @@ -127,6 +127,9 @@ spec: {{- if .ParallelNicConfig }} - --parallel-nic-config {{- end }} + {{- if .MlxFWReset }} + - --mlx-fw-reset + {{- end }} env: - name: NODE_NAME valueFrom: diff --git a/cmd/sriov-network-config-daemon/start.go b/cmd/sriov-network-config-daemon/start.go index 4311db11ba..fbebcd1ad0 100644 --- a/cmd/sriov-network-config-daemon/start.go +++ b/cmd/sriov-network-config-daemon/start.go @@ -84,6 +84,7 @@ var ( systemd bool disabledPlugins stringList parallelNicConfig bool + mlxFWReset bool } ) @@ -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 { @@ -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") diff --git a/controllers/sriovoperatorconfig_controller.go b/controllers/sriovoperatorconfig_controller.go index 6a5088a95c..dbeea51353 100644 --- a/controllers/sriovoperatorconfig_controller.go +++ b/controllers/sriovoperatorconfig_controller.go @@ -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 == "" { diff --git a/pkg/consts/constants.go b/pkg/consts/constants.go index 282f31adde..d32a0afeba 100644 --- a/pkg/consts/constants.go +++ b/pkg/consts/constants.go @@ -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 ( diff --git a/pkg/plugins/mellanox/mellanox_plugin.go b/pkg/plugins/mellanox/mellanox_plugin.go index 3aa6e26ab5..49c3f82f3e 100644 --- a/pkg/plugins/mellanox/mellanox_plugin.go +++ b/pkg/plugins/mellanox/mellanox_plugin.go @@ -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" ) @@ -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) } diff --git a/pkg/vars/vars.go b/pkg/vars/vars.go index 0d2b9a39da..f039220c88 100644 --- a/pkg/vars/vars.go +++ b/pkg/vars/vars.go @@ -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 = ""