Skip to content
This repository has been archived by the owner on Apr 2, 2023. It is now read-only.

Commit

Permalink
Revert "Disable pauses for auto pause enabled updates (#216)" (#249)
Browse files Browse the repository at this point in the history
This reverts commit c64f72f.
  • Loading branch information
zorro786 committed Jul 9, 2021
1 parent 1da5e45 commit 2697cbc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,6 @@ public void assertNotUpdating(IJobKey job) throws JobUpdatingException {
@Override
public void pause(final IJobUpdateKey key, AuditData auditData) throws UpdateStateException {
requireNonNull(key);
Optional<IJobUpdateDetails> update = storage.read(p -> p.getJobUpdateStore()
.fetchJobUpdate(key));
Boolean isAutoPauseEnabled = update.isPresent() && isAutoPauseEnabled(update.get()
.getUpdate()
.getInstructions()
.getSettings()
.getUpdateStrategy());
if (isAutoPauseEnabled) {
throw new UpdateStateException("Pauses not allowed on auto-pause enabled job updates");
}
LOG.info("Attempting to pause update " + key);
unscopedChangeUpdateStatus(
key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
import org.easymock.EasyMock;
import org.easymock.IExpectationSetters;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -2032,68 +2031,6 @@ public void testSuccessfulVarBatchUpdateAutoPauseWithRollback() throws Exception
.build());
}

@Test
public void testPauseFailsWithAutoPauseEnabled() throws Exception {
expectTaskKilled().times(3);
control.replay();

JobUpdate builder = makeJobUpdate(makeInstanceConfig(0, 2, OLD_CONFIG)).newBuilder();
builder.getInstructions().getSettings()
.setUpdateStrategy(
JobUpdateStrategy.varBatchStrategy(
new VariableBatchJobUpdateStrategy()
.setGroupSizes(ImmutableList.of(1, 2))
.setAutopauseAfterBatch(true)));
IJobUpdate update = setInstanceCount(IJobUpdate.build(builder), 3);
insertInitialTasks(update);

for (int i = 0; i <= 2; ++i) {
changeState(JOB, i, ASSIGNED, STARTING, RUNNING);
}
clock.advance(WATCH_TIMEOUT);

ImmutableMultimap.Builder<Integer, JobUpdateAction> actions = ImmutableMultimap.builder();

// Update first batch
updater.start(update, AUDIT);
actions.put(0, INSTANCE_UPDATING);
assertState(ROLLING_FORWARD, actions.build());
// Pause should fail
Assert.assertThrows(UpdateStateException.class, () -> updater.pause(UPDATE_ID, AUDIT));
changeState(JOB, 0, FINISHED, ASSIGNED, STARTING, RUNNING);
clock.advance(WATCH_TIMEOUT);
actions.put(0, INSTANCE_UPDATED);

assertState(ROLL_FORWARD_PAUSED, actions.build());
// Pause should fail
Assert.assertThrows(UpdateStateException.class, () -> updater.pause(UPDATE_ID, AUDIT));
updater.resume(UPDATE_ID, AUDIT);

actions.put(1, INSTANCE_UPDATING).put(2, INSTANCE_UPDATING);
assertState(ROLLING_FORWARD, actions.build());
// Pause should fail
Assert.assertThrows(UpdateStateException.class, () -> updater.pause(UPDATE_ID, AUDIT));

// Update second batch
changeState(JOB, 1, FINISHED, ASSIGNED, STARTING, RUNNING);
changeState(JOB, 2, FINISHED, ASSIGNED, STARTING, RUNNING);
clock.advance(WATCH_TIMEOUT);

actions.put(1, INSTANCE_UPDATED);
actions.put(2, INSTANCE_UPDATED);

assertState(ROLLED_FORWARD, actions.build());
Assert.assertThrows(UpdateStateException.class, () -> updater.pause(UPDATE_ID, AUDIT));

assertJobState(
JOB,
ImmutableMap.<Integer, ITaskConfig>builder()
.put(0, NEW_CONFIG)
.put(1, NEW_CONFIG)
.put(2, NEW_CONFIG)
.build());
}

private Collection<IScheduledTask> getTasksInState(IJobKey job, ScheduleStatus status) {
return storage.write(storeProvider ->
storeProvider.getTaskStore().fetchTasks(Query.jobScoped(job).byStatus(status)));
Expand Down

0 comments on commit 2697cbc

Please sign in to comment.