Skip to content

[8.19] [Obs AI Assistant] Backport all LockManager commits#219812

Merged
sorenlouv merged 8 commits intoelastic:8.19from
sorenlouv:backport/8.19/pr-216753_pr-216916_pr-218901_pr-219220
May 1, 2025
Merged

[8.19] [Obs AI Assistant] Backport all LockManager commits#219812
sorenlouv merged 8 commits intoelastic:8.19from
sorenlouv:backport/8.19/pr-216753_pr-216916_pr-218901_pr-219220

Conversation

@sorenlouv
Copy link
Member

sorenlouv and others added 4 commits April 30, 2025 23:46
Tests added in elastic#216397 are failing
on MKI. Skipping temporarily in the affected environment

### Error

```
           └- ✖ fail: Serverless Observability - Deployment-agnostic API integration tests observability AI Assistant LockManager Basic lock operations acquires the lock when not held
           │      ResponseError: security_exception
           │ 	Root causes:
           │ 		security_exception: action [indices:admin/create] is unauthorized for user [testing-internal] with effective roles [superuser] on restricted indices [.kibana_locks-000001], this action is granted by the index privileges [create_index,manage,all]
```

### Root cause
```ts
const es = getService('es');
es.deleteByQuery({ index: '.kibana_locks-000001', query: { match_all: {} }});
```

(cherry picked from commit 8bcce2e)
Closes: elastic#218944

The index template for the Lock Manager was not created, causing index
mappings and settings to be incorrect.
Root cause: the function responsible for creating the index template
(`ensureTemplatesAndIndexCreated`) was never invoked - only during
automated testing 🤦

The mappings for the lock manager index (`.kibana_locks-000001`) should
match this:
```ts
 {
  mappings: {
    dynamic: false,
    properties: {
      token: { type: 'keyword' },
      metadata: { enabled: false },
      createdAt: { type: 'date' },
      expiresAt: { type: 'date' },
    },
  },
}
```

In this test we make sure that the LockManager library can recover and
fix the mappings if the existing index has invalid mappings
```
DELETE .kibana_locks-000001
DELETE _index_template/.kibana_locks-index-template
DELETE _component_template/.kibana_locks-component
```
correct mappings
```
PUT .kibana_locks-000001
```

(Restart Kibana)
```
GET .kibana_locks-000001/_mapping
```

In this test we make sure that out of the box, the LockManager library
creates an index with the correct mappings

```
DELETE .kibana_locks-000001
DELETE _index_template/.kibana_locks-index-template
DELETE _component_template/.kibana_locks-component
```

(Restart Kibana)
```
GET .kibana_locks-000001/_mapping
```

Related: elastic#216916
elastic#216397

---------

Co-authored-by: Viduni Wickramarachchi <viduni.ushanka@gmail.com>
(cherry picked from commit f684ea4)
Closes: elastic#218944

The index template for the Lock Manager was not created, causing index
mappings and settings to be incorrect.
Root cause: the function responsible for creating the index template
(`ensureTemplatesAndIndexCreated`) was never invoked - only during
automated testing 🤦

The mappings for the lock manager index (`.kibana_locks-000001`) should
match this:
```ts
 {
  mappings: {
    dynamic: false,
    properties: {
      token: { type: 'keyword' },
      metadata: { enabled: false },
      createdAt: { type: 'date' },
      expiresAt: { type: 'date' },
    },
  },
}
```

In this test we make sure that the LockManager library can recover and
fix the mappings if the existing index has invalid mappings
```
DELETE .kibana_locks-000001
DELETE _index_template/.kibana_locks-index-template
DELETE _component_template/.kibana_locks-component
```
correct mappings
```
PUT .kibana_locks-000001
```

(Restart Kibana)
```
GET .kibana_locks-000001/_mapping
```

In this test we make sure that out of the box, the LockManager library
creates an index with the correct mappings

```
DELETE .kibana_locks-000001
DELETE _index_template/.kibana_locks-index-template
DELETE _component_template/.kibana_locks-component
```

(Restart Kibana)
```
GET .kibana_locks-000001/_mapping
```

Related: elastic#216916
elastic#216397

---------

Co-authored-by: Viduni Wickramarachchi <viduni.ushanka@gmail.com>
(cherry picked from commit f684ea4)
Expose LockManager as package to make it easier to consume from other
plugins

cc @nchaulet

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Viduni Wickramarachchi <viduni.ushanka@gmail.com>
(cherry picked from commit 8b8d569)
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant)

@prodsecmachine
Copy link
Collaborator

prodsecmachine commented Apr 30, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@sorenlouv sorenlouv disabled auto-merge April 30, 2025 21:57
@sorenlouv sorenlouv changed the title [8.19] [Obs AI Assistant] Skip lock tests in MKI temporarily (#216753) | [Obs AI Assistant] Replace Task Manager usage with Lock Manager (#216916) | [LockManager] Ensure index template are created (#218901) | [LockManager] Expose as package (#219220) [8.19] [Obs AI Assistant] Backport all LockManager commits May 1, 2025
@sorenlouv sorenlouv enabled auto-merge (squash) May 1, 2025 08:01
@sorenlouv sorenlouv merged commit 0bc47de into elastic:8.19 May 1, 2025
8 checks passed
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/lock-manager - 11 +11
observabilityAIAssistant 389 390 +1
total +12
Unknown metric groups

API count

id before after diff
@kbn/lock-manager - 12 +12
observabilityAIAssistant 391 392 +1
total +13

ESLint disabled line counts

id before after diff
@kbn/lock-manager - 1 +1
observabilityAIAssistant 7 6 -1
total -0

Total ESLint disabled count

id before after diff
@kbn/lock-manager - 1 +1
observabilityAIAssistant 9 8 -1
total -0

History

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 Team:Obs AI Assistant Observability AI Assistant

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants