nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: kubernetes/cloud-provider-aws
Pull request #982 (2024-06-27 20:02:11)

Automated cherry pick of #981: add support for new aws partitions in credential provider
Cherry pick of #981 on release-1.27.

#981: add support for new aws partitions in credential provider

For details on the cherry pick process, see the [cherry pick requests](https://git.k8s.io/community/contributors/devel/sig-release/cherry-picks.md) page.

```release-note

```


Patch:
diff --git a/cmd/ecr-credential-provider/main.go b/cmd/ecr-credential-provider/main.go
index b4e1a4a..1df77a9 100644
--- a/cmd/ecr-credential-provider/main.go
+++ b/cmd/ecr-credential-provider/main.go
@@ -33,10 +33,10 @@ import (
 
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/klog/v2"
-	"k8s.io/kubelet/pkg/apis/credentialprovider/v1"
+	v1 "k8s.io/kubelet/pkg/apis/credentialprovider/v1"
 )
 
-var ecrPattern = regexp.MustCompile(`^(\d{12})\.dkr\.ecr(\-fips)?\.([a-zA-Z0-9][a-zA-Z0-9-_]*)\.(amazonaws\.com(\.cn)?|sc2s\.sgov\.gov|c2s\.ic\.gov)$`)
+var ecrPattern = regexp.MustCompile(`^(\d{12})\.dkr\.ecr(\-fips)?\.([a-zA-Z0-9][a-zA-Z0-9-_]*)\.(amazonaws\.com(\.cn)?|sc2s\.sgov\.gov|c2s\.ic\.gov|cloud\.adc-e\.uk|csp\.hci\.ic\.gov)$`)
 
 // ECR abstracts the calls we make to aws-sdk for testing purposes
 type ECR interface {


Test patch:
diff --git a/cmd/ecr-credential-provider/main_test.go b/cmd/ecr-credential-provider/main_test.go
index 6d16c5f..41db8b8 100644
--- a/cmd/ecr-credential-provider/main_test.go
+++ b/cmd/ecr-credential-provider/main_test.go
@@ -240,6 +240,16 @@ func TestRegistryPatternMatch(t *testing.T) {
 		{"123456789012.dkr.cat.lala-land-1.awsamazon.com", false},
 		// too short
 		{"123456789012.lala-land-1.amazonaws.com", false},
+		// iso
+		{"123456789012.dkr.ecr.us-iso-east-1.c2s.ic.gov", true},
+		// iso-b
+		{"123456789012.dkr.ecr.us-isob-east-1.sc2s.sgov.gov", true},
+		// iso-e
+		{"123456789012.dkr.ecr.eu-isoe-west-1.cloud.adc-e.uk", true},
+		// iso-f
+		{"123456789012.dkr.ecr.us-isof-east-1.csp.hci.ic.gov", true},
+		// invalid gov endpoint
+		{"123456789012.dkr.ecr.us-iso-east-1.amazonaws.gov", false},
 	}
 	for _, g := range grid {
 		actual := ecrPattern.MatchString(g.Registry)
Repository: kubernetes/minikube
Pull request #7206 (2020-03-24 16:25:31)

Parse --disk-size and --memory sizes with binary suffixes
Hi!

when enabling the istio addon I got the message that I would need more memory in my VM - to my surprise it parsed the `--memory 8g` parameter as `8000MB` and not `8192MB`.
After looking at the rest of the code which uses 1024 in various locations for calculating sizes this seems not intended - I'm of course not sure if this is really the case :).

### Detailed Issue Description
```
 $ minikube addons enable istio
❗  Istio needs 8192MB of memory -- your configuration only allocates 4000MB
...
```

As it said I need to give my VM 8192MB I thought that I can just run it with `--memory 8g` which resulted in 8000MB instead of the expected 8GiB=8192MB:
```
 $ minikube start --memory 8g --cpus 4
😄  minikube v1.8.2 on Darwin 10.15.3
✨  Using the hyperkit driver based on existing profile
⌛  Reconfiguring existing host ...
🏃  Using the running hyperkit "minikube" VM ...
🐳  Preparing Kubernetes v1.17.3 on Docker 19.03.6 ...
🚀  Launching Kubernetes ...
🌟  Enabling addons: dashboard, default-storageclass, efk, ingress, logviewer, registry, storage-provisioner
🏄  Done! kubectl is now configured to use "minikube"
 $ minikube addons enable istio
❗  Istio needs 8192MB of memory -- your configuration only allocates 8000MB
...
```

Thanks!
Vincent



Patch:
diff --git a/pkg/util/utils.go b/pkg/util/utils.go
index fdd38f4f3..37de6085c 100644
--- a/pkg/util/utils.go
+++ b/pkg/util/utils.go
@@ -38,12 +38,13 @@ func CalculateSizeInMB(humanReadableSize string) (int, error) {
 	if err == nil {
 		humanReadableSize += "mb"
 	}
-	size, err := units.FromHumanSize(humanReadableSize)
+	// parse the size suffix binary instead of decimal so that 1G -> 1024MB instead of 1000MB
+	size, err := units.RAMInBytes(humanReadableSize)
 	if err != nil {
 		return 0, fmt.Errorf("FromHumanSize: %v", err)
 	}
 
-	return int(size / units.MB), nil
+	return int(size / units.MiB), nil
 }
 
 // GetBinaryDownloadURL returns a suitable URL for the platform


Test patch:
diff --git a/pkg/util/utils_test.go b/pkg/util/utils_test.go
index f1fe867c4..55392d7eb 100644
--- a/pkg/util/utils_test.go
+++ b/pkg/util/utils_test.go
@@ -51,6 +51,7 @@ func TestCalculateSizeInMB(t *testing.T) {
 		{"1024KB", 1},
 		{"1024mb", 1024},
 		{"1024b", 0},
+		{"1g", 1024},
 	}
 
 	for _, tt := range testData {
@@ -59,7 +60,7 @@ func TestCalculateSizeInMB(t *testing.T) {
 			t.Fatalf("unexpected err: %v", err)
 		}
 		if number != tt.expectedNumber {
-			t.Fatalf("Expected '%d'' but got '%d'", tt.expectedNumber, number)
+			t.Fatalf("Expected '%d' but got '%d' from size '%s'", tt.expectedNumber, number, tt.size)
 		}
 	}
 }