Skip to content

[Improvement-18662][API]Aligns insertSchedule with updateSchedule (which already allows offline workflows to save) - #18664

Merged
SbloodyS merged 7 commits into
apache:devfrom
njnu-seafish:Improvement-18662
Sep 30, 2026
Merged

SbloodyS merged 7 commits into
apache:devfrom
njnu-seafish:Improvement-18662

Conversation

@njnu-seafish

Copy link
Copy Markdown
Contributor

Was this PR generated or assisted by AI?

NO

Purpose of the pull request

close #18662

Brief change log

The new schedule created by insertSchedule is always persisted with releaseState = OFFLINE and is not registered into the Quartz scheduler, so it cannot fire anything by itself. It only takes effect after the user explicitly goes it online via onlineScheduler.

That "go online" path (doOnlineScheduler) keeps the workflow-level check — it still throws WORKFLOW_DEFINITION_NOT_RELEASE when the workflow definition is not ONLINE. So an offline workflow's schedule can never actually be triggered; the current design guard is not bypassed.

The change only aligns insertSchedule with updateSchedule (which already allows offline workflows to save), and removes an unnecessary stricter check for the "configure a timer first, go online later" flow.

Verify this pull request

This change added tests and can be verified as follows:

  • Added unit tests in SchedulerServiceTest: creating a schedule for an offline workflow succeeds (persisted as OFFLINE, no trigger), while non-existent and cross-project workflows are still rejected.
  • Manually verified on a locally deployed cluster: offline workflow scheduling configuration can now be saved, and it takes effect only after the schedule is manually set online.

Pull Request Notice

Pull Request Notice

If your pull request contains incompatible change, you should also add it to docs/docs/en/guide/upgrade/incompatible.md

@SbloodyS SbloodyS added this to the 3.5.0 milestone Sep 24, 2026
@SbloodyS SbloodyS added the improvement make more easy to user or prompt friendly label Sep 24, 2026

@det101 det101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looked at the insertSchedule change against updateSchedule / doOnlineScheduler.

This is not a privilege bypass: project write permission is still checked, the created schedule stays OFFLINE, and insertSchedule does not register Quartz. Online still requires the workflow to be ONLINE. Replacing orElse(null) + checkWorkflowDefinitionValid with orElseThrow plus the projectCode check is also the right existence/ownership guard.

Optional test tightening in testInsertScheduleOfflineWorkflow: assert the captured schedule is ReleaseState.OFFLINE, and verifyNoInteractions(schedulerApi) so the “saved but not scheduled” contract stays locked. A case that onlineScheduler rejects an OFFLINE workflow would help the same way.

@SbloodyS SbloodyS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Preserve subworkflow validation when activating a schedule.

The removed checkWorkflowDefinitionValid() call also verified that subworkflows were online, whereas doOnlineScheduler() only checks the parent workflow.

Please keep offline schedule creation supported, but validate subworkflow readiness when activating the schedule and add coverage for this case.

@njnu-seafish

Copy link
Copy Markdown
Contributor Author

Looked at the insertSchedule change against updateSchedule / doOnlineScheduler.

This is not a privilege bypass: project write permission is still checked, the created schedule stays OFFLINE, and insertSchedule does not register Quartz. Online still requires the workflow to be ONLINE. Replacing orElse(null) + checkWorkflowDefinitionValid with orElseThrow plus the projectCode check is also the right existence/ownership guard.

Optional test tightening in testInsertScheduleOfflineWorkflow: assert the captured schedule is ReleaseState.OFFLINE, and verifyNoInteractions(schedulerApi) so the “saved but not scheduled” contract stays locked. A case that onlineScheduler rejects an OFFLINE workflow would help the same way.

Thanks for the review. Both suggested test tightenings are now in place in commit 00c1da0:

testInsertScheduleOfflineWorkflow now asserts the captured schedule is persisted as ReleaseState.OFFLINE, and verifies no interaction with schedulerApi, so the "saved but not scheduled" contract stays locked.
Added testOnlineSchedulerRejectsOfflineWorkflow to cover that onlineScheduler still rejects an OFFLINE workflow, leaving the schedule unmodified and Quartz unregistered.

@njnu-seafish

Copy link
Copy Markdown
Contributor Author

Preserve subworkflow validation when activating a schedule.

The removed checkWorkflowDefinitionValid() call also verified that subworkflows were online, whereas doOnlineScheduler() only checks the parent workflow.

Please keep offline schedule creation supported, but validate subworkflow readiness when activating the schedule and add coverage for this case.

Good catch — the removed checkWorkflowDefinitionValid() did include subworkflow validation via checkSubWorkflowDefinitionValid(), and doOnlineScheduler() only checked the parent workflow. That gap is now closed in commit 484cb79:

doOnlineScheduler() now calls executorService.checkSubWorkflowDefinitionValid(workflowDefinition) after the parent ONLINE check, throwing SUB_WORKFLOW_DEFINITION_NOT_RELEASE if any sub-workflow is offline.
Offline schedule creation is still supported — insertSchedule saves the schedule as OFFLINE without registering Quartz.
Added test coverage:
testOnlineSchedulerRejectsOfflineSubWorkflow — parent ONLINE but sub-workflow OFFLINE → rejected, schedule stays OFFLINE, Quartz unregistered.
testOnlineSchedulerSucceedsWhenSubWorkflowOnline — sub-workflows ready → schedule activated and Quartz registered.
Since both onlineScheduler and onlineSchedulerByWorkflowCode go through doOnlineScheduler, the validation covers both entry points.

@SbloodyS SbloodyS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@SbloodyS
SbloodyS merged commit c63ecc9 into apache:dev Sep 30, 2026
118 of 119 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend improvement make more easy to user or prompt friendly test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement][API] Inconsistent behavior: "Timing" button is enabled for offline workflows but saving schedule fails with "workflow not online" error

3 participants