-
Notifications
You must be signed in to change notification settings - Fork 123
Fix state consistency issues with ML Datafeed start and end times. #1563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… start time has been configured
We were supplying a Unix seconds value where ES expected a Unix millseconds value, using a human friendly time string is more explicit in this case anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes state consistency issues with ML datafeed start and end times by correcting timezone handling, time unit conversion, and state transition logic.
Key Changes:
- Fixed time conversion from Unix seconds to milliseconds for API calls
- Preserved user-specified timezones to prevent state inconsistency
- Set
starttime to unknown during stopped→started transitions to allow server-side default
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
internal/elasticsearch/ml/datafeed_state/update.go |
Simplified time retrieval by directly accessing string values instead of converting through helper methods |
internal/elasticsearch/ml/datafeed_state/models.go |
Added timezone preservation logic and proper handling of unknown start/end values |
internal/elasticsearch/ml/datafeed_state/read.go |
Removed conditional check that prevented reading start/end times for started datafeeds |
internal/elasticsearch/ml/datafeed_state/schema.go |
Added plan modifier to set start time to unknown when state changes |
internal/elasticsearch/ml/datafeed_state/set_unknown_if_state_has_changes.go |
Implemented custom plan modifier for conditional unknown value setting |
internal/elasticsearch/ml/datafeed_state/acc_test.go |
Added comprehensive multi-step acceptance test covering state transitions and timezone handling |
| Test configuration files (5 files) | Added test scenarios for various datafeed state transitions |
| start, diags := timeInSameLocation(datafeedStats.RunningState.SearchInterval.StartMS, d.Start) | ||
| if diags.HasError() { | ||
| return diags | ||
| } | ||
|
|
||
| end, diags := timeInSameLocation(datafeedStats.RunningState.SearchInterval.EndMS, d.End) | ||
| if diags.HasError() { | ||
| return diags | ||
| } |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable diags is reused for both start and end conversions, shadowing the outer diags variable declared at line 44. This makes it unclear which diagnostics are being accumulated. Use distinct variable names like startDiags and endDiags to avoid confusion.
Fixes #1557
Fixes #1561
This PR:
starttime to unknown if the datafeed state if transitioning fromstopped->startedstartandendtimes to avoid a state consistency issue when the user supplied timezone does not match the ES server timezone.startandendtimes were being set as Unix second values when the API was expecting Unix milli-second values.