Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
orishoshan committed May 24, 2023
1 parent 6e1172b commit bd33640
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (r *EndpointsReconciler) reconcileEndpoints(ctx context.Context, endpoints

}

if !foundOtterizeNetpolsAffectingPods {
if !foundOtterizeNetpolsAffectingPods && !r.createEvenIfNoIntentsFound {
policyName := r.formatPolicyName(endpoints.Name)
result, err := r.handlePolicyDelete(ctx, policyName, endpoints.Namespace)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,12 @@ func (s *ExternalNetworkPolicyReconcilerWithNoIntentsTestSuite) TestNetworkPolic

// make sure the network policy was created between the two services based on the intents
np := &v1.NetworkPolicy{}
policyName := fmt.Sprintf(otterizev1alpha2.OtterizeNetworkPolicyNameTemplate, serviceName, s.TestNamespace)
err := s.Mgr.GetClient().Get(context.Background(), types.NamespacedName{Namespace: s.TestNamespace, Name: policyName}, np)
s.Require().NoError(err)
s.Require().NotEmpty(np)

s.AddDeploymentWithService(serviceName, []string{"1.1.1.1"}, map[string]string{"app": "test"}, nil)
s.Require().True(s.Mgr.GetCache().WaitForCacheSync(context.Background()))

// the ingress reconciler expect the pod watcher labels in order to work
_, err = s.podWatcher.Reconcile(context.Background(), ctrl.Request{NamespacedName: types.NamespacedName{Namespace: s.TestNamespace, Name: serviceName + "-0"}})
_, err := s.podWatcher.Reconcile(context.Background(), ctrl.Request{NamespacedName: types.NamespacedName{Namespace: s.TestNamespace, Name: serviceName + "-0"}})
s.Require().NoError(err)

// make sure the ingress network policy doesn't exist yet
Expand Down Expand Up @@ -120,18 +116,14 @@ func (s *ExternalNetworkPolicyReconcilerWithNoIntentsTestSuite) TestNetworkPolic

// make sure the network policy was created between the two services based on the intents
np := &v1.NetworkPolicy{}
policyName := fmt.Sprintf(otterizev1alpha2.OtterizeNetworkPolicyNameTemplate, serviceName, s.TestNamespace)
err := s.Mgr.GetClient().Get(context.Background(), types.NamespacedName{Namespace: s.TestNamespace, Name: policyName}, np)
s.Require().NoError(err)
s.Require().NotEmpty(np)

podIps := []string{"1.1.2.1"}
podLabels := map[string]string{"app": "test-load-balancer"}
s.AddDeploymentWithService(serviceName, podIps, podLabels, nil)
s.Require().True(s.Mgr.GetCache().WaitForCacheSync(context.Background()))

// the ingress reconciler expect the pod watcher labels in order to work
_, err = s.podWatcher.Reconcile(context.Background(), ctrl.Request{NamespacedName: types.NamespacedName{Namespace: s.TestNamespace, Name: serviceName + "-0"}})
_, err := s.podWatcher.Reconcile(context.Background(), ctrl.Request{NamespacedName: types.NamespacedName{Namespace: s.TestNamespace, Name: serviceName + "-0"}})
s.Require().NoError(err)

// make sure the load balancer network policy doesn't exist yet
Expand Down Expand Up @@ -165,18 +157,14 @@ func (s *ExternalNetworkPolicyReconcilerWithNoIntentsTestSuite) TestNetworkPolic

// make sure the network policy was created between the two services based on the intents
np := &v1.NetworkPolicy{}
policyName := fmt.Sprintf(otterizev1alpha2.OtterizeNetworkPolicyNameTemplate, serviceName, s.TestNamespace)
err := s.Mgr.GetClient().Get(context.Background(), types.NamespacedName{Namespace: s.TestNamespace, Name: policyName}, np)
s.Require().NoError(err)
s.Require().NotEmpty(np)

podIps := []string{"1.1.2.1"}
podLabels := map[string]string{"app": "test-load-balancer"}
s.AddDeploymentWithService(serviceName, podIps, podLabels, nil)
s.Require().True(s.Mgr.GetCache().WaitForCacheSync(context.Background()))

// the ingress reconciler expect the pod watcher labels in order to work
_, err = s.podWatcher.Reconcile(context.Background(), ctrl.Request{NamespacedName: types.NamespacedName{Namespace: s.TestNamespace, Name: serviceName + "-0"}})
_, err := s.podWatcher.Reconcile(context.Background(), ctrl.Request{NamespacedName: types.NamespacedName{Namespace: s.TestNamespace, Name: serviceName + "-0"}})
s.Require().NoError(err)

// make sure the load balancer network policy doesn't exist yet
Expand Down Expand Up @@ -209,18 +197,14 @@ func (s *ExternalNetworkPolicyReconcilerWithNoIntentsTestSuite) TestEndpointsRec

// make sure the network policy was created between the two services based on the intents
np := &v1.NetworkPolicy{}
policyName := fmt.Sprintf(otterizev1alpha2.OtterizeNetworkPolicyNameTemplate, serviceName, s.TestNamespace)
err := s.Mgr.GetClient().Get(context.Background(), types.NamespacedName{Namespace: s.TestNamespace, Name: policyName}, np)
s.Require().NoError(err)
s.Require().NotEmpty(np)

podIps := []string{"1.1.2.1"}
podLabels := map[string]string{"app": "test-load-balancer"}
s.AddDeploymentWithService(serviceName, podIps, podLabels, nil)
s.Require().True(s.Mgr.GetCache().WaitForCacheSync(context.Background()))

// the ingress reconciler expect the pod watcher labels in order to work
_, err = s.podWatcher.Reconcile(context.Background(), ctrl.Request{NamespacedName: types.NamespacedName{Namespace: s.TestNamespace, Name: serviceName + "-0"}})
_, err := s.podWatcher.Reconcile(context.Background(), ctrl.Request{NamespacedName: types.NamespacedName{Namespace: s.TestNamespace, Name: serviceName + "-0"}})
s.Require().NoError(err)

// make sure the load balancer network policy doesn't exist yet
Expand Down

0 comments on commit bd33640

Please sign in to comment.