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

Services options : variable expansion does not work for {{.cds.worker}} #5988

Open
b2p-fred opened this issue Oct 27, 2021 · 1 comment
Open
Labels

Comments

@b2p-fred
Copy link

b2p-fred commented Oct 27, 2021

When defining some options for a service, the CDS variables are not expanded. As an example:

version: v1.0
name: deploy-backend
description: Deploy the application backend
jobs:
- job: Setup the application package
  steps:
  - artifactDownload:
      path: Download installable package
      pattern: epr-backend-api
      tag: '{{.cds.version}}'
  - script:
    - 'echo "My worker hostname: {{.cds.worker}}"'
  requirements:
  - model: eprotocole/epr-PHP
  - service:
      name: nginx-api
      value: '{{.cds.env.DOCKER_REGISTRY}}{{.cds.env.DOCKER_REGISTRY_PREFIX}}epr-backend_nginx:{{.cds.env.IMAGE_TAG_NGINX}} NGINX_PHP_UPSTREAM_HOST=php-api-{{.cds.worker}} NGINX_PHP_UPSTREAM_PORT=9000'
  - service:
      name: php-api
      value: '{{.cds.env.DOCKER_REGISTRY}}{{.cds.env.DOCKER_REGISTRY_PREFIX}}epr-backend_php:{{.cds.env.IMAGE_TAG_PHP}}'

I wish using the worker name in an environment variable used to configure the Nginx server. Hence I need to use the hostname of the service running my php fpm instance ...

The {{.cds.worker}} is not replaced with the worker hostname thus resulting in an error in the nginx configuration.

Edit:
I made some more tests and I found out that some variables are expanded (e.g. {{.cds.env.VAR}}). It looks like only the {{.cds.worker}} variable is not expanded or not with the expected value...
I am still investigating to find out what is happening with this variable!

Edit:
After some more investigation, I do confirm that the {{.cds.worker}} variable is not expanded in the services options!. When I dump the environment of my nginx service I got:

[INFO]          11-dump-defined-envs.sh: Raw environment:
[INFO]          HOSTNAME af9b12426256
[INFO]          HOME /root
[INFO]          PKG_RELEASE 1 buster
[INFO]          UID 1000
[INFO]          NGINX_PHP_UPSTREAM_HOST php-api-test
[INFO]          PHP_USER www-data
[INFO]          NGINX VERSION 1.20.1
[INFO]          PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[INFO]          NGINX PHP UPSTREAM PORT 9000
[INFO]          NJS_VERSION 0.5.3
[INFO]          NGINX_PHP_UPSTREAM_COMMENT {{.cds.worker}}
[INFO]          GID 1000
[INFO]          APP_ENV prod
[INFO]          PWD /

Note the NGINX_PHP_UPSTREAM_COMMENT comment that is not expanded... whereas the test in NGINX_PHP_UPSTREAM_HOST is the expansion of {{.cds.env.APP_ENV}}

@b2p-fred b2p-fred changed the title Services options : variable expansion does not work Services options : variable expansion does not work for {{.cds.worker}} Oct 27, 2021
@yesnault
Copy link
Member

Hi, yes. I confirm that this variable can't be used in pre-requisite.

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

No branches or pull requests

2 participants