Skip to content

Commit

Permalink
Add NetworkPolicy rule name in Traceflow observation
Browse files Browse the repository at this point in the history
Update Traceflow e2e tests to verify "NetworkPolicy" and "NetworkPolicyRule"
in Traceflow observation.

Signed-off-by: Kumar Atish <atish.iaf@gmail.com>
  • Loading branch information
Atish-iaf committed Nov 16, 2023
1 parent bdf2d6b commit d2cc4a5
Show file tree
Hide file tree
Showing 13 changed files with 344 additions and 55 deletions.
2 changes: 2 additions & 0 deletions build/charts/antrea/crds/traceflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ spec:
type: string
networkPolicy:
type: string
networkPolicyRule:
type: string
ttl:
type: integer
minimum: 0
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5048,6 +5048,8 @@ spec:
type: string
networkPolicy:
type: string
networkPolicyRule:
type: string
ttl:
type: integer
minimum: 0
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-crds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5021,6 +5021,8 @@ spec:
type: string
networkPolicy:
type: string
networkPolicyRule:
type: string
ttl:
type: integer
minimum: 0
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5048,6 +5048,8 @@ spec:
type: string
networkPolicy:
type: string
networkPolicyRule:
type: string
ttl:
type: integer
minimum: 0
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5048,6 +5048,8 @@ spec:
type: string
networkPolicy:
type: string
networkPolicyRule:
type: string
ttl:
type: integer
minimum: 0
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5048,6 +5048,8 @@ spec:
type: string
networkPolicy:
type: string
networkPolicyRule:
type: string
ttl:
type: integer
minimum: 0
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5048,6 +5048,8 @@ spec:
type: string
networkPolicy:
type: string
networkPolicyRule:
type: string
ttl:
type: integer
minimum: 0
Expand Down
9 changes: 9 additions & 0 deletions pkg/agent/controller/traceflow/packetin.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ func (c *Controller) parsePacketIn(pktIn *ofctrl.PacketIn) (*crdv1beta1.Traceflo
npRef := c.networkPolicyQuerier.GetNetworkPolicyByRuleFlowID(egressInfo)
if npRef != nil {
ob.NetworkPolicy = npRef.ToString()
ruleRef := c.networkPolicyQuerier.GetRuleByFlowID(egressInfo)
if ruleRef != nil {
ob.NetworkPolicyRule = ruleRef.Name
}
}
obs = append(obs, *ob)
}
Expand All @@ -222,6 +226,10 @@ func (c *Controller) parsePacketIn(pktIn *ofctrl.PacketIn) (*crdv1beta1.Traceflo
npRef := c.networkPolicyQuerier.GetNetworkPolicyByRuleFlowID(ingressInfo)
if npRef != nil {
ob.NetworkPolicy = npRef.ToString()
ruleRef := c.networkPolicyQuerier.GetRuleByFlowID(ingressInfo)
if ruleRef != nil {
ob.NetworkPolicyRule = ruleRef.Name
}
}
obs = append(obs, *ob)
}
Expand All @@ -237,6 +245,7 @@ func (c *Controller) parsePacketIn(pktIn *ofctrl.PacketIn) (*crdv1beta1.Traceflo
if ruleRef := c.networkPolicyQuerier.GetRuleByFlowID(notAllowConjInfo); ruleRef != nil {
if npRef := ruleRef.PolicyRef; npRef != nil {
ob.NetworkPolicy = npRef.ToString()
ob.NetworkPolicyRule = ruleRef.Name
}
if ruleRef.Action != nil && *ruleRef.Action == crdv1beta1.RuleActionReject {
ob.Action = crdv1beta1.ActionRejected
Expand Down
Loading

0 comments on commit d2cc4a5

Please sign in to comment.