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

lifecycle.hook field is required but not validated as set #24837

Open
aiven-amartin opened this issue Jan 10, 2025 · 2 comments
Open

lifecycle.hook field is required but not validated as set #24837

aiven-amartin opened this issue Jan 10, 2025 · 2 comments

Comments

@aiven-amartin
Copy link

Nomad version

Nomad v1.9.4+ent
BuildDate 2024-12-18T15:39:04Z
Revision f3c6d7912823c6d9db7b655696b6735c1f4b90f0+CHANGES

Operating system and Environment details

NAME="Fedora Linux"
VERSION="40 (Cloud Edition)"
ID=fedora
VERSION_ID=40
VERSION_CODENAME=""
PLATFORM_ID="platform:f40"
PRETTY_NAME="Fedora Linux 40 (Cloud Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:40"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f40/system-administrators-guide/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=40
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=40
SUPPORT_END=2025-05-13
VARIANT="Cloud Edition"
VARIANT_ID=cloud

Issue

For at least system jobs (and probably service as well), if you have a non-leader task with sidecar=false, and no hook specified, it is constantly restarted when it exits with code 0.

Reproduction steps

Create a system job with two tasks. One is the actual main task (optionally set leader=true on this one for clarity), with no lifecycle defined. The second is intended as a oneshot with a lifecycle with sidecar=false, and hook unspecified.

Expected Result

The second task runs until it exits with code 0, with no restarts.

Actual Result

The second task is constantly restarted after every exit (frequency depending on your restart policy defaults). If you specify a hook, then things behave as expected.

Job file (if appropriate)

Nomad Server logs (if appropriate)

Nomad Client logs (if appropriate)

@tgross
Copy link
Member

tgross commented Jan 10, 2025

Hi @aiven-amartin! Note that the hook field is documented as required: https://developer.hashicorp.com/nomad/docs/job-specification/lifecycle#hook. We should be validating that at job submission so that it's an error to have it unset.

@tgross tgross changed the title sidecar=false is ignored unless a hook is specified lifecycle.hook field is required but not validated as set Jan 10, 2025
@tgross tgross moved this from Needs Triage to Needs Roadmapping in Nomad - Community Issues Triage Jan 10, 2025
@aiven-amartin
Copy link
Author

Hi @aiven-amartin! Note that the hook field is documented as required: https://developer.hashicorp.com/nomad/docs/job-specification/lifecycle#hook. We should be validating that at job submission so that it's an error to have it unset.

Okay so the bug is just that jobs are accepted w/o the hook specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Roadmapping
Development

No branches or pull requests

2 participants