Skip to content

[8.19] [Automatic Migration] Introduce Last execution info for a migration (#221635)#223379

Merged
kibanamachine merged 1 commit intoelastic:8.19from
kibanamachine:backport/8.19/pr-221635
Jun 11, 2025
Merged

[8.19] [Automatic Migration] Introduce Last execution info for a migration (#221635)#223379
kibanamachine merged 1 commit intoelastic:8.19from
kibanamachine:backport/8.19/pr-221635

Conversation

@kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.19:

Questions ?

Please refer to the Backport tool documentation

…lastic#221635)

## Resolves

- elastic/security-team#12681
- elastic/security-team#12682

## Summary

Please find the summary of all the changes below.

### Last Execution Info

This Enhancement introduces `last_execution` object to the `migration`
document. There is some information that we need to add for the last run
migration ( eg. `error` occured or `connector_id` used ). This PR add
that info. Below is how a sample `migration` document looks like with
`last_execution` info and shape of `last_execution` object.

```ts
export const RuleMigrationLastExecution = z.object({
  /**
   * The moment the last execution started.
   */
  started_at: z.string().optional(),
  /**
   * The moment the last execution ended.
   */
  ended_at: z.string().optional(),
  /**
   * The connector ID used for the last execution, if applicable.
   */
  connector_id: z.string().optional(),
  /**
   * The error message if the last execution failed.
   */
  error: z.string().optional(),
  /**
   * Indicates if the last execution was aborted by the user.
   */
  is_aborted: z.boolean().optional(),
});
```
```json
{
  "created_by": "u_v6jVi3qZ21kAEUwmbl-sfujRnwydrltycxyByl3jtIM_0",
  "created_at": "2025-05-28T06:10:37.638Z",
  "last_execution": {
    "connector_id": "azureOpenAiGPT4o",
    "started_at": "2025-05-28T06:10:48.030Z",
    "is_aborted": false,
    "error": "Failed to populate ELSER indices. Make sure the ELSER model is deployed and running at Machine Learning > Trained Models. Error: Exception when running inference id [.elser-2-elasticsearch] on field [elser_embedding]",
    "ended_at": "2025-05-28T06:11:31.464Z"
}

```

### Why `Last Execution` info was needed?

- An automatic migration can run into an error and terminate. Today, we
store that error in server state and do not persist. This can be a
problem when server is restarted and user will not be able to see that
error.
  - So, we need a way to persist the error for last execution.
- Additionally, we do not have any details on when the last execution
was started and finished.

- We also need to store the connector_id so that we can re-use it when
user is restarting a migration.

In addition to resolving above issues, this Ticket makes some minor UI
Changes to the Migration Ready Panel in different states of a Migration

### When Migration is Ready to be started.

This remains exactly the same as before:

![image](https://github.com/user-attachments/assets/290a4cb2-ac13-44af-a266-22c0d57719db)

### When Migration was Aborted

|Before|After|
|---|---|

|![image](https://github.com/user-attachments/assets/fee267c1-addc-4de5-87ae-86b6b4d332aa)|![image](https://github.com/user-attachments/assets/6580f10e-9276-422b-8576-f90e862c8bb9)|

### When there was an error

|Before|After|
|---|---|

|![image](https://github.com/user-attachments/assets/97ab4e86-1e5d-42db-a6b6-86fc4a0cd837)|![image](https://github.com/user-attachments/assets/ff89bf71-a86e-4409-929d-69dd631b448e)|

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

(cherry picked from commit 6458650)
@kibanamachine kibanamachine added the backport This PR is a backport of another PR label Jun 11, 2025
@kibanamachine kibanamachine enabled auto-merge (squash) June 11, 2025 09:57
@elasticmachine
Copy link
Contributor

elasticmachine commented Jun 11, 2025

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #3 / Testing AddDataProviderPopover Test Popover is visible

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 9.4MB 9.4MB +1.3KB

History

cc @logeekal

@kibanamachine kibanamachine merged commit 01993a2 into elastic:8.19 Jun 11, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants