nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: schemahero/schemahero
Pull request #883 (2023-02-21 21:01:43)

Don't try to apply migrations that have been applied already


Patch:
diff --git a/pkg/controller/migration/reconcile_migration.go b/pkg/controller/migration/reconcile_migration.go
index 2312181f..3fcaa9c5 100644
--- a/pkg/controller/migration/reconcile_migration.go
+++ b/pkg/controller/migration/reconcile_migration.go
@@ -20,7 +20,7 @@ func (r *ReconcileMigration) reconcileMigration(ctx context.Context, migration *
 		zap.String("name", migration.Name),
 		zap.String("tableName", migration.Spec.TableName))
 
-	if migration.Status.ApprovedAt == 0 && migration.Status.ExecutedAt > 0 {
+	if !shouldApplyMigration(migration) {
 		logger.Debug("migration not yet approved or already executed",
 			zap.String("name", migration.Name),
 			zap.String("tableName", migration.Spec.TableName))
@@ -77,6 +77,13 @@ func (r *ReconcileMigration) reconcileMigration(ctx context.Context, migration *
 	return reconcile.Result{}, nil
 }
 
+func shouldApplyMigration(migration *schemasv1alpha4.Migration) bool {
+	if migration.Status.ApprovedAt > 0 && migration.Status.ExecutedAt == 0 {
+		return true
+	}
+	return false
+}
+
 func getDatabaseFromMigration(ctx context.Context, migration *schemasv1alpha4.Migration) (*databasesv1alpha4.Database, error) {
 	table, err := TableFromMigration(ctx, migration)
 	if err != nil {


Test patch:
diff --git a/pkg/controller/migration/reconcile_migration_test.go b/pkg/controller/migration/reconcile_migration_test.go
index 041d3e5a..1b6625eb 100644
--- a/pkg/controller/migration/reconcile_migration_test.go
+++ b/pkg/controller/migration/reconcile_migration_test.go
@@ -3,6 +3,7 @@ package migration
 import (
 	"context"
 	"testing"
+	"time"
 
 	databasesv1alpha4 "github.com/schemahero/schemahero/pkg/apis/databases/v1alpha4"
 	schemasv1alpha4 "github.com/schemahero/schemahero/pkg/apis/schemas/v1alpha4"
@@ -88,3 +89,48 @@ func Test_getDatabaseFromMigration(t *testing.T) {
 		})
 	}
 }
+
+func Test_shouldApplyMigration(t *testing.T) {
+	tests := []struct {
+		name      string
+		migration *schemasv1alpha4.Migration
+		want      bool
+	}{
+		{
+			name: "approved not executedm, should apply",
+			migration: &schemasv1alpha4.Migration{
+				Status: schemasv1alpha4.MigrationStatus{
+					ApprovedAt: time.Now().Unix(),
+					ExecutedAt: 0,
+				},
+			},
+			want: true,
+		},
+		{
+			name: "approved and executed, should not aply",
+			migration: &schemasv1alpha4.Migration{
+				Status: schemasv1alpha4.MigrationStatus{
+					ApprovedAt: time.Now().Unix(),
+					ExecutedAt: time.Now().Unix(),
+				},
+			},
+			want: false,
+		},
+		{
+			name: "not approved, should not apply",
+			migration: &schemasv1alpha4.Migration{
+				Status: schemasv1alpha4.MigrationStatus{
+					ApprovedAt: 0,
+					ExecutedAt: 0,
+				},
+			},
+			want: false,
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			got := shouldApplyMigration(tt.migration)
+			assert.Equal(t, tt.want, got)
+		})
+	}
+}
Repository: GoogleCloudPlatform/cloud-bigtable-client
Pull request #1627 (2018-01-26 14:19:22)

CheckAndMutate calls should not be retried


Patch:
diff --git a/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/BigtableDataGrpcClient.java b/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/BigtableDataGrpcClient.java
index 6941bfc66..2b9b38f0e 100644
--- a/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/BigtableDataGrpcClient.java
+++ b/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/BigtableDataGrpcClient.java
@@ -108,17 +108,6 @@ public class BigtableDataGrpcClient implements BigtableDataClient {
         }
       };
 
