Skip to content

Commit

Permalink
Fix comments
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Sch <[email protected]>
  • Loading branch information
SchSeba committed Sep 26, 2023
1 parent 835f5ac commit 0399543
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions pkg/utils/mock/mock_store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pkg/utils/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
//go:generate ../../bin/mockgen -destination mock/mock_store.go -source store.go
type StoreManagerInterface interface {
ClearPCIAddressFolder() error
SaveLastPfAppliedStatus(pciAddress string, PfInfo *sriovnetworkv1.Interface) error
SaveLastPfAppliedStatus(PfInfo *sriovnetworkv1.Interface) error
LoadPfsStatus(pciAddress string) (*sriovnetworkv1.Interface, bool, error)
}

Expand Down Expand Up @@ -82,7 +82,7 @@ func (s *StoreManager) ClearPCIAddressFolder() error {
if os.IsNotExist(err) {
return nil
}
return fmt.Errorf("failed to check the pci address folder path %s", PfAppliedConfigUse)
return fmt.Errorf("failed to check the pci address folder path %s: %v", PfAppliedConfigUse, err)
}

err = os.RemoveAll(PfAppliedConfigUse)
Expand All @@ -100,15 +100,15 @@ func (s *StoreManager) ClearPCIAddressFolder() error {

// SaveLastPfAppliedStatus will save the PF object as a json into the /etc/sriov-operator/pci/<pci-address>
// this function must be called after running the chroot function
func (s *StoreManager) SaveLastPfAppliedStatus(pciAddress string, PfInfo *sriovnetworkv1.Interface) error {
func (s *StoreManager) SaveLastPfAppliedStatus(PfInfo *sriovnetworkv1.Interface) error {
data, err := json.Marshal(PfInfo)
if err != nil {
glog.Errorf("failed to marshal PF status %+v: %v", *PfInfo, err)
return err
}

hostExtension := getHostExtension(s.RunOnHost)
pathFile := filepath.Join(hostExtension, PfAppliedConfig, pciAddress)
pathFile := filepath.Join(hostExtension, PfAppliedConfig, PfInfo.PciAddress)
err = os.WriteFile(pathFile, data, 0644)
return err
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ func DiscoverSriovDevices(withUnsupported bool, storeManager StoreManagerInterfa
pfStatus, exist, err := storeManager.LoadPfsStatus(iface.PciAddress)
if err != nil {
glog.Warningf("DiscoverSriovDevices(): failed to load PF status from disk: %v", err)
}

if exist {
iface.ExternallyManaged = pfStatus.ExternallyManaged
} else {
if exist {
iface.ExternallyManaged = pfStatus.ExternallyManaged
}
}

if dputils.IsSriovPF(device.Address) {
Expand Down Expand Up @@ -196,7 +196,7 @@ func ConfigSriovInterfaces(interfaces []sriovnetworkv1.Interface, ifaceStatuses
glog.V(2).Infof("syncNodeState(): no need update interface %s", iface.PciAddress)

// Save the PF status to the host
err = storeManager.SaveLastPfAppliedStatus(iface.PciAddress, &iface)
err = storeManager.SaveLastPfAppliedStatus(&iface)
if err != nil {
glog.Errorf("SyncNodeState(): failed to save PF applied config to host: %v", err)
return err
Expand All @@ -217,7 +217,7 @@ func ConfigSriovInterfaces(interfaces []sriovnetworkv1.Interface, ifaceStatuses
}

// Save the PF status to the host
err = storeManager.SaveLastPfAppliedStatus(iface.PciAddress, &iface)
err = storeManager.SaveLastPfAppliedStatus(&iface)
if err != nil {
glog.Errorf("SyncNodeState(): failed to save PF applied config to host: %v", err)
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func validatePolicyForNodeState(policy *sriovnetworkv1.SriovNetworkNodePolicy, s
}

if policy.Spec.LinkType != "" && strings.ToLower(policy.Spec.LinkType) != strings.ToLower(iface.LinkType) {
return fmt.Errorf("LinkType(%d) in CR %s is not equal to the LinkType for the PF externally value(%d)", policy.Spec.Mtu, policy.GetName(), iface.Mtu)
return fmt.Errorf("LinkType(%s) in CR %s is not equal to the LinkType for the PF externally value(%s)", policy.Spec.LinkType, policy.GetName(), iface.LinkType)
}
}
// vdpa: only mellanox cards are supported
Expand Down

0 comments on commit 0399543

Please sign in to comment.