mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[ftr/kbnServer] prevent caching errors when fetching status (#12848)
(cherry picked from commit 10656c2108
)
This commit is contained in:
parent
a63183766a
commit
09d0d7c1c7
1 changed files with 13 additions and 5 deletions
|
@ -1,12 +1,20 @@
|
|||
import { once } from 'lodash';
|
||||
|
||||
export class KibanaServerVersion {
|
||||
constructor(kibanaStatus) {
|
||||
this.kibanaStatus = kibanaStatus;
|
||||
this._cachedVersionNumber;
|
||||
}
|
||||
|
||||
get = once(async () => {
|
||||
async get() {
|
||||
if (this._cachedVersionNumber) {
|
||||
return this._cachedVersionNumber;
|
||||
}
|
||||
|
||||
const status = await this.kibanaStatus.get();
|
||||
return status.version;
|
||||
})
|
||||
if (status && status.version && status.version.number) {
|
||||
this._cachedVersionNumber = status.version.number;
|
||||
return this._cachedVersionNumber;
|
||||
}
|
||||
|
||||
throw new Error(`Unable to fetch Kibana Server status, received ${JSON.stringify(status)}`);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue