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

deprecate client-side interpolation for known values in lieu of HCL2 #20362

Open
tgross opened this issue Apr 11, 2024 · 0 comments
Open

deprecate client-side interpolation for known values in lieu of HCL2 #20362

tgross opened this issue Apr 11, 2024 · 0 comments

Comments

@tgross
Copy link
Member

tgross commented Apr 11, 2024

In #20344 (review) @schmichael noted:

I wonder if we should deprecate this form of interpolation in this place in favor of HCL variables? I think an HCL variable with a default value could specify both the group and service names in a way that would make them static by the time they're submitted to Nomad. It would be nice to have a path away from this extremely buggy phased interpolation approach.

There are broadly two kinds of interpolation that happen in Nomad jobs:

This two-phase interpolation has been a source of confusion and bugs for a while now. Any field that's being interpolated on the client cannot be used by the server. One particularly confusing thing is that this information can't be used for scheduling decisions, even if the server could do the interpolation, because the allocation hasn't been placed yet! But some of that information is available already (like task name), but because we do all the interpolation on the client we haven't built the mechanisms on the server to use it.

All of which is to say this is a bit of a mess.

To untangle this, we could:

  • Retire the environment variable syntax for the jobspec (we'd probably need to think about what this looks like for task args fields)
  • Add all the runtime environment variables for allocation and node data as ${env.*} attributes, but not the submit-time attributes like task name and group name
  • Add functions to our HCL2 that allow users to refer to submit-time attributes like task name and group name

An alternate approach could be:

  • Leave all the existing syntax in place
  • Rework the client's taskenv builder so that it only interpolates runtime-side variables
  • Add a submit-time equivalent as the first job submit hook, that does interpolation of submit-time data like task name and group name, so that these never reach the client side uninterpolated.

Either way we could also use more documentation here. There's probably some subsets of fields that we could say "you're allowed to interpolate these fields with node metadata, and these fields only with HCL2 (or submit time)". Being able to document which those are would be nice for users and for us developers.

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

No branches or pull requests

1 participant