Allow jobs to be manually unpaused in development mode (#885)

Partly mitigates #859. It's still not clear to me if there is an actual
use case or if users are trying to use "development" mode jobs for
production, but making this overridable is reasonable.

Beyond this fix I think we could do something in the Jobs schedule UI,
but it would help to better understand the use case (or actual reason of
confusion). I expect we should hint customers to move away from dev mode
rather than unpause.
This commit is contained in:
Lennart Kats (databricks) 2023-11-13 20:50:39 +01:00 committed by GitHub
parent c3ced68c60
commit 0ab125c109
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 4 deletions

View File

@ -47,13 +47,17 @@ func transformDevelopmentMode(b *bundle.Bundle) error {
if r.Jobs[i].MaxConcurrentRuns == 0 {
r.Jobs[i].MaxConcurrentRuns = developmentConcurrentRuns
}
if r.Jobs[i].Schedule != nil {
// Pause each job. As an exception, we don't pause jobs that are explicitly
// marked as "unpaused". This allows users to override the default behavior
// of the development mode.
if r.Jobs[i].Schedule != nil && r.Jobs[i].Schedule.PauseStatus != jobs.PauseStatusUnpaused {
r.Jobs[i].Schedule.PauseStatus = jobs.PauseStatusPaused
}
if r.Jobs[i].Continuous != nil {
if r.Jobs[i].Continuous != nil && r.Jobs[i].Schedule.PauseStatus != jobs.PauseStatusUnpaused {
r.Jobs[i].Continuous.PauseStatus = jobs.PauseStatusPaused
}
if r.Jobs[i].Trigger != nil {
if r.Jobs[i].Trigger != nil && r.Jobs[i].Schedule.PauseStatus != jobs.PauseStatusUnpaused {
r.Jobs[i].Trigger.PauseStatus = jobs.PauseStatusPaused
}
}

View File

@ -45,7 +45,23 @@ func mockBundle(mode config.Mode) *bundle.Bundle {
},
Resources: config.Resources{
Jobs: map[string]*resources.Job{
"job1": {JobSettings: &jobs.JobSettings{Name: "job1"}},
"job1": {
JobSettings: &jobs.JobSettings{
Name: "job1",
Schedule: &jobs.CronSchedule{
QuartzCronExpression: "* * * * *",
},
},
},
"job2": {
JobSettings: &jobs.JobSettings{
Name: "job2",
Schedule: &jobs.CronSchedule{
QuartzCronExpression: "* * * * *",
PauseStatus: jobs.PauseStatusUnpaused,
},
},
},
},
Pipelines: map[string]*resources.Pipeline{
"pipeline1": {PipelineSpec: &pipelines.PipelineSpec{Name: "pipeline1"}},
@ -82,6 +98,12 @@ func TestProcessTargetModeDevelopment(t *testing.T) {
// Job 1
assert.Equal(t, "[dev lennart] job1", bundle.Config.Resources.Jobs["job1"].Name)
assert.Equal(t, bundle.Config.Resources.Jobs["job1"].Tags["dev"], "lennart")
assert.Equal(t, bundle.Config.Resources.Jobs["job1"].Schedule.PauseStatus, jobs.PauseStatusPaused)
// Job 2
assert.Equal(t, "[dev lennart] job2", bundle.Config.Resources.Jobs["job2"].Name)
assert.Equal(t, bundle.Config.Resources.Jobs["job2"].Tags["dev"], "lennart")
assert.Equal(t, bundle.Config.Resources.Jobs["job2"].Schedule.PauseStatus, jobs.PauseStatusUnpaused)
// Pipeline 1
assert.Equal(t, "[dev lennart] pipeline1", bundle.Config.Resources.Pipelines["pipeline1"].Name)
@ -182,6 +204,7 @@ func TestProcessTargetModeProduction(t *testing.T) {
}
bundle.Config.Resources.Jobs["job1"].Permissions = permissions
bundle.Config.Resources.Jobs["job1"].RunAs = &jobs.JobRunAs{UserName: "user@company.com"}
bundle.Config.Resources.Jobs["job2"].RunAs = &jobs.JobRunAs{UserName: "user@company.com"}
bundle.Config.Resources.Pipelines["pipeline1"].Permissions = permissions
bundle.Config.Resources.Experiments["experiment1"].Permissions = permissions
bundle.Config.Resources.Experiments["experiment2"].Permissions = permissions