Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a way to delete backfill runs #207

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mpawliszyn
Copy link
Collaborator

WIP

@mpawliszyn mpawliszyn requested a review from shellderp August 16, 2021 15:33
@mpawliszyn mpawliszyn force-pushed the mikepaw.delete-runs branch from e288e96 to 1cda513 Compare August 16, 2021 15:39
@@ -181,5 +169,21 @@ class BackfillCreator @Inject constructor(

companion object {
private val logger = getLogger<BackfillCreator>()

fun PrepareBackfillResponse.validate() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why extension instead of a method that takes it in?

when (desiredState) {
RUNNING -> slackHelper.runStarted(Id(id), caller.principal)
PAUSED -> slackHelper.runPaused(Id(id), caller.principal)
CANCELLED -> slackHelper.runCancelled(Id(id), caller.principal)
Copy link
Collaborator

@shellderp shellderp Aug 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you really want to notify? I wouldn't think anyone cares

PAUSED -> "stopped"
RUNNING -> "started"
CANCELLED -> "cancelled"
else -> desiredState.name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not reachable right? throw exception instead?

/**
* When the Backfill state changes modify the underlying partitions to these corresponding states.
*/
fun BackfillState.getPartitionState() = when (this) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toPartitionState

CANCELLED; // A backfill that has been manually cancelled, this is a final non-resumable state.

companion object {
val FINAL_STATES = setOf(CANCELLED, COMPLETE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TERMINAL might be a better word

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

however, either is fine

// State can't be changed after being completed.
checkState(this.state != BackfillState.COMPLETE)
// Backfills in final states cannot change.
checkState(!BackfillState.FINAL_STATES.contains(this.state))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could instead do

this.state !in BackfillState.FINAL_STATES

query.setParameter("newState", state)
query.setParameter("completed", BackfillState.COMPLETE)
query.setParameter("newPartitionState", state.getPartitionState())
query.setParameterList("finalPartitionStates", BackfillPartitionState.FINAL_STATES)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool this works well. I was worried it would harder to read

}

@Test fun `cancel newly created backfill`() {
val createdBackfill = createBackfillRun(false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use named arg for this boolean

}

transacter.transaction { session ->
val run = queryFactory.newQuery<BackfillRunQuery>().uniqueResult(session)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use the status api instead of transaction?

}
}

@Nested inner class `And then the backfill is started` {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is where I overdid it a bit I think. I was trying out some new stuff.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol it's a lil awkward to me, can we just call setupOtherThing() as the first line in the tests that need extra setup?

scope.fakeCaller(user = "molly") {
var backfillRuns = getBackfillRunsAction.backfillRuns("deep-fryer")
assertThat(backfillRuns.paused_backfills).hasSize(0)
assertThat(backfillRuns.running_backfills).hasSize(0)
softAssert {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what? why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

soft assert gives you all the errors instead of just the first one.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants