diff --git a/pkg/antctl/transform/networkpolicy/response.go b/pkg/antctl/transform/networkpolicy/response.go index 74a762a54c2..2825eb3b366 100644 --- a/pkg/antctl/transform/networkpolicy/response.go +++ b/pkg/antctl/transform/networkpolicy/response.go @@ -190,7 +190,7 @@ func (r EvaluationResponse) GetTableRow(_ int) []string { // Handle K8s NPs empty action field. "Allow" corresponds to a K8s NP // allow action, and "Isolate" corresponds to a drop action because of the // default isolation model. Otherwise, display the action field content. - action := "Allow" + action := "" if r.Response.Rule.Action != nil { action = string(*r.Response.Rule.Action) } else if r.Response.RuleIndex == math.MaxInt32 { diff --git a/pkg/antctl/transform/networkpolicy/response_test.go b/pkg/antctl/transform/networkpolicy/response_test.go index d2f4e4c348d..58a1677efca 100644 --- a/pkg/antctl/transform/networkpolicy/response_test.go +++ b/pkg/antctl/transform/networkpolicy/response_test.go @@ -182,7 +182,7 @@ func TestEvaluationResponseTransform(t *testing.T) { assert.Equal(t, []string{"NAME", "NAMESPACE", "POLICY-TYPE", "RULE-INDEX", "DIRECTION", "ACTION"}, test.GetTableHeader()) assert.False(t, test.SortRows()) assert.Equal(t, []string{"", "", "", "", "", ""}, test.GetTableRow(32)) - testDropAction := crdv1beta1.RuleActionDrop + testDropAction, testDefaultAction := crdv1beta1.RuleActionDrop, crdv1beta1.RuleActionAllow tests := []struct { name string @@ -198,7 +198,7 @@ func TestEvaluationResponseTransform(t *testing.T) { Name: "testK8s", }, RuleIndex: 10, - Rule: cpv1beta.RuleRef{Direction: cpv1beta.DirectionIn}, + Rule: cpv1beta.RuleRef{Direction: cpv1beta.DirectionIn, Action: &testDefaultAction}, }, expectedOutput: []string{"testK8s", "ns", "K8sNetworkPolicy", "10", "In", "Allow"}, }, diff --git a/pkg/controller/networkpolicy/endpoint_querier.go b/pkg/controller/networkpolicy/endpoint_querier.go index 561d8b696d4..564bade8ffd 100644 --- a/pkg/controller/networkpolicy/endpoint_querier.go +++ b/pkg/controller/networkpolicy/endpoint_querier.go @@ -192,10 +192,10 @@ func processEndpointAppliedRules(appliedPolicies []*antreatypes.NetworkPolicy, i for _, rule := range internalPolicy.Rules { if rule.Direction == controlplane.DirectionIn && !isSourceEndpoint { isolationRules = append(isolationRules, &antreatypes.RuleInfo{Policy: internalPolicy, Index: math.MaxInt32, - Rule: &controlplane.NetworkPolicyRule{Direction: rule.Direction, Name: rule.Name, Action: rule.Action}}) + Rule: &controlplane.NetworkPolicyRule{Direction: rule.Direction, Name: rule.Name}}) } else if rule.Direction == controlplane.DirectionOut && isSourceEndpoint { isolationRules = append(isolationRules, &antreatypes.RuleInfo{Policy: internalPolicy, Index: math.MaxInt32, - Rule: &controlplane.NetworkPolicyRule{Direction: rule.Direction, Name: rule.Name, Action: rule.Action}}) + Rule: &controlplane.NetworkPolicyRule{Direction: rule.Direction, Name: rule.Name}}) } } }