Introduce InputStopped Event to Distinguish Stop from Delete#25296
Open
patrickmann wants to merge 3 commits intomasterfrom
Open
Introduce InputStopped Event to Distinguish Stop from Delete#25296patrickmann wants to merge 3 commits intomasterfrom
patrickmann wants to merge 3 commits intomasterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a dedicated InputStopped server event to distinguish “stop” from “delete”, preventing downstream consumers from treating a stopped input as deleted.
Changes:
- Added new
InputStoppedAutoValue event model and updatedInputStatesResource.stop()to emit it. - Updated
InputEventListenerto handleInputStoppedand to use it when leadership is lost. - Simplified
MongoInputStatusServicedeletion handling by removing the stop-vs-delete DB lookup workaround and updated tests accordingly.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| graylog2-server/src/main/java/org/graylog2/rest/resources/system/inputs/InputStatesResource.java | Stop endpoint now returns/posts InputStopped instead of InputDeleted. |
| graylog2-server/src/main/java/org/graylog2/rest/models/system/inputs/responses/InputStopped.java | New event model representing an input stop lifecycle transition. |
| graylog2-server/src/main/java/org/graylog2/inputs/InputEventListener.java | Adds subscriber for InputStopped; leadership-loss path now triggers stop event instead of delete. |
| graylog2-server/src/main/java/org/graylog2/inputs/persistence/MongoInputStatusService.java | Removes DB existence check workaround; InputDeleted now always deletes state. |
| graylog2-server/src/test/java/org/graylog2/inputs/persistence/MongoInputStatusServiceTest.java | Updates tests to reflect unconditional deletion on InputDeleted and constructor signature change. |
| graylog2-server/src/test/java/org/graylog2/inputs/InputEventListenerTest.java | Adds coverage for inputStopped() behavior. |
| graylog2-server/src/test/java/org/graylog2/filters/StaticFieldFilterTest.java | Adds tests ensuring stop preserves cache, delete clears cache. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
graylog2-server/src/test/java/org/graylog2/filters/StaticFieldFilterTest.java
Show resolved
Hide resolved
graylog2-server/src/test/java/org/graylog2/filters/StaticFieldFilterTest.java
Outdated
Show resolved
Hide resolved
...log2-server/src/main/java/org/graylog2/rest/resources/system/inputs/InputStatesResource.java
Show resolved
Hide resolved
graylog2-server/src/main/java/org/graylog2/inputs/InputEventListener.java
Show resolved
Hide resolved
graylog2-server/src/main/java/org/graylog2/inputs/persistence/MongoInputStatusService.java
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Graylog emitted an
InputDeletedevent both when an input was stopped and when it was deleted. This made it impossible for downstream components to distinguish between the two lifecycle transitions.Consequences:
MongoInputStatusServiceneeded a database lookup workaround to determine if an input was actually deleted or just stopped (referenced in #7812)StaticFieldFiltercleared its static field cache on stop, causing messages still draining from the journal to lose their static fieldsSolution
Introduce a new
InputStoppedevent so each lifecycle transition has its own event type:InputStopped(input still exists in DB, just not running)InputDeleted(input removed from DB)Changes
New file
rest/models/system/inputs/responses/InputStopped.java— AutoValue event class matching the pattern ofInputCreated,InputDeleted,InputSetupModified files
InputStatesResource.javastop()now returnsInputStoppedand posts it on the server EventBus instead ofInputDeletedInputEventListener.javainputStopped()handler that removes the input from the registry. UpdatedleaderChanged()to useInputStoppedwhen a node loses leader role (inputs are stopped, not deleted)MongoInputStatusService.javaInputServicedependency and the database-check workaround.handleInputDeleted()now unconditionally deletes the state record since it only fires on actual deletionTest changes
InputEventListenerTest.javainputStopped(): verifies registry removal and no-op when input not in registryMongoInputStatusServiceTest.javaInputServicemock and the "stop does nothing" workaround test. Simplified the delete test to verify unconditional state removalStaticFieldFilterTest.javastoppedInputRetainsStaticFieldsForJournalMessages(stop preserves cache) anddeletedInputClearsStaticFieldsCache(delete evicts cache)Event architecture
There are two separate event types/buses:
InputDeleted(AutoValue class) — posted on the local server EventBus. Consumed byInputEventListener,MongoInputStatusService, andStaticFieldFilter.InputDeletedEvent(record) — posted on the cluster EventBus. Consumed byConfigurationStateUpdater,PipelineMetadataUpdater, andInputRoutingService. This was already correct (only fired from the actual delete endpoint) and was not changed.Unchanged components
InputDeletedEvent(cluster event) — unchanged, only fires fromInputsResource.terminate()InputServiceImpl.destroy()— still postsInputDeletedviapublishChange(), correct because it only runs on actual deletionConfigurationStateUpdater,PipelineMetadataUpdater,InputRoutingService— subscribe toInputDeletedEvent, not affectedHow Tested
Unit tests and manual test per instructions in #23406
Motivation and Context
Resolves #7812
Resolves #23406
Types of changes
Checklist: