-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[eventLog] retry resource creation at initialization time #136363
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,14 +12,17 @@ import { initializeEs } from './init'; | |
import { ClusterClientAdapter, IClusterClientAdapter } from './cluster_client_adapter'; | ||
import { createReadySignal, ReadySignal } from '../lib/ready_signal'; | ||
|
||
export const RETRY_DELAY = 2000; | ||
|
||
export interface EsContext { | ||
logger: Logger; | ||
esNames: EsNames; | ||
esAdapter: IClusterClientAdapter; | ||
readonly logger: Logger; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just some clean-up I noticed while editing the file. This structure is not used outside of the event log, but the fields should be read-only as they are populated via a function call which creates an object that returns this interface. Figured it would be helpful to make sure we don't accidentally update these fields in our code ... Same with |
||
readonly esNames: EsNames; | ||
readonly esAdapter: IClusterClientAdapter; | ||
initialize(): void; | ||
shutdown(): Promise<void>; | ||
waitTillReady(): Promise<boolean>; | ||
initialized: boolean; | ||
readonly initialized: boolean; | ||
readonly retryDelay: number; | ||
} | ||
|
||
export interface EsError { | ||
|
@@ -44,12 +47,14 @@ class EsContextImpl implements EsContext { | |
public esAdapter: IClusterClientAdapter; | ||
private readonly readySignal: ReadySignal<boolean>; | ||
public initialized: boolean; | ||
public readonly retryDelay: number; | ||
|
||
constructor(params: EsContextCtorParams) { | ||
this.logger = params.logger; | ||
this.esNames = getEsNames(params.indexNameRoot, params.kibanaVersion); | ||
this.readySignal = createReadySignal(); | ||
this.initialized = false; | ||
this.retryDelay = RETRY_DELAY; | ||
this.esAdapter = new ClusterClientAdapter({ | ||
logger: params.logger, | ||
elasticsearchClientPromise: params.elasticsearchClientPromise, | ||
|
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 mock uses a retry of 20ms, so we can run the retries without special jest clock stuff and have the tests run in a short amount of time, but the REAL context object uses 2000ms.
I did take a stab at using the special jest clock stuff, but looks like it's going to be difficult to get working, as we need to "run all the timers" at points where we currently have no control.