Skip to content
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

[Enhancement]: the elasticsearch configurable timeout #2982

Open
james-async opened this issue Feb 14, 2025 · 0 comments · May be fixed by #2983
Open

[Enhancement]: the elasticsearch configurable timeout #2982

james-async opened this issue Feb 14, 2025 · 0 comments · May be fixed by #2983
Labels
enhancement New feature or request

Comments

@james-async
Copy link

Proposal

The elasticsearch module should support the client applying a custom StartupTimeout.

In resource constrained environments as seen in some (many?) Github Actions it can take longer for the container to complete the WaitFor strategy. By allowing the client to specify the timeout they can control how long their system is willing to wait.

This module currently does support the client passing in additional strategies. However, the StartupTimeout needs to be applied to the wait.ForHTTP strategy.

The logs as seen from a timeout include the following where it can be seen that no timeout is applied to the wait.ForHTTP("/"):

Waiting for: &{timeout: Port:9200 Path:/ StatusCodeMatcher:0x1b9b0c0 ResponseMatcher:0x1c0e9e0 UseTLS:false AllowInsecure:false TLSConfig: Method:GET Body: Headers:map[] ResponseHeadersMatcher:0x1c0ea00 PollInterval:100ms UserInfo:elastic:changeme ForceIPv4LocalHost:false}ELASTIC:
container logs (wait until ready: context deadline exceeded):

This module could be updated to include an additional option:

// WithStartupTimeout sets the timeout duration used when waiting for the Elasticsearch container to start.
func WithStartupTimeout(timeout time.Duration) Option {
	return func(o *Options) {
		o.StartupTimeout = timeout
	}
}

and then apply the option in the setWaitFor function. Here I have setup no default StartupTimeout, but one could be applied to the defaultOptions, and then skip the if condition here:

if options.StartupTimeout > 0 {
	waitHTTP = waitHTTP.WithStartupTimeout(options.StartupTimeout)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant