Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Add custom environment variable options to pool configuration #253

Merged
merged 4 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Added
- Sample Windows container recipes
- Added environment variables to pool configuration, which allows users to
setup Batch environment variables for the start task.

### Fixed
- Some commands were incorrectly failing due to nodeid conflicts with
Expand Down
2 changes: 2 additions & 0 deletions config_templates/pool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,5 @@ pool_specification:
- kata_containers
- singularity
default: null
environment_variables:
abc: 'xyz'
8 changes: 8 additions & 0 deletions convoy/fleet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,14 @@ def _construct_pool_object(
value=block_for_gr,
)
)
# add custom env vars to the batch start task
env_vars = pool_settings.environment_variables
if util.is_not_empty(env_vars):
for key in env_vars:
pool.start_task.environment_settings.append(
batchmodels.EnvironmentSetting(name=key, value=env_vars[key])
)
del env_vars
# Linux-only settings
if not is_windows:
# singularity env vars
Expand Down
4 changes: 3 additions & 1 deletion convoy/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
'autoscale', 'node_fill_type', 'remote_access_control',
'certificates', 'prometheus', 'upload_diagnostics_logs_on_unusable',
'container_runtimes_install', 'container_runtimes_default',
'per_job_auto_scratch',
'per_job_auto_scratch', 'environment_variables',
]
)
SSHSettings = collections.namedtuple(
Expand Down Expand Up @@ -1328,6 +1328,8 @@ def pool_settings(config):
container_runtimes_default=cr_default,
per_job_auto_scratch=_kv_read(
conf, 'per_job_auto_scratch', default=False),
environment_variables=_kv_read_checked(
conf, 'environment_variables', default={}),
)


Expand Down
5 changes: 5 additions & 0 deletions docs/13-batch-shipyard-configuration-pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ pool_specification:
- kata_containers
- singularity
default: null
environment_variables:
abc: 'xyz'
```

The `pool_specification` property has the following members:
Expand Down Expand Up @@ -572,6 +574,9 @@ behavior on the pool compute nodes.
* (optional) `default` is the default container runtime to use for
running Docker containers. This option has no effect on `singularity`
containers.
* (optional) `environment_variables` that are set on the Azure Batch start
task. Note that environment variables are not expanded and are passed
as-is.

## Full template
A full template of a credentials file can be found
Expand Down
5 changes: 5 additions & 0 deletions schemas/pool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,8 @@ mapping:
default:
type: str
enum: ['kata_containers', 'runc']
environment_variables:
type: map
mapping:
regex;(.+):
type: str