-
Notifications
You must be signed in to change notification settings - Fork 908
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
ds-identify: Improve ds-identify testing flexibility #5047
ds-identify: Improve ds-identify testing flexibility #5047
Conversation
- DI_MAIN: if DI_MAIN isn't a builtin function, exec() it - /usr/libexec/ds-identify-env may be sourced to set variables The purpose of these changes is to improve ds-identify testing capabilities and to allow testing alternative ds-identify implementations. Use of these capabilities is not supported in cloud-init deployments and therefore generates warnings in the ds-identify log. Systemd gives generators no ability to run with custom environment variables. To set ds-identify variables at runtime, sourcing an environment file is required. Example no-op side-loading: $ DI_MAIN='echo' ./tools/ds-identify "hello world" WARN: side-loading alternate implementation: [echo] hello world Example side-loader that can only identify one cloud: $ cat nocloud-identifier.sh #!/bin/sh echo "creating nocloud config" echo "datasource_list: [ NoCloud ]" > cloud.cfg $ DI_MAIN=./nocloud-identifier.sh ./tools/ds-identify WARN: side-loading alternate implementation: [./nocloud-identifier.sh] creating nocloud config $ cat cloud.cfg datasource_list: [ NoCloud ]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Learnt alot about the power of exec
while reviewing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These feel like two unrelated changes. Is the get_environment()
part related to the side-loading part? In the side-loading case, main->get_environment()
would never get a chance to get called, right?
Good point - the code never calls get_environment(). Fixed in the latest commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
In order for get_environment to be of any use, it needs to be called before $DI_MAIN is referenced. Shift the call to get_environment before main() is called.
@TheRealFalcon I know you already reviewed this code, but I just updated this PR since DI_MAIN would be referenced before get_environment would be set, so the call wasn't useful. tested $ cat ./usr/libexec/ds-identify-env
export DI_MAIN=echo
$ PATH_ROOT=. ./tools/ds-identify "test"
WARN: loading environment file [./usr/libexec/ds-identify-env]
WARN: side-loading alternate implementation: [echo]
test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh. +1
Merge type