Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Qiyue Yao <yaoq@vmware.com>
  • Loading branch information
qiyueyao committed Jul 26, 2022
1 parent 367e46d commit 185d85e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions docs/antrea-network-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -649,12 +649,12 @@ The rules are logged in the following format:

Kubernetes Network Policies can also be audited using Antrea logging to the same file
(`/var/log/antrea/networkpolicy/np.log`). Set the Namespace Annotations to
`policy.antrea.io/enable-np-logging: "true"`, then all the rules of Kubernetes Network
Policies in this Namespace will be processed similar to setting their `enableLogging`
field to true. Packet of any connection that matches the rules will be logged with
Kubernetes Network Policy reference, but packets dropped by implicit default drop
will only be logged with consistent name `K8sNetworkPolicy` for reference.
The rules are logged in the following format:
`policy.antrea.io/enable-np-logging: "true"`, then all the rules of Kubernetes
Network Policies in this Namespace will be processed similar to setting their
`enableLogging` field to true. Packet of any connection that matches the rules
will be logged with Kubernetes Network Policy reference, but packets dropped by
implicit default drop will only be logged with consistent name `K8sNetworkPolicy`
for reference. The rules are logged in the following format:

```text
<yyyy/mm/dd> <time> <ovs-table-name> <k8s-network-policy-reference> Allow <openflow-priority> <source-ip> <source-port> <destination-ip> <destination-port> <protocol> <packet-length>
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/networkpolicy/networkpolicy_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ func newClientset(objects ...runtime.Object) *fake.Clientset {
return client
}

type mockNamespaceAnnotationLog struct{}
type mockNamespaceListerWithLogAnnotation struct{}

func (s *mockNamespaceAnnotationLog) List(selector labels.Selector) (ret []*corev1.Namespace, err error) {
func (s *mockNamespaceListerWithLogAnnotation) List(selector labels.Selector) (ret []*corev1.Namespace, err error) {
testNamespace := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Namespace: corev1.NamespaceDefault,
Expand All @@ -244,7 +244,7 @@ func (s *mockNamespaceAnnotationLog) List(selector labels.Selector) (ret []*core
return []*corev1.Namespace{testNamespace}, nil
}

func (s *mockNamespaceAnnotationLog) Get(name string) (*corev1.Namespace, error) {
func (s *mockNamespaceListerWithLogAnnotation) Get(name string) (*corev1.Namespace, error) {
testNamespace := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Namespace: corev1.NamespaceDefault,
Expand Down Expand Up @@ -2823,7 +2823,7 @@ func TestProcessNetworkPolicyLogging(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
_, c := newController()
// Replace with custom lister that returns Namespace with logging Annotation.
c.namespaceLister = &mockNamespaceAnnotationLog{}
c.namespaceLister = &mockNamespaceListerWithLogAnnotation{}

if actualPolicy := c.processNetworkPolicy(tt.inputPolicy); !reflect.DeepEqual(actualPolicy, tt.expectedPolicy) {
t.Errorf("processNetworkPolicy() got %v, want %v", actualPolicy, tt.expectedPolicy)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/antreapolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package e2e

import (
"antrea.io/antrea/pkg/controller/networkpolicy"
"context"
"encoding/json"
"fmt"
Expand All @@ -41,6 +40,7 @@ import (
crdv1alpha1 "antrea.io/antrea/pkg/apis/crd/v1alpha1"
crdv1alpha2 "antrea.io/antrea/pkg/apis/crd/v1alpha2"
crdv1alpha3 "antrea.io/antrea/pkg/apis/crd/v1alpha3"
"antrea.io/antrea/pkg/controller/networkpolicy"
"antrea.io/antrea/pkg/features"
. "antrea.io/antrea/test/e2e/utils"
)
Expand Down Expand Up @@ -2123,6 +2123,7 @@ func testAuditLoggingEnableNP(t *testing.T, data *TestData) {
t.Errorf("Error when polling audit log files for required entries: %v", err)
}
failOnError(k8sUtils.DeleteNetworkPolicy(namespaces["x"], "allow-x-b-to-x-a"), t)
data.updateNamespaceWithAnnotations(namespaces["x"], map[string]string{})
}

func testAppliedToPerRule(t *testing.T) {
Expand Down Expand Up @@ -3568,7 +3569,6 @@ func TestAntreaPolicy(t *testing.T) {
t.Run("Case=AuditLoggingBasic", func(t *testing.T) { testAuditLoggingBasic(t, data) })
t.Run("Case=AuditLoggingEnableNP", func(t *testing.T) { testAuditLoggingEnableNP(t, data) })
})
printResults()

t.Run("TestMulticastNP", func(t *testing.T) {
skipIfMulticastDisabled(t)
Expand Down

0 comments on commit 185d85e

Please sign in to comment.