nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: Azure/ARO-RP
Pull request #1267 (2021-01-22 16:00:23)

add nil kubeconfig check to portal
fixes panic


Patch:
diff --git a/pkg/portal/kubeconfig/proxy.go b/pkg/portal/kubeconfig/proxy.go
index d5004da3d..4277cae44 100644
--- a/pkg/portal/kubeconfig/proxy.go
+++ b/pkg/portal/kubeconfig/proxy.go
@@ -7,6 +7,7 @@ import (
 	"context"
 	"crypto/tls"
 	"crypto/x509"
+	"fmt"
 	"io"
 	"net/http"
 	"strings"
@@ -103,6 +104,10 @@ func (k *kubeconfig) cli(ctx context.Context, resourceID string, elevated bool)
 		kc = openShiftDoc.OpenShiftCluster.Properties.AROServiceKubeconfig
 	}
 
+	if len(kc) == 0 {
+		return nil, fmt.Errorf("kubeconfig is nil")
+	}
+
 	var kubeconfig *v1.Config
 	err = yaml.Unmarshal(kc, &kubeconfig)
 	if err != nil {


Test patch:
diff --git a/pkg/portal/kubeconfig/proxy_test.go b/pkg/portal/kubeconfig/proxy_test.go
index 0fab39f82..9f6e4d7b7 100644
--- a/pkg/portal/kubeconfig/proxy_test.go
+++ b/pkg/portal/kubeconfig/proxy_test.go
@@ -319,6 +319,37 @@ func TestProxy(t *testing.T) {
 			wantStatusCode: http.StatusInternalServerError,
 			wantBody:       "Internal Server Error\n",
 		},
+		{
+			name: "nil kubeconfig",
+			fixtureChecker: func(fixture *testdatabase.Fixture, checker *testdatabase.Checker, openShiftClustersClient *cosmosdb.FakeOpenShiftClusterDocumentClient, portalClient *cosmosdb.FakePortalDocumentClient) {
+				portalDocument := &api.PortalDocument{
+					ID:  token,
+					TTL: 21600,
+					Portal: &api.Portal{
+						Username:   username,
+						ID:         resourceID,
+						Kubeconfig: &api.Kubeconfig{},
+					},
+				}
+				fixture.AddPortalDocuments(portalDocument)
+				checker.AddPortalDocuments(portalDocument)
+				openShiftClusterDocument := &api.OpenShiftClusterDocument{
+					ID:  resourceID,
+					Key: resourceID,
+					OpenShiftCluster: &api.OpenShiftCluster{
+						Properties: api.OpenShiftClusterProperties{
+							NetworkProfile: api.NetworkProfile{
+								PrivateEndpointIP: privateEndpointIP,
+							},
+						},
+					},
+				}
+				fixture.AddOpenShiftClusterDocuments(openShiftClusterDocument)
+				checker.AddOpenShiftClusterDocuments(openShiftClusterDocument)
+			},
+			wantStatusCode: http.StatusInternalServerError,
+			wantBody:       "Internal Server Error\n",
+		},
 	} {
 		t.Run(tt.name, func(t *testing.T) {
 			dbPortal, portalClient := testdatabase.NewFakePortal()
Repository: Azure/ARO-RP
Pull request #1283 (2021-01-29 18:58:53)

fix broken local create regression


Patch:
diff --git a/hack/cluster/cluster.go b/hack/cluster/cluster.go
index 139b1cc28..a6190b853 100644
--- a/hack/cluster/cluster.go
+++ b/hack/cluster/cluster.go
@@ -36,7 +36,10 @@ func run(ctx context.Context, log *logrus.Entry) error {
 		return err
 	}
 
-	vnetResourceGroup := os.Getenv("CLUSTER")
+	vnetResourceGroup := os.Getenv("RESOURCEGROUP") // TODO: remove this when we deploy and peer a vnet per cluster create
+	if os.Getenv("CI") != "" {
+		vnetResourceGroup = os.Getenv("CLUSTER")
+	}
 	clusterName := os.Getenv("CLUSTER")
 
 	c, err := cluster.New(log, env, os.Getenv("CI") != "")


Test patch:
diff --git a/test/e2e/setup.go b/test/e2e/setup.go
index 574fdd771..97354e6df 100644
--- a/test/e2e/setup.go
+++ b/test/e2e/setup.go
@@ -156,7 +156,10 @@ func setup(ctx context.Context) error {
 		return err
 	}
 
-	vnetResourceGroup = os.Getenv("CLUSTER")
+	vnetResourceGroup = os.Getenv("RESOURCEGROUP") // TODO: remove this when we deploy and peer a vnet per cluster create
+	if os.Getenv("CI") != "" {
+		vnetResourceGroup = os.Getenv("CLUSTER")
+	}
 	clusterName = os.Getenv("CLUSTER")
 
 	if os.Getenv("CI") != "" { // always create cluster in CI
Repository: Azure/ARO-RP
Pull request #1284 (2021-02-01 01:15:44)

Turn custom DNS upgrade errors into 500s with text
### Which issue this PR addresses:

something I noticed doing upgrades

### What this PR does / why we need it:

This will make custom DNS preflight checks return the error (like when the CVO is unhealthy) instead of a non-descript 500.

### Test plan for issue:

tests updated

### Is there any documentation that needs to be updated for this PR?

no



Patch:
diff --git a/pkg/frontend/adminactions/upgrade.go b/pkg/frontend/adminactions/upgrade.go
index 28d158943..e71b53a88 100644
--- a/pkg/frontend/adminactions/upgrade.go
+++ b/pkg/frontend/adminactions/upgrade.go
@@ -5,7 +5,6 @@ package adminactions
 
 import (
 	"context"
-	"fmt"
 	"net/http"
 
 	"github.com/Azure/go-autorest/autorest/azure"
@@ -92,7 +91,7 @@ func checkCustomDNS(ctx context.Context, oc *api.OpenShiftCluster, vnet network.
 	if v.VirtualNetworkPropertiesFormat.DhcpOptions != nil &&
 		v.VirtualNetworkPropertiesFormat.DhcpOptions.DNSServers != nil &&
 		len(*v.VirtualNetworkPropertiesFormat.DhcpOptions.DNSServers) > 0 {
-		return fmt.Errorf("not upgrading: custom DNS is set")
+		return api.NewCloudError(http.StatusInternalServerError, api.CloudErrorCodeInternalServerError, "", "Not upgrading: custom DNS is set.")
 	}
 
 	return nil


Test patch:
diff --git a/pkg/frontend/adminactions/upgrade_test.go b/pkg/frontend/adminactions/upgrade_test.go
index f924c1131..cca3c8a30 100644
--- a/pkg/frontend/adminactions/upgrade_test.go
+++ b/pkg/frontend/adminactions/upgrade_test.go
@@ -239,7 +239,7 @@ func TestCheckCustomDNS(t *testing.T) {
 						},
 					}, nil)
 			},
-			wantErr: "not upgrading: custom DNS is set",
+			wantErr: "500: InternalServerError: : Not upgrading: custom DNS is set.",
 		},
 	}
 	for _, tt := range tests {
Repository: cloudspannerecosystem/harbourbridge
Pull request #73 (2020-07-09 10:16:24)

Fix : MySQL reserved keywords and spaces issue in schema and table name
To handle case when MySQL reserved keywords or spaces are used in schema name(database) or table name, we have quoted schema and table name with backticks (`).

Dharmil-searce: We cannot use quoting as dome in postgres (\`select count(\*) from "%s"."%s"\`), because double quotes(") are not allowed in MySQL and only backticks(\`) can be used in column, schema or table name. Also, using quoting like \`select count(\*) from \`%s\`.\`%s\`\` is not possible.
Hence, only option is "select count(*) from \`%s\`.\`%s\`".

Patch:
diff --git a/mysql/infoschema.go b/mysql/infoschema.go
index d6c19d9..531a685 100644
--- a/mysql/infoschema.go
+++ b/mysql/infoschema.go
@@ -76,7 +76,7 @@ func ProcessSQLData(conv *internal.Conv, db *sql.DB, dbName string) {
 		// MySQL schema and name can be arbitrary strings.
 		// Ideally we would pass schema/name as a query parameter,
 		// but MySQL doesn't support this. So we quote it instead.
-		q := fmt.Sprintf(`SELECT %s FROM %s.%s;`, colNameList, t.schema, t.name)
+		q := fmt.Sprintf("SELECT %s FROM `%s`.`%s`;", colNameList, t.schema, t.name)
 		rows, err := db.Query(q)
 		if err != nil {
 			conv.Unexpected(fmt.Sprintf("Couldn't get data for table %s : err = %s", t.name, err))
@@ -147,7 +147,7 @@ func SetRowStats(conv *internal.Conv, db *sql.DB, dbName string) {
 		// MySQL schema and name can be arbitrary strings.
 		// Ideally we would pass schema/name as a query parameter,
 		// but MySQL doesn't support this. So we quote it instead.
-		q := fmt.Sprintf(`SELECT COUNT(*) FROM %s.%s;`, t.schema, t.name)
+		q := fmt.Sprintf("SELECT COUNT(*) FROM `%s`.`%s`;", t.schema, t.name)
 		tableName := t.name
 		rows, err := db.Query(q)
 		if err != nil {


Test patch:
diff --git a/mysql/infoschema_test.go b/mysql/infoschema_test.go
index 88fc654..fb4ee62 100644
--- a/mysql/infoschema_test.go
+++ b/mysql/infoschema_test.go
@@ -151,7 +151,7 @@ func TestProcessSQLData(t *testing.T) {
 			cols:  []string{"table_name"},
 			rows:  [][]driver.Value{{"te st"}},
 		}, {
-			query: "SELECT (.+) FROM test.te st",
+			query: "SELECT (.+) FROM `test`.`te st`",
 			cols:  []string{"a a", " b", " c "},
 			rows: [][]driver.Value{
 				{42.3, 3, "cat"},
@@ -233,7 +233,7 @@ func TestProcessSQLData_MultiCol(t *testing.T) {
 			cols:  []string{"table_name"},
 			rows:  [][]driver.Value{{"test"}},
 		}, {
-			query: "SELECT (.+) FROM test.test",
+			query: "SELECT (.+) FROM `test`.`test`",
 			cols:  []string{"a", "b", "c"},
 			rows: [][]driver.Value{
 				{"cat", 42.3, nil},
@@ -282,11 +282,11 @@ func TestSetRowStats(t *testing.T) {
 			cols:  []string{"table_name"},
 			rows:  [][]driver.Value{{"test1"}, {"test2"}},
 		}, {
-			query: `SELECT COUNT[(][*][)] FROM test.test1`,
+			query: "SELECT COUNT[(][*][)] FROM `test`.`test1`",
 			cols:  []string{"count"},
 			rows:  [][]driver.Value{{5}},
 		}, {
-			query: `SELECT COUNT[(][*][)] FROM test.test2`,
+			query: "SELECT COUNT[(][*][)] FROM `test`.`test2`",
 			cols:  []string{"count"},
 			rows:  [][]driver.Value{{142}},
 		},