Skip to content

Allow for a custom timeout on exec ops#42

Merged
mikejholly merged 1 commit into
earthly-mainfrom
mh/exec-time-limit
Feb 8, 2024
Merged

Allow for a custom timeout on exec ops#42
mikejholly merged 1 commit into
earthly-mainfrom
mh/exec-time-limit

Conversation

@mikejholly

Copy link
Copy Markdown
Contributor

This is working well, but it doesn't look fantastic. It would be nice to report back to the user that the command has exceeded the max time.

/tmp+b | DOCKERHUB_AUTH=true
/tmp+b | --> RUN --no-cache sleep 10
/tmp+b | WARN /tmp/Earthfile line 11:4: The command 'RUN --no-cache sleep 10' failed: process "/bin/sh -c PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /usr/bin/earth_debugger /bin/sh -c 'sleep 10'" did not complete successfully: exit code: 137: context deadline exceeded
Error: DeadlineExceeded: async force execution for /tmp+basic: unlazy force execution: DeadlineExceeded: process "/bin/sh -c PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /usr/bin/earth_debugger /bin/sh -c 'sleep 10'" did not complete successfully: exit code: 137: context deadline exceeded
View logs at https://cloud.earthly.dev/builds/a455e474-35ec-453d-bbe8-9d7508cd0061

@mikejholly mikejholly requested review from a team and vladaionescu February 7, 2024 20:51

@vladaionescu vladaionescu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be nice to report back to the user that the command has exceeded the max time.

Agreed - I think this is critical - otherwise we'll just get a ton of questions about it.

Perhaps we can do something similar to this in a defer, such that we repackage the error with something more meaningful: https://github.com/earthly/buildkit/blob/earthly-main/solver/jobs.go#L933C1-L942C4.

@alexcb

alexcb commented Feb 7, 2024

Copy link
Copy Markdown
Contributor

I'm just thinking about edge cases here -- Have you tested that the process gets killed versus go returning an error while the process continues to run?

e.g. does ps show the sleep command continuing to run?

@alexcb

alexcb commented Feb 7, 2024

Copy link
Copy Markdown
Contributor

side note: should we have earthly filter out error messages like "async force execution" and "unlazy force execution", and just print the underlying errors? I don't think the unlazy message is useful to anyone aside from core developers.

@alexcb

alexcb commented Feb 7, 2024

Copy link
Copy Markdown
Contributor

also, is there a corresponding earthly PR for this? We require the two to stay in sync for test coverage, as outlined under https://github.com/earthly/earthly/blob/main/CONTRIBUTING.md#updates-to-buildkit-or-fsutil

@mikejholly

Copy link
Copy Markdown
Contributor Author

@vladaionescu ok, I'll take a closer look at customizing the error message text.

@mikejholly

Copy link
Copy Markdown
Contributor Author

I'm just thinking about edge cases here -- Have you tested that the process gets killed versus go returning an error while the process continues to run?

e.g. does ps show the sleep command continuing to run?

Not yet, but good idea.

@mikejholly

Copy link
Copy Markdown
Contributor Author

also, is there a corresponding earthly PR for this? We require the two to stay in sync for test coverage, as outlined under https://github.com/earthly/earthly/blob/main/CONTRIBUTING.md#updates-to-buildkit-or-fsutil

I haven't had a chance yet but I will 🙂

@mikejholly

mikejholly commented Feb 7, 2024

Copy link
Copy Markdown
Contributor Author

side note: should we have earthly filter out error messages like "async force execution" and "unlazy force execution", and just print the underlying errors? I don't think the unlazy message is useful to anyone aside from core developers.

Yeah, I think async force execution is basically meaningless from a user's point of view (to me anyway!).

@mikejholly mikejholly marked this pull request as draft February 7, 2024 22:43
@mikejholly

Copy link
Copy Markdown
Contributor Author

Good news! ps doesn't show the process after the timeout is hit.

@mikejholly mikejholly marked this pull request as ready for review February 7, 2024 23:05
@alexcb

alexcb commented Feb 7, 2024

Copy link
Copy Markdown
Contributor

nit: squash these commits prior to merging.

@mikejholly

Copy link
Copy Markdown
Contributor Author

@alexcb Squashed. Look good?

@idodod

idodod commented Feb 8, 2024

Copy link
Copy Markdown

@vladaionescu ok, I'll take a closer look at customizing the error message text.

you can wrap it in a hint error and/or handle the error type in run.go

@mikejholly

Copy link
Copy Markdown
Contributor Author

@idodod Thanks. That'll be something to potentially clean up on the Earthly side.

Here's an example with this BK version:

/tmp+basic | --> RUN --no-cache sleep 100
/tmp+basic | WARN /tmp/Earthfile line 6:4: The command 'RUN --no-cache sleep 100' failed: max execution time of 2s exceeded
Error: async force execution for /tmp+basic: unlazy force execution: max execution time of 2s exceeded
View logs at https://cloud.earthly.dev/builds/ccbb2769-ba32-4f74-a40c-4a3f69a630ff

@vladaionescu

vladaionescu commented Feb 8, 2024

Copy link
Copy Markdown
Member

That'll be something to potentially clean up on the Earthly side

Agreed - on the Earthly side we might want to say a bit more explicitly something like "Unverified accounts have a limit on the duration of RUN commands. Verify your account to lift this restriction". I think that what you have now in this PR is a good string to grep for on the Earthly side.

@mikejholly mikejholly requested a review from alexcb February 8, 2024 22:08
mikejholly added a commit to earthly/earthly that referenced this pull request Feb 8, 2024
@mikejholly mikejholly merged commit fbd249f into earthly-main Feb 8, 2024
mikejholly added a commit to earthly/earthly that referenced this pull request Feb 9, 2024
I accidentally merged this [Core
PR](#3794) before the [BK
one](earthly/buildkit#42). This PR updates the
correct `earthly-main` commit SHA.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants