Skip to content

Commit

Permalink
[Multicast] Remove NetworkPolicyStats dependency of MulticastGroup API
Browse files Browse the repository at this point in the history
Fixes #5329

Signed-off-by: ceclinux <src655@gmail.com>
  • Loading branch information
ceclinux committed Aug 8, 2023
1 parent 8ac8a91 commit 56bbe4e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
6 changes: 0 additions & 6 deletions pkg/apiserver/registry/stats/multicastgroup/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ func (r *REST) NewList() runtime.Object {
}

func (r *REST) List(ctx context.Context, options *internalversion.ListOptions) (runtime.Object, error) {
if !features.DefaultFeatureGate.Enabled(features.NetworkPolicyStats) {
return &statsv1alpha1.MulticastGroupList{}, nil
}
if !features.DefaultFeatureGate.Enabled(features.Multicast) {
return &statsv1alpha1.MulticastGroupList{}, nil
}
Expand All @@ -85,9 +82,6 @@ func (r *REST) List(ctx context.Context, options *internalversion.ListOptions) (
}

func (r *REST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
if !features.DefaultFeatureGate.Enabled(features.NetworkPolicyStats) {
return &statsv1alpha1.MulticastGroup{}, nil
}
if !features.DefaultFeatureGate.Enabled(features.Multicast) {
return &statsv1alpha1.MulticastGroup{}, nil
}
Expand Down
41 changes: 29 additions & 12 deletions pkg/apiserver/registry/stats/multicastgroup/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,29 @@ func TestRESTList(t *testing.T) {
networkPolicyStatsEnabled bool
multicastEnabled bool
stats map[string]*statsv1alpha1.MulticastGroup
groupName string
expectedObj runtime.Object
}{
{
name: "NetworkPolicyStats feature disabled",
networkPolicyStatsEnabled: false,
groupName: group1.Name,
expectedObj: &statsv1alpha1.MulticastGroupList{},
multicastEnabled: true,
stats: map[string]*statsv1alpha1.MulticastGroup{
group1.Name: group1,
group2.Name: group2,
},
expectedObj: &statsv1alpha1.MulticastGroupList{
Items: []statsv1alpha1.MulticastGroup{*group1, *group2},
},
},
{
name: "Multicast feature disabled",
multicastEnabled: false,
groupName: group1.Name,
expectedObj: &statsv1alpha1.MulticastGroupList{},
name: "Multicast feature disabled",
networkPolicyStatsEnabled: true,
multicastEnabled: false,
stats: map[string]*statsv1alpha1.MulticastGroup{
group1.Name: group1,
group2.Name: group2,
},
expectedObj: &statsv1alpha1.MulticastGroupList{},
},
{
name: "empty group",
Expand Down Expand Up @@ -153,14 +162,22 @@ func TestRESTGet(t *testing.T) {
{
name: "NetworkPolicyStats feature disabled",
networkPolicyStatsEnabled: false,
multicastEnabled: true,
groupName: group1.Name,
expectedObj: &statsv1alpha1.MulticastGroup{},
groups: map[string]*statsv1alpha1.MulticastGroup{
group1.Name: group1,
},
expectedObj: group1,
},
{
name: "Multicast feature disabled",
multicastEnabled: false,
groupName: group1.Name,
expectedObj: &statsv1alpha1.MulticastGroup{},
name: "Multicast feature disabled",
networkPolicyStatsEnabled: true,
multicastEnabled: false,
groupName: group1.Name,
groups: map[string]*statsv1alpha1.MulticastGroup{
group1.Name: group1,
},
expectedObj: &statsv1alpha1.MulticastGroup{},
},
{
name: "group not found",
Expand Down

0 comments on commit 56bbe4e

Please sign in to comment.