Skip to content

Correctly canonicalize lifecycle block when missing hook value - #26285

Merged
allisonlarson merged 1 commit into
mainfrom
b-validate-lifecycle-hook
Jul 16, 2025
Merged

allisonlarson merged 1 commit into
mainfrom
b-validate-lifecycle-hook

Conversation

@allisonlarson

@allisonlarson allisonlarson commented Jul 15, 2025 •

Copy link
Copy Markdown
Contributor

Description

The hook field in the lifecycle block is documented as being required, but when a task was being canonicalized, the block was being treated as empty if the hook wasn't set. This would prevent the validations from correctly returning an error to the user, and would instead ignore the lifecycle block completely and run the task without it. This change fixes corrects the canonicalization by correcting the Empty() check, and adds tests to ensure the struct is correctly canonicalized.

Testing & Reproduction steps

Added test cases to the unit tests, but reproduction is to define a task with an empty lifecycle block.

Links

Fixes #24837

Contributor Checklist

  • Changelog Entry If this PR changes user-facing behavior, please generate and add a
    changelog entry using the make cl command.
  • Testing Please add tests to cover any new functionality or to demonstrate bug fixes and
    ensure regressions will be caught.
  • Documentation If the change impacts user-facing functionality such as the CLI, API, UI,
    and job configuration, please update the Nomad website documentation to reflect this. Refer to
    the website README for docs guidelines. Please also consider whether the
    change requires notes within the upgrade guide.

Reviewer Checklist

  • Backport Labels Please add the correct backport labels as described by the internal
    backporting document.
  • Commit Type Ensure the correct merge method is selected which should be "squash and merge"
    in the majority of situations. The main exceptions are long-lived feature branches or merges where
    history should be preserved.
  • Enterprise PRs If this is an enterprise only PR, please add any required changelog entry
    within the public repository.

@allisonlarson
allisonlarson requested review from a team as code owners July 15, 2025 22:25

@Juanadelacuesta Juanadelacuesta 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.

LGTM!

@github-actions

Copy link
Copy Markdown

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 14, 2025

This branch was successfully deployed

1 active deployment
Preview – nomad-ui — db9256f2 Deployed Jul 15, 2025 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport/ent/1.8.x+ent Changes are backported to 1.8.x+ent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lifecycle.hook field is required but not validated as set

2 participants