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

startup timeout will be ignored when enabling functionsWorkerEnabled in pulsar container #5252

Closed
wants to merge 5 commits into from

Conversation

larmic
Copy link

@larmic larmic commented Apr 8, 2022

When using

private static final PulsarContainer pulsarContainer =
        new PulsarContainer(DockerImageName.parse("apachepulsar/pulsar:latest"))
            .withStartupTimeout(Duration.of(2, ChronoUnit.MINUTES));

120 seconds will be used as waiting strategy timeout. See logs:
/pensive_antonelli: Waiting for 120 seconds for URL: http://localhost:54554/metrics

But when using

private static final PulsarContainer pulsarContainer =
        new PulsarContainer(DockerImageName.parse("apachepulsar/pulsar:latest"))
            .withFunctionsWorker()
            .withStartupTimeout(Duration.of(2, ChronoUnit.MINUTES));

startup timeout will be set to default (30 seconds). See logs:
/jolly_cerf: Waiting for 30 seconds for URL: http://localhost:54640/metrics

This is because when enabling functions worker a new log waiting strategy will be used. This fix will cache startup timeout and add (if exists) this to log waiting strategy.

Copy link
Member

@kiview kiview left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, great find 👍
I added some comments regarding how I think we can simplify the implementation.

public PulsarContainer withFunctionsWorker() {
functionsWorkerEnabled = true;
return this;
}

private WaitStrategy createLogWaitingStrategy() {
if (startupTimeout != null) {
return Wait.forLogMessage(".*Function worker service started.*", 1).withStartupTimeout(startupTimeout);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can apply the startupTimeout to the WaitAllStrategy instead.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Comment on lines 59 to 62
waitingFor(
new WaitAllStrategy()
.withStrategy(waitStrategy)
.withStrategy(Wait.forLogMessage(".*Function worker service started.*", 1))
.withStrategy(createLogWaitingStrategy())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If instead of conditionally switching to the WaitAllStrategy we would just use a WaitAllStrategy as default and conditionally add the LogMessageWaitStrategy to it, it should simplify the implementation (no need for overriding withStartupTimeout anymore).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kiview i don't know what i should do here. :( Can you explain that a little more? :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking something like this in the constructor:

waitingFor(
            new WaitAllStrategy()
                .withStrategy(Wait.forHttp(METRICS_ENDPOINT).forStatusCode(200).forPort(BROKER_HTTP_PORT))
        );

And this in configure:

waitingFor(
                new WaitAllStrategy()
                    .withStrategy(waitStrategy)
                    .withStrategy(Wait.forLogMessage(".*Function worker service started.*", 1)
                        // NOTE withStartupTimeout must be called at the end, because start timeout will be
                        // applied to all strategies above
                    .withStartupTimeout(startupTimeout))
            );

But think somewhere along with the commits in this PR, we broke the shouldWaitForFunctionsWorkerStarted test. It fails on CI and locally now. Maybe I gave a wrong suggestion, we have to look into this.

@eddumelendez
Copy link
Member

@larmic sorry for the delay and for not taking a look at this before. This was fixed via #5674

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants