Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NetworkPolicy rule name in Traceflow observation #5667

Merged
merged 1 commit into from
Nov 17, 2023

Conversation

Atish-iaf
Copy link
Contributor

@Atish-iaf Atish-iaf commented Nov 3, 2023

Add NetworkPolicy rule name in Traceflow observation.

Update Traceflow e2e tests to verify "NetworkPolicy" and "NetworkPolicyRule"
in Traceflow observation.

Signed-off-by: Kumar Atish atish.iaf@gmail.com

@Atish-iaf Atish-iaf marked this pull request as ready for review November 4, 2023 06:00
@gran-vmv gran-vmv added this to the Antrea v1.15 release milestone Nov 6, 2023
@gran-vmv gran-vmv added area/ops/traceflow Issues or PRs related to the Traceflow feature kind/feature Categorizes issue or PR as related to a new feature. labels Nov 6, 2023
Copy link
Contributor

@gran-vmv gran-vmv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Could you update e2e cases to verify this section?

@@ -1135,6 +1135,8 @@ type Observation struct {
DstMAC string `json:"dstMAC,omitempty" yaml:"dstMAC,omitempty"`
// NetworkPolicy is the combination of Namespace and NetworkPolicyName.
NetworkPolicy string `json:"networkPolicy,omitempty" yaml:"networkPolicy,omitempty"`
// NetworkPolicyRule is the name of an ingress or an egress rule in NetworkPolicy.
NetworkPolicyRule string `json:"networkPolicyRule,omitempty" yaml:"networkPolicyRule,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are introducing new attribute NetworkPolicyRule in "v1beta1" but not in "v1alpha1," it's essential to provide clear documentation about this difference to avoid confusion. Users of "v1alpha1" should be aware that the attribute is not available in that version, and they may need to upgrade their CRDs to "v1beta1" if they want to use the new feature.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll make it clear in the release notes. Is there any other documentation that you suggest updating?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upstream side, updating release note is required.

@rajnkamr rajnkamr added the action/release-note Indicates a PR that should be included in release notes. label Nov 6, 2023
@Atish-iaf
Copy link
Contributor Author

LGTM. Could you update e2e cases to verify this section?

updated, PTAL.
Thanks.

Copy link
Contributor

@luolanzone luolanzone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, one nit.

pkg/agent/controller/traceflow/packetin_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small comments, otherwise LGTM

It would have been better to separate 1) the e2e tests changes to replace usage of v1alpha1 with v1beta1, and 2) the addition of the new field to Traceflow (i.e., use 2 different PRs). I don't think there is a strong need to split that PR now, but something to keep in mind in the future.

Class: openflow15.OXM_CLASS_PACKET_REGS,
Field: uint8(openflow.TFEgressConjIDField.GetRegID() / 2),
Value: &openflow15.ByteArrayField{
Data: xreg0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's confusing to use xreg0 as the data source here. The name xreg0 comes from the fact that we use it (above) to set the value of the openflow15.NXM_NX_REG0 register.
I suggest that you use a new byte array for the conj ID registers. Maybe conjData or some variable like that.

Name: "acnp-1",
},
)
npQuerier.EXPECT().GetRuleByFlowID(gomock.Any()).Return(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think that it is pretty easy to know the expected ID here, given that we craft the register data ourselves?
applies to expectations below as well

@@ -1135,6 +1135,8 @@ type Observation struct {
DstMAC string `json:"dstMAC,omitempty" yaml:"dstMAC,omitempty"`
// NetworkPolicy is the combination of Namespace and NetworkPolicyName.
NetworkPolicy string `json:"networkPolicy,omitempty" yaml:"networkPolicy,omitempty"`
// NetworkPolicyRule is the name of an ingress or an egress rule in NetworkPolicy.
NetworkPolicyRule string `json:"networkPolicyRule,omitempty" yaml:"networkPolicyRule,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll make it clear in the release notes. Is there any other documentation that you suggest updating?

test/e2e/traceflow_test.go Outdated Show resolved Hide resolved
Component: v1beta1.ComponentNetworkPolicy,
ComponentInfo: "IngressMetric",
Action: v1beta1.ActionDropped,
NetworkPolicy: "AntreaNetworkPolicy:testtraceflow-.{8}/test-annp-deny-ingress",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a regex here? We know what the name of the Namespace is by the time we declare the test cases.

ComponentInfo: "IngressMetric",
Action: v1beta1.ActionDropped,
NetworkPolicy: "AntreaNetworkPolicy:testtraceflow-.{8}/test-annp-deny-ingress",
NetworkPolicyRule: "ingress-drop-.{7}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A similar comment here: we can use hardcoded rule names when we create the policies, and use that name here. We don't need to let Antrea auto-generate a rule name when testing Traceflow.

Update Traceflow e2e tests to verify "NetworkPolicy" and "NetworkPolicyRule"
in Traceflow observation.

Signed-off-by: Kumar Atish <atish.iaf@gmail.com>
@Atish-iaf Atish-iaf changed the title Add NetworkPolicy rule name in traceflow observation Add NetworkPolicy rule name in Traceflow observation Nov 16, 2023
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tnqn
Copy link
Member

tnqn commented Nov 16, 2023

/test-all

@antoninbas
Copy link
Contributor

/test-conformance

@tnqn tnqn merged commit 68b5a02 into antrea-io:main Nov 17, 2023
49 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/release-note Indicates a PR that should be included in release notes. area/ops/traceflow Issues or PRs related to the Traceflow feature kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants