"Scale-to-Zero" Approach

By this I mean: Instead of purging a job entirely, you set the count parameter to a value of 0 so that the job ceases to run.

As far as I have seen/can tell, it has ostensibly the same effect (but there are some caveats [1] to this approach as Nomad doesn’t officially support this method of stopping a job).

My team has found this approach to be useful when launching a new service for the first time and only wanting to deploy it to our development environment (our deployment pipeline is identical for both dev and prod save for the count value – and a few other env-specific variable values – being derived from an env-specific Levant [2] variable file.

All said… I was just curious if anyone else leverages a “scale-to-zero” approach in their Nomad jobs because if this is actually something that a large-ish group of folks are doing, then perhaps it merits me filing a GitHub Issue feature request for officially supporting “scale-to-zero”.

[1] This simply does not work with multiregion {} jobs and the workload will be allocated with a default count value of 1 (regardless of the explicitly defined count value of 0).
[2] Yes, I know that its due time I migrate away from Levant. :laughing:

1 Like

Hi. My 2 cents. I think for me, it would be great to support count=0 as a special edge case that will make the job not garbage collected and just keep the job spec in memory for later use.

I only really used count=0 for groups that I do not want to use anymore, but I am not able to “remove” groups in HCL2 language. (For this issue, I would want rather to extend HCL2 language with full preprocessing like C preprocessor, rather than supporting count=0.). For example, I have a job airflow.nomad.hcl. That job takes a variable "INIT" { type = boolean and has an optional initialization group that initializes postgres group "airflow-init" { count = var.INIT ? 0 : 1. That group that only runs when admin requests initialization.

Then I used count=0 to ad-hoc hot fast patch services to stop groups in case of emergencies. It’s easier to set count=0 or 1 when modifying the JSON on the web UI, then removing the group JSON. Finding the closing } in the JSON in the UI for looooong groups with long templates is very hard, changing 1 to 0 is easy.

It’s easier to set count=0 or 1 when modifying the JSON on the web UI, then removing the group JSON. Finding the closing } in the JSON in the UI for looooong groups with long templates is very hard, changing 1 to 0 is easy.

This. 100%.