Skip to content

events: add field to job events to detect deregister vs delete#27614

Merged
tgross merged 2 commits intomainfrom
NMD366-event-stream-purge-flag
Mar 4, 2026
Merged

events: add field to job events to detect deregister vs delete#27614
tgross merged 2 commits intomainfrom
NMD366-event-stream-purge-flag

Conversation

@tgross
Copy link
Member

@tgross tgross commented Feb 27, 2026

Most objects are simply deleted from the state store once the user deletes them or they're GC'd, but jobs can be either deregistered (stopped) or deleted (purged). Because both happen with the same Raft log type, we emit identical events to the event stream for both. Add a Purge flag to the job event to differentiate between the two.

Ref: https://hashicorp.atlassian.net/browse/NMD-366
Fixes: #24618

Generative AI disclosure: I used IBM Bob to generate much of this changeset. All code has been reviewed by me and tested end-to-end on a real cluster. Commit message by humans for humans, of course.

Contributor Checklist

  • Changelog Entry If this PR changes user-facing behavior, please generate and add a
    changelog entry using the make cl command.
  • Testing Please add tests to cover any new functionality or to demonstrate bug fixes and
    ensure regressions will be caught.
  • Documentation n/a

Reviewer Checklist

  • Backport Labels Please add the correct backport labels as described by the internal
    backporting document.
  • Commit Type Ensure the correct merge method is selected which should be "squash and merge"
    in the majority of situations. The main exceptions are long-lived feature branches or merges where
    history should be preserved.
  • Enterprise PRs If this is an enterprise only PR, please add any required changelog entry
    within the public repository.
  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

@tgross tgross added backport/1.11.x backport to 1.11.x release line theme/events Issues related to events labels Feb 27, 2026
Most objects are simply deleted from the state store once the user deletes them
or they're GC'd, but jobs can be either deregistered (stopped) or
deleted (purged). Because both happen with the same Raft log type, we emit
identical events to the event stream for both. Add a `Purge` flag to the job
event to differentiate between the two.

Ref: https://hashicorp.atlassian.net/browse/NMD-366
Fixes: #24618
@tgross tgross requested review from gulducat and tehut February 27, 2026 21:11
@tgross tgross added this to the 1.11.x milestone Feb 27, 2026
@tgross tgross marked this pull request as ready for review February 27, 2026 21:12
@tgross tgross requested review from a team as code owners February 27, 2026 21:12
@jrasell
Copy link
Member

jrasell commented Mar 2, 2026

Will there be a follow-up PR to modify the api package behaviour, so this is available too?

@tgross
Copy link
Member Author

tgross commented Mar 4, 2026

Will there be a follow-up PR to modify the api package behaviour, so this is available too?

Honestly, I'd forgotten there was any code at all in the api package for decoding events. 😊 Moving back to draft while I address that.

@tgross tgross marked this pull request as draft March 4, 2026 14:22
Copy link
Member

@gulducat gulducat left a comment

Choose a reason for hiding this comment

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

woops, just realized I hadn't sent this when I reviewed earlier


func TestEventsFromChanges_JobDeregisterRequestType(t *testing.T) {
t.SkipNow()
}
Copy link
Member

Choose a reason for hiding this comment

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

😅

@tgross
Copy link
Member Author

tgross commented Mar 4, 2026

Will there be a follow-up PR to modify the api package behaviour, so this is available too?

There wasn't a way to backwards-compatibly update the (*EventStream) Job helper, so I've added a (*EventStream) DeregisteredJob method.

@tgross tgross marked this pull request as ready for review March 4, 2026 15:53
Copy link
Member

@gulducat gulducat left a comment

Choose a reason for hiding this comment

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

LGTM!

@tgross tgross merged commit 9c98359 into main Mar 4, 2026
39 checks passed
@tgross tgross deleted the NMD366-event-stream-purge-flag branch March 4, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/1.11.x backport to 1.11.x release line theme/events Issues related to events type/enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

event stream JobDeregister event does not include purge flag

3 participants