-  /** Constant <code>IS_RETRYABLE_CHECK_AND_MUTATE</code> */
-  private static final Predicate<CheckAndMutateRowRequest> IS_RETRYABLE_CHECK_AND_MUTATE =
-      new Predicate<CheckAndMutateRowRequest>() {
-        @Override
-        public boolean apply(CheckAndMutateRowRequest checkAndMutateRowRequest) {
-          return checkAndMutateRowRequest != null
-              && allCellsHaveTimestamps(checkAndMutateRowRequest.getTrueMutationsList())
-              && allCellsHaveTimestamps(checkAndMutateRowRequest.getFalseMutationsList());
-        }
-      };
-
   private static final boolean allCellsHaveTimestamps(Iterable<Mutation> mutations) {
     for (Mutation mut : mutations) {
       if (mut.getSetCell().getTimestampMicros() <= 0) {
@@ -205,7 +194,7 @@ public class BigtableDataGrpcClient implements BigtableDataClient {
     this.checkAndMutateRpc =
         asyncUtilities.createAsyncRpc(
             BigtableGrpc.METHOD_CHECK_AND_MUTATE_ROW,
-            getMutationRetryableFunction(IS_RETRYABLE_CHECK_AND_MUTATE));
+            getMutationRetryableFunction(Predicates.<CheckAndMutateRowRequest> alwaysFalse()));
     this.readWriteModifyRpc =
         asyncUtilities.createAsyncRpc(
             BigtableGrpc.METHOD_READ_MODIFY_WRITE_ROW,


Test patch:
diff --git a/bigtable-client-core-parent/bigtable-client-core/src/test/java/com/google/cloud/bigtable/grpc/TestBigtableDataGrpcClient.java b/bigtable-client-core-parent/bigtable-client-core/src/test/java/com/google/cloud/bigtable/grpc/TestBigtableDataGrpcClient.java
index 1b31df8cf..2eb672b82 100644
--- a/bigtable-client-core-parent/bigtable-client-core/src/test/java/com/google/cloud/bigtable/grpc/TestBigtableDataGrpcClient.java
+++ b/bigtable-client-core-parent/bigtable-client-core/src/test/java/com/google/cloud/bigtable/grpc/TestBigtableDataGrpcClient.java
@@ -171,7 +171,7 @@ public class TestBigtableDataGrpcClient {
     assertFalse(defaultClient.checkAndMutateRpc.isRetryable(null));
 
     CheckAndMutateRowRequest.Builder request = CheckAndMutateRowRequest.newBuilder();
-    assertTrue(defaultClient.checkAndMutateRpc.isRetryable(request.build()));
+    assertFalse(defaultClient.checkAndMutateRpc.isRetryable(request.build()));
 
     request.addTrueMutations(
         Mutation.newBuilder().setSetCell(SetCell.newBuilder().setTimestampMicros(-1)));
Repository: osbuild/osbuild-composer
Pull request #1120 (2020-11-30 12:58:12)

distro/rhel8*: change the default size of qcow2 to 10 GiB
The default size of RHEL 8 qcow2 images is 10 GiB, let's align our default.

Related: rhbz#1846087

teg: Thanks for picking this up so quickly! I would only change the 8.4 images (no need to touch 8.3 unless there is a bug, I would say). And we need to update the test cases.
ondrejbudai: Thanks for your quick review! I force-pushed a new version that changes only rhel-84 and I regenerated the test-cases.
ondrejbudai: Rebased to add #1122.

Patch:
diff --git a/internal/distro/rhel84/distro.go b/internal/distro/rhel84/distro.go
index b4d759fa9..afd3e1bbf 100644
--- a/internal/distro/rhel84/distro.go
+++ b/internal/distro/rhel84/distro.go
@@ -898,7 +898,7 @@ func New() distro.Distro {
 		},
 		kernelOptions: "ro console=ttyS0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto",
 		bootable:      true,
-		defaultSize:   4 * GigaByte,
+		defaultSize:   10 * GigaByte,
 		assembler: func(options distro.ImageOptions, arch distro.Arch) *osbuild.Assembler {
 			return qemuAssembler("qcow2", "disk.qcow2", options, arch)
 		},


Test patch:
diff --git a/test/data/manifests/rhel_84-x86_64-qcow2-boot.json b/test/data/manifests/rhel_84-x86_64-qcow2-boot.json
index a7659b5a1..f3730e487 100644
--- a/test/data/manifests/rhel_84-x86_64-qcow2-boot.json
+++ b/test/data/manifests/rhel_84-x86_64-qcow2-boot.json
@@ -3496,7 +3496,7 @@
           },
           "format": "qcow2",
           "filename": "disk.qcow2",
-          "size": 4294967296,
+          "size": 10737418240,
           "ptuuid": "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
           "pttype": "gpt",
           "partitions": [
@@ -10105,7 +10105,7 @@
         "fstype": "xfs",
         "label": "root",
         "partuuid": "6264D520-3FB9-423F-8AB8-7A0A8E3D3562",
-        "size": 4187995648,
+        "size": 10630446592,
         "start": 106954752,
         "type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
         "uuid": "efe8afea-c0a8-45dc-8e6e-499279f6fa5d"
@@ -10239,4 +10239,4 @@
     ],
     "timezone": "UTC"
   }
-}
\ No newline at end of file
+}
diff --git a/test/data/manifests/rhel_84-x86_64-qcow2-customize.json b/test/data/manifests/rhel_84-x86_64-qcow2-customize.json
index 73f9e625d..92d812a04 100644
--- a/test/data/manifests/rhel_84-x86_64-qcow2-customize.json
+++ b/test/data/manifests/rhel_84-x86_64-qcow2-customize.json
@@ -3606,7 +3606,7 @@
           },
           "format": "qcow2",
           "filename": "disk.qcow2",
