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

After rendering the template, the script runs constantly restarts #14734

Closed
Mileshin opened this issue Sep 28, 2022 · 3 comments · Fixed by #14749
Closed

After rendering the template, the script runs constantly restarts #14734

Mileshin opened this issue Sep 28, 2022 · 3 comments · Fixed by #14749
Assignees
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/template type/bug

Comments

@Mileshin
Copy link

Mileshin commented Sep 28, 2022

Nomad v1.3.5
I'm trying to set up nginx to reload the config generated from a template:

{{- $forbiddenNames := parseJSON `["serviceslanding","webconfigurator"]` -}}
{{ range services -}}
  {{if .Tags | contains "api" -}}
    location /{{ .Name }}/ {
      #proxy_pass http://{{ env `NOMAD_IP_nginxhttp` }}:{{ scratch.Get .Name }}/;
      proxy_pass http://{{ env `NOMAD_IP_nginxhttp` }}:{{ key (print .Name "/http.port") }}/;
      include /etc/nginx/conf.d/proxy.conf;
      proxy_set_header X-Forwarded-Path /{{ .Name }};
   }
  {{- end -}}
{{- end -}}

To do this, I set the change_mode = "script" value in the job and add the change_script section.

# services
      artifact {
        source      = "http://consul.service.consul:8500/v1/kv/nginx/services.conf.tpl?raw=true"
        ${artifact_headers}
      }
      template {
        source        = "local/services.conf.tpl"
        destination   = "local/services.conf"
        change_mode   = "script"
        change_script  {
          command       = "/usr/sbin/nginx"
          args          = ["-s", "reload"]
          timeout       = "5s"
          fail_on_error = false
        }
      }

When the template changes, the script is executed. However, after that it starts to run continuously.

image

At the same time, the config modification time does not change. This means that the script restarts are not due to a change in the config.

I can't understand why this might be happening. Maybe there are thoughts about this? Maybe I missed something?

Thank you!

@lgfa29
Copy link
Contributor

lgfa29 commented Sep 29, 2022

Thanks for the report @Mileshin!

#14749 should fix this problem by enforcing the splay timeout value, which defaults to 5s.

@Mileshin
Copy link
Author

Thank you very much!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, 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 Jan 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/template type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants