Skip to content

Commit

Permalink
sriov pkg: Renamed CleanAllPoolConfigs func (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenLevin authored May 16, 2024
1 parent 4333130 commit 9d5d447
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pkg/sriov/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func TestListPoolConfigs(t *testing.T) {
}
}

func TestCleanAllNonDefaultPoolConfigs(t *testing.T) {
func TestCleanPoolConfigs(t *testing.T) {
testCases := []struct {
poolConfigs []*PoolConfigBuilder
operatorNamespace string
Expand All @@ -414,7 +414,7 @@ func TestCleanAllNonDefaultPoolConfigs(t *testing.T) {
_, _ = poolConfig.Create()
}

err := CleanAllNonDefaultPoolConfigs(testCase.poolConfigs[0].apiClient, testCase.operatorNamespace)
err := CleanAllPoolConfigs(testCase.poolConfigs[0].apiClient, testCase.operatorNamespace)
assert.Equal(t, err, testCase.expectedError)

if testCase.expectedError == nil {
Expand Down
15 changes: 6 additions & 9 deletions pkg/sriov/poolconfiglist.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func ListPoolConfigs(apiClient *clients.Settings, namespace string) ([]*PoolConf
return poolConfigBuilderObjects, nil
}

// CleanAllNonDefaultPoolConfigs removes all sriovNetworkPoolConfigs that are not set as default.
func CleanAllNonDefaultPoolConfigs(
// CleanAllPoolConfigs removes all sriovNetworkPoolConfigs.
func CleanAllPoolConfigs(
apiClient *clients.Settings, operatornsname string) error {
glog.V(100).Infof("Cleaning up SriovNetworkPoolConfigs in the %s namespace", operatornsname)

Expand All @@ -65,15 +65,12 @@ func CleanAllNonDefaultPoolConfigs(
}

for _, poolConfig := range poolConfigs {
// The "default" sriovNetworkPoolConfig is both mandatory and the default option.
if poolConfig.Object.Name != "default" {
err = poolConfig.Delete()
err = poolConfig.Delete()

if err != nil {
glog.V(100).Infof("Failed to delete SriovNetworkPoolConfigs: %s", poolConfig.Object.Name)
if err != nil {
glog.V(100).Infof("Failed to delete SriovNetworkPoolConfigs: %s", poolConfig.Object.Name)

return err
}
return err
}
}

Expand Down

0 comments on commit 9d5d447

Please sign in to comment.