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 label value regexp pattern verification in CRD labelSelector matchExpressions #2887

Merged
merged 2 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions build/yamls/antrea-aks.yml

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions build/yamls/antrea-eks.yml

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions build/yamls/antrea-gke.yml

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions build/yamls/antrea-ipsec.yml

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions build/yamls/antrea.yml

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions build/yamls/base/crds.yml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/memberlist/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,11 @@ func (c *Cluster) syncConsistentHash(eipName string) error {
updateConsistentHash := func(eip *v1alpha2.ExternalIPPool) error {
nodeSel, err := metav1.LabelSelectorAsSelector(&eip.Spec.NodeSelector)
if err != nil {
return err
return fmt.Errorf("labelSelectorAsSelector error: %v", err)
}
nodes, err := c.nodeLister.List(nodeSel)
if err != nil {
return err
return fmt.Errorf("listing Nodes error: %v", err)
}
aliveNodes := c.aliveNodes()
// Node alive and Node labels match ExternalIPPool nodeSelector.
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/egress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ func TestEgress(t *testing.T) {
t.Run("testEgressUpdateEgressIP", func(t *testing.T) { testEgressUpdateEgressIP(t, data) })
t.Run("testEgressUpdateNodeSelector", func(t *testing.T) { testEgressUpdateNodeSelector(t, data) })
t.Run("testEgressNodeFailure", func(t *testing.T) { testEgressNodeFailure(t, data) })
t.Run("testCreateExternalIPPool", func(t *testing.T) { testCreateExternalIPPool(t, data) })
}

func testCreateExternalIPPool(t *testing.T, data *TestData) {
eip := v1alpha2.ExternalIPPool{
ObjectMeta: metav1.ObjectMeta{Name: "fakeExternalIPPool"},
Spec: v1alpha2.ExternalIPPoolSpec{NodeSelector: metav1.LabelSelector{MatchLabels: map[string]string{"env": "pro-"}}},
}

_, err := data.crdClient.CrdV1alpha2().ExternalIPPools().Create(context.TODO(), &eip, metav1.CreateOptions{})
assert.Error(t, err, "Should fail to create ExternalIPPool")
}

func testEgressClientIP(t *testing.T, data *TestData) {
Expand Down