-          "size": 4294967296,
+          "size": 10737418240,
           "ptuuid": "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
           "pttype": "gpt",
           "partitions": [
@@ -10217,7 +10217,7 @@
         "fstype": "xfs",
         "label": "root",
         "partuuid": "6264D520-3FB9-423F-8AB8-7A0A8E3D3562",
-        "size": 4187995648,
+        "size": 10630446592,
         "start": 106954752,
         "type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
         "uuid": "efe8afea-c0a8-45dc-8e6e-499279f6fa5d"
@@ -10353,4 +10353,4 @@
     ],
     "timezone": "London"
   }
-}
\ No newline at end of file
+}
Repository: osbuild/osbuild-composer
Pull request #909 (2020-08-04 16:18:15)

weldr: Fix out of range index for missing toml blueprint freeze
The API was crashing if the freeze request was called on a non-existent
blueprint. This changes it to return an empty string, matching
lorax-composer's behavior (since the output is toml it shouldn't return
json).


Patch:
diff --git a/internal/weldr/api.go b/internal/weldr/api.go
index b15377d7c..7b84c6a7a 100644
--- a/internal/weldr/api.go
+++ b/internal/weldr/api.go
@@ -1246,7 +1246,12 @@ func (api *API) blueprintsFreezeHandler(writer http.ResponseWriter, request *htt
 		// lorax concatenates multiple blueprints with `\n\n` here,
 		// which is never useful. Deviate by only returning the first
 		// blueprint.
-		if len(blueprints) > 1 {
+		if len(blueprints) == 0 {
+			// lorax-composer just outputs an empty string if there were no blueprints
+			writer.WriteHeader(http.StatusOK)
+			fmt.Fprintf(writer, "")
+			return
+		} else if len(blueprints) > 1 {
 			errors := responseError{
 				ID:  "HTTPError",
 				Msg: "toml format only supported when requesting one blueprint",


Test patch:
diff --git a/internal/weldr/api_test.go b/internal/weldr/api_test.go
index 86dcca5c6..6f9674d1f 100644
--- a/internal/weldr/api_test.go
+++ b/internal/weldr/api_test.go
@@ -351,6 +351,7 @@ func TestBlueprintsFreeze(t *testing.T) {
 			ExpectedTOML   string
 		}{
 			{rpmmd_mock.BaseFixture, "/api/v0/blueprints/freeze/test?format=toml", http.StatusOK, "name=\"test\"\n description=\"Test\"\n version=\"0.0.1\"\n groups = []\n [[packages]]\n name=\"dep-package1\"\n version=\"1.33-2.fc30.x86_64\"\n [[packages]]\n name=\"dep-package3\"\n version=\"7:3.0.3-1.fc30.x86_64\"\n [[modules]]\n name=\"dep-package2\"\n version=\"2.9-1.fc30.x86_64\""},
+			{rpmmd_mock.BaseFixture, "/api/v0/blueprints/freeze/missing?format=toml", http.StatusOK, ""},
 		}
 
 		for _, c := range cases {
Repository: GoogleCloudPlatform/cloud-bigtable-client
Pull request #1754 (2018-03-22 18:18:34)

Fixing flaky OauthCredentialsCache test.
There was a race condition in OAuthCredentialsCacheTest.testRefreshAfterStale().  The test is for a stale condition that should ensure that the token's cache state is `CacheState.Stale`.  The test would be consistent if only a single call is made to the core cache retrieval code; however, a second call to `getHeader()` was introduced and that second call may return the "Stale" token or the "Good" token depending on the execution of a different thread.
This change ensures that only a single call is made to refresh the header cache under stale conditions.


Patch:
diff --git a/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/io/OAuthCredentialsCache.java b/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/io/OAuthCredentialsCache.java
index a23d4a517..92db299d6 100644
--- a/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/io/OAuthCredentialsCache.java
+++ b/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/io/OAuthCredentialsCache.java
@@ -197,7 +197,8 @@ public class OAuthCredentialsCache {
   /**
    * Get the http credential header we need from a new oauth2 AccessToken.
    */
-  private HeaderCacheElement getHeaderUnsafe(Duration timeout) {
+  @VisibleForTesting
+  HeaderCacheElement getHeaderUnsafe(Duration timeout) {
     // Optimize for the common case: do a volatile read to peek for a Good cache value
     HeaderCacheElement headerCacheUnsync = this.headerCache;
 


Test patch:
diff --git a/bigtable-client-core-parent/bigtable-client-core/src/test/java/com/google/cloud/bigtable/grpc/io/OAuthCredentialsCacheTest.java b/bigtable-client-core-parent/bigtable-client-core/src/test/java/com/google/cloud/bigtable/grpc/io/OAuthCredentialsCacheTest.java
index fcdff911c..1dc5c3ee8 100644
--- a/bigtable-client-core-parent/bigtable-client-core/src/test/java/com/google/cloud/bigtable/grpc/io/OAuthCredentialsCacheTest.java
+++ b/bigtable-client-core-parent/bigtable-client-core/src/test/java/com/google/cloud/bigtable/grpc/io/OAuthCredentialsCacheTest.java
@@ -184,9 +184,9 @@ public class OAuthCredentialsCacheTest {
     setTimeInMillieconds(10);
 
     // Second call - return stale token, but schedule refresh
-    OAuthCredentialsCache.HeaderToken secondResult = underTest.getHeader(TIMEOUT);
-    Assert.assertEquals(CacheState.Stale, underTest.getHeaderCache().getCacheState());
-    Assert.assertThat(secondResult.getHeader(), containsString("stale"));
+    HeaderCacheElement secondResult = underTest.getHeaderUnsafe(TIMEOUT);
+    Assert.assertEquals(CacheState.Stale, secondResult.getCacheState());
+    Assert.assertThat(secondResult.getToken().getHeader(), containsString("stale"));
 
     // forward to expired
     setTimeInMillieconds(expires);
Repository: GoogleCloudPlatform/cloud-bigtable-client
Pull request #1931 (2018-09-06 21:44:32)

Adding a method to "fail fast" large rows


Patch:
diff --git a/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/async/BulkMutation.java b/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/async/BulkMutation.java
index a477d24d4..39cf36753 100644
--- a/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/async/BulkMutation.java
+++ b/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/async/BulkMutation.java
@@ -69,7 +69,7 @@ public class BulkMutation {
   static Logger LOG = new Logger(BulkMutation.class);
 
   public static final long MAX_RPC_WAIT_TIME_NANOS = TimeUnit.MINUTES.toNanos(12);
-  private static final long MAX_NUMBER_OF_MUTATIONS = 100_000;
+  public static final long MAX_NUMBER_OF_MUTATIONS = 100_000;
 
   private static StatusRuntimeException toException(Status status) {
     io.grpc.Status grpcStatus = io.grpc.Status
@@ -401,6 +401,10 @@ public class BulkMutation {
   public synchronized ListenableFuture<MutateRowResponse> add(MutateRowsRequest.Entry entry) {
     Preconditions.checkNotNull(entry, "Request null");
     Preconditions.checkArgument(!entry.getRowKey().isEmpty(), "Request has an empty rowkey");
+    Preconditions.checkArgument(entry.getMutationsCount() <= MAX_NUMBER_OF_MUTATIONS, String
+        .format("Key %s has %d mutations, which is over the %d maximum.",
+            entry.getRowKey().toStringUtf8(), entry.getMutationsCount(),
+            MAX_NUMBER_OF_MUTATIONS));
 
     boolean didSend = false;
     if (currentBatch != null && currentBatch.wouldBeFull(entry)) {


Test patch:
diff --git a/bigtable-client-core-parent/bigtable-client-core/src/test/java/com/google/cloud/bigtable/grpc/async/TestBulkMutation.java b/bigtable-client-core-parent/bigtable-client-core/src/test/java/com/google/cloud/bigtable/grpc/async/TestBulkMutation.java
index dad01e920..4dede139b 100644
--- a/bigtable-client-core-parent/bigtable-client-core/src/test/java/com/google/cloud/bigtable/grpc/async/TestBulkMutation.java
+++ b/bigtable-client-core-parent/bigtable-client-core/src/test/java/com/google/cloud/bigtable/grpc/async/TestBulkMutation.java
@@ -358,6 +358,15 @@ public class TestBulkMutation {
     Assert.assertTrue(underTest.currentBatch.builder.getEntriesList().contains(lastRequest));
   }
 
+  @Test(expected = IllegalArgumentException.class)
+  public void testTooManyMutations() {
+    MutateRowsRequest.Entry.Builder bigRequest = createRequestEntry().toBuilder();
+    bigRequest.addAllMutations(
+        Collections.nCopies((int) BulkMutation.MAX_NUMBER_OF_MUTATIONS, bigRequest.getMutations(0))
+    );
+    underTest.add(bigRequest.build());
+  }
+
   private BulkMutation createBulkMutation() {
     return new BulkMutation(TABLE_NAME, client, operationAccountant, retryExecutorService,
         BULK_OPTIONS);