nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: zalando-incubator/kube-ingress-aws-controller
Pull request #404 (2021-02-16 15:03:29)

Apply rule creation just on ALBs
The #400 PR added rules to deny internal traffic, and in its docs it
even stated that NLBs do not support this feature. But the code didn't
check for the load balancer type. This commit adds the logic to apply
the rule creation just for ALBs.

jonathanbeber: :+1: 
jonathanbeber: :+1: 
mikkeloscar: :+1: 

Patch:
diff --git a/aws/cf_template.go b/aws/cf_template.go
index 86b9324..3bf8b3c 100644
--- a/aws/cf_template.go
+++ b/aws/cf_template.go
@@ -151,7 +151,8 @@ func generateTemplate(spec *stackSpec) (string, error) {
 			Port:            cloudformation.Integer(80),
 			Protocol:        cloudformation.String(protocol),
 		})
-		if spec.denyInternalDomains {
+		// Just ALBs support Rules
+		if spec.denyInternalDomains && spec.loadbalancerType == LoadBalancerTypeApplication {
 			template.AddResource(
 				"HTTPRuleBlockInternalTraffic",
 				generateDenyInternalTrafficRule(
@@ -193,7 +194,8 @@ func generateTemplate(spec *stackSpec) (string, error) {
 			Protocol:        cloudformation.String(tlsProtocol),
 			SslPolicy:       cloudformation.Ref(parameterListenerSslPolicyParameter).String(),
 		})
-		if spec.denyInternalDomains {
+		// Just ALBs support Rules
+		if spec.denyInternalDomains && spec.loadbalancerType == LoadBalancerTypeApplication {
 			template.AddResource(
 				"HTTPSRuleBlockInternalTraffic",
 				generateDenyInternalTrafficRule(


Test patch:
diff --git a/aws/cf_template_test.go b/aws/cf_template_test.go
index 33a9219..16860e9 100644
--- a/aws/cf_template_test.go
+++ b/aws/cf_template_test.go
@@ -341,6 +341,20 @@ func TestGenerateTemplate(t *testing.T) {
 				require.NotContains(t, template.Resources, "HTTPRuleBlockInternalTraffic")
 			},
 		},
+		{
+			name: "Does not create deny internal traffic rule on NLBs",
+			spec: &stackSpec{
+				loadbalancerType: LoadBalancerTypeNetwork,
+				certificateARNs:  map[string]time.Time{"domain.company.com": time.Now()},
+				nlbHTTPEnabled:   true,
+
+				denyInternalDomains: true,
+			},
+			validate: func(t *testing.T, template *cloudformation.Template) {
+				require.NotContains(t, template.Resources, "HTTPSRuleBlockInternalTraffic")
+				require.NotContains(t, template.Resources, "HTTPRuleBlockInternalTraffic")
+			},
+		},
 	} {
 		t.Run(test.name, func(t *testing.T) {
 			generated, err := generateTemplate(test.spec)
Repository: zalando-incubator/kube-ingress-aws-controller
Pull request #493 (2022-04-07 09:43:39)

worker: log Ingress resource type
Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>

mikkeloscar: :+1: 
szuecs: :+1:

Patch:
diff --git a/kubernetes/adapter.go b/kubernetes/adapter.go
index ea55707..3e197a9 100644
--- a/kubernetes/adapter.go
+++ b/kubernetes/adapter.go
@@ -102,9 +102,9 @@ type Ingress struct {
 	resourceType     ingressType
 }
 
-// String returns a string representation of the Ingress instance containing the namespace and the resource name.
+// String returns a string representation of the Ingress instance containing the type, namespace and the resource name.
 func (i *Ingress) String() string {
-	return fmt.Sprintf("%s/%s", i.Namespace, i.Name)
+	return fmt.Sprintf("%s %s/%s", i.resourceType, i.Namespace, i.Name)
 }
 
 // ConfigMap is the ingress-controller's representation of a Kubernetes
diff --git a/worker.go b/worker.go
index a263b32..7377970 100644
--- a/worker.go
+++ b/worker.go
@@ -401,12 +401,7 @@ func matchIngressesToLoadBalancers(
 
 		if ingress.CertificateARN != "" {
 			if !certs.CertificateExists(ingress.CertificateARN) {
-				log.Errorf(
-					"Failed to find certificate '%s' for ingress '%s/%s'",
-					ingress.CertificateARN,
-					ingress.Namespace,
-					ingress.Name,
-				)
+				log.Errorf("Failed to find certificate %s for %s", ingress.CertificateARN, ingress)
 				continue
 			}
 			certificateARNs = []string{ingress.CertificateARN}
@@ -576,12 +571,12 @@ func updateIngress(kubeAdapter *kubernetes.Adapter, lb *loadBalancer, problems *
 		for _, ing := range ingresses {
 			if err := kubeAdapter.UpdateIngressLoadBalancer(ing, dnsName); err != nil {
 				if err == kubernetes.ErrUpdateNotNeeded {
-					log.Debugf("Ingress update not needed %v with DNS name %q", ing, dnsName)
+					log.Debugf("Update not needed for %s with DNS name %s", ing, dnsName)
 				} else {
-					problems.Add("failed to update ingress %q: %w", ing, err)
+					problems.Add("failed to update %s: %w", ing, err)
 				}
 			} else {
-				log.Infof("Updated ingress %v with DNS name %q", ing, dnsName)
+				log.Infof("Updated %s with DNS name %s", ing, dnsName)
 			}
 		}
 	}


Test patch:
diff --git a/kubernetes/adapter_test.go b/kubernetes/adapter_test.go
index 817a24a..1302033 100644
--- a/kubernetes/adapter_test.go
+++ b/kubernetes/adapter_test.go
@@ -455,7 +455,7 @@ func TestNewIngressFromKube(tt *testing.T) {
 			} else {
 				assert.NoError(t, err)
 				assert.Equal(t, tc.ingress, got, "mapping from kubernetes ingress to adapter failed")
-				assert.Equal(t, got.String(), fmt.Sprintf("%s/%s", tc.ingress.Namespace, tc.ingress.Name), "wrong value from String()")
+				assert.Equal(t, got.String(), fmt.Sprintf("%s %s/%s", tc.ingress.resourceType, tc.ingress.Namespace, tc.ingress.Name), "wrong value from String()")
 			}
 		})
 	}
Repository: zalando-incubator/kube-ingress-aws-controller
Pull request #265 (2019-07-18 09:08:14)

Don't add others ingresses to already owned/non-shared stack
It seems like we have a bug where shared ingresses can be added to an already non-shared stack owned by another ingress.

Need to add tests to validate that this is indeed a bug.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/24643352/badge)](https://coveralls.io/builds/24643352)

Coverage decreased (-0.02%) to 46.532% when pulling **aaf12876579442f01178d16e47652caaf423b1dd on fix-dont-add-to-owned-stack** into **6cf979e16f4c5df4abca5b91e636a73f8e2cc208 on master**.

szuecs: Added test and validated that it caught the bug.
szuecs: :+1: 
muaazsaleem: 👍 
mikkeloscar: :+1: 

Patch:
diff --git a/worker.go b/worker.go
index 62df6aa..bc3ecd0 100644
--- a/worker.go
+++ b/worker.go
@@ -78,6 +78,10 @@ func (l *loadBalancer) AddIngress(certificateARNs []string, ingress *kubernetes.
 		owner = l.stack.OwnerIngress
 	}
 
+	if owner != "" && resourceName != owner {
+		return false
+	}
+
 	if !ingress.Shared && resourceName != owner {
 		return false
 	}


Test patch:
diff --git a/worker_test.go b/worker_test.go
index d082091..36bb72e 100644
--- a/worker_test.go
+++ b/worker_test.go
@@ -64,6 +64,20 @@ func TestAddIngress(tt *testing.T) {
 			},
 			added: false,
 		},
+		{
+			name: "don't add ingresses shared, to an owned load balancer",
+			loadBalancer: &loadBalancer{
+				stack: &aws.Stack{
+					OwnerIngress: "foo/bar",
+				},
+			},
+			ingress: &kubernetes.Ingress{
+				Shared:    true,
+				Namespace: "foo",
+				Name:      "baz",
+			},
+			added: false,
+		},
 		{
 			name: "add ingress to empty load balancer",
 			loadBalancer: &loadBalancer{
Repository: zalando-incubator/kube-ingress-aws-controller
Pull request #294 (2019-12-05 12:37:36)

Fix parsing of custom filters for ASG filter
Fixes the filter parsing for ASG such that cluster IDs with `:` are
handled correctly.

mikkeloscar: :+1: 
coveralls: 
[![Coverage Status](https://coveralls.io/builds/27434410/badge)](https://coveralls.io/builds/27434410)

Coverage remained the same at 49.107% when pulling **5da08eae3d0a0d5c11bd28d63bd0237b3132b2e1 on fix-custom-filter-parsing** into **4b5dad48b90bd7a2637f25eb27bdc821851d6eb3 on master**.

szuecs: :+1: 
szuecs: @jhohertz FYI

Patch:
diff --git a/aws/adapter.go b/aws/adapter.go
index 1ce6c12..bde14ef 100644
--- a/aws/adapter.go
+++ b/aws/adapter.go
@@ -789,8 +789,8 @@ func (a *Adapter) parseAutoscaleFilterTags(clusterId string) map[string][]string
 			if parts[0] == "tag-key" {
 				filterTags[parts[1]] = []string{}
 			} else if strings.HasPrefix(parts[0], "tag:") {
-				tagparts := strings.Split(parts[0], ":")
-				filterTags[tagparts[1]] = strings.Split(parts[1], ",")
+				tagKey := strings.TrimPrefix(parts[0], "tag:")
+				filterTags[tagKey] = strings.Split(parts[1], ",")
 			} else {
 				filterTags[parts[0]] = strings.Split(parts[1], ",")
 			}


Test patch:
diff --git a/aws/adapter_test.go b/aws/adapter_test.go
index 18cce7b..354b98f 100644
--- a/aws/adapter_test.go
+++ b/aws/adapter_test.go
@@ -777,31 +777,41 @@ func TestFindLBSubnets(tt *testing.T) {
 
 func TestParseFilterTagsDefault(t *testing.T) {
 	for _, test := range []struct {
-		name      string
-		clusterId string
-		want      map[string][]string
+		name         string
+		clusterID    string
+		customFilter string
+		want         map[string][]string
 	}{
 		{
-			"success-default-filter-asg",
-			"mycluster",
-			map[string][]string{
+			name:      "success-default-filter-asg",
+			clusterID: "mycluster",
+			want: map[string][]string{
 				clusterIDTagPrefix + "mycluster": []string{resourceLifecycleOwned},
 			},
 		},
+		{
+			name:         "success-custom-filter-asg",
+			clusterID:    "aws:12345678910:eu-central-1:mycluster",
+			customFilter: "tag:kubernetes.io/cluster/aws:12345678910:eu-central-1:mycluster=owned tag:node.kubernetes.io/role=worker",
+			want: map[string][]string{
+				clusterIDTagPrefix + "aws:12345678910:eu-central-1:mycluster": []string{resourceLifecycleOwned},
+				"node.kubernetes.io/role":                                     []string{"worker"},
+			},
+		},
 	} {
 		t.Run(fmt.Sprintf("%v", test.name), func(t *testing.T) {
 			a := Adapter{
-				customFilter: "",
+				customFilter: test.customFilter,
 				ec2Details:   map[string]*instanceDetails{},
 				manifest: &manifest{
 					instance: &instanceDetails{
 						tags: map[string]string{
-							clusterIDTagPrefix + test.clusterId: resourceLifecycleOwned,
+							clusterIDTagPrefix + test.clusterID: resourceLifecycleOwned,
 						},
 					},
 				},
 			}
-			got := a.parseAutoscaleFilterTags(test.clusterId)
+			got := a.parseAutoscaleFilterTags(test.clusterID)
 
 			if !reflect.DeepEqual(test.want, got) {
 				t.Errorf("unexpected result. wanted %+v, got %+v", test.want, got)