Skip to content

[HOTFIX] Clear scheduled execution settings when copying notes - #5631

Open
jongyoul wants to merge 3 commits into
apache:masterfrom
jongyoul:codex/clear-scheduled-note-config
Open

jongyoul wants to merge 3 commits into
apache:masterfrom
jongyoul:codex/clear-scheduled-note-config

Conversation

@jongyoul

Copy link
Copy Markdown
Member

This keeps copied and restored notes from inheriting scheduled execution settings.

  • Clears schedule, execution identity, roles, and resource-release settings when copying or restoring note configuration
  • Refreshes scheduler registration after restoring a revision
  • Adds regression coverage for clone, import, and revision restore behavior

The core and quick workflows provide the full validation.

Copilot AI balanced review requested due to automatic review settings November 29, 2026 06:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new test cannot compile because Mockito static imports are missing, and revision restoration loses secondary-storage fallback and silently succeeds when a revision cannot be loaded.

3 open issues
What changed in this PR

This hotfix prevents copied and restored Zeppelin notes from inheriting scheduled execution settings while preserving unrelated configuration.

Changes:

  • Removes schedule, execution identity, roles, and resource-release settings when cloning or restoring notes.
  • Refreshes scheduler registration after revision restore and strengthens execution-identity validation.
  • Adds regression coverage for cloning, importing, revision restoration, and identity validation.
File Description
zeppelin-server/​src/​test/​java/​org/​apache/​zeppelin/​service/​NotebookServiceTest.java Tests identity validation and scheduler refresh after restoration.
zeppelin-server/​src/​test/​java/​org/​apache/​zeppelin/​notebook/​NotebookTest.java Tests removal of scheduling settings during clone, import, and restore.
zeppelin-server/​src/​main/​java/​org/​apache/​zeppelin/​service/​NotebookService.java Validates execution identity and refreshes restored-note scheduling.
zeppelin-server/​src/​main/​java/​org/​apache/​zeppelin/​notebook/​Notebook.java Clears scheduling configuration before saving copied or restored notes.

Review effort: Balanced

Comment on lines +1162 to +1164
when(notebookRepo.isRevisionSupportedInDefaultRepo()).thenReturn(true);
when(notebookRepo.get("note-id", "/note", "revision-id", subject))
.thenReturn(revisionNote);
Comment on lines +637 to +638
Note note = ((NotebookRepoWithVersionControl) notebookRepo)
.setNoteRevision(noteId, notePath, revisionId, subject);
noteManager.saveNote(note);
.get(noteId, notePath, revisionId, subject);
Comment on lines +639 to +642
if (note != null) {
removeCronConfig(note.getConfig());
noteManager.saveNote(note, subject);
}
Keep revision lookup fallback across configured repositories and report missing revisions before refreshing dependent state.
throw new IOException(
"Revision " + revisionId + " of note " + noteId + " not found");
}
schedulerService.refreshCron(noteId);

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.

An existing cron job can still run the restored revision even though its cron settings have been cleared. refreshCron() removes the trigger, but it doesn’t cancel a job that Quartz has already dispatched. If that job looks up the note by ID after the restore, CronJob.execute() gets the restored note and calls runAll() as anonymous without checking whether cron is still set.

Could we have CronJob.execute() return early when the current note has no cron expression? A regression test can cover this without relying on timing: invoke the job against a note with no cron setting and verify that runAll() is not called.

try {
Note resultNote = notebook.setNoteRevision(noteId, note.getPath(), revisionId,
context.getAutheInfo());
if (resultNote == null) {

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.

Non-Blocking: Could we drop this null check? Notebook.setNoteRevision() already throws an IOException when the revision is missing, and the catch block below reports the failure without refreshing the scheduler.

Could we also have testMissingNoteRevisionFailsWithoutRefreshingCron stub that exception instead of returning null? That would keep the existing assertions while exercising the failure path used in production.

@miinhho

miinhho commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Thanks for the fixes! LGTM 😄

This branch has not been deployed

No deployments
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.

3 participants