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

(CDPE-6220) Fix variable references in run.pp #977

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

eputnam
Copy link

@eputnam eputnam commented Apr 18, 2024

Summary

Currently, CD4PE is using this module as part of the version 5 installation. When we use docker::run, as part of starting up the application containers, we're getting warnings like this in the customer-facing terminal output:

Unknown variable: 'docker::docker_group'. (file: /Users/eric.putnam/ws/cd4pe/PipelinesInfra/deploy/envs/cdpe6633/.modules/docker/manifests/run.pp, line: 268, column: 19)
Unknown variable: 'docker::service_name'. (file: /Users/eric.putnam/ws/cd4pe/PipelinesInfra/deploy/envs/cdpe6633/.modules/docker/manifests/run.pp, line: 267, column: 19)

This doesn't make for a very good customer experience. Since these vars are in docker::params, I added "::params" to the two lines where docker_group and service_name are assigned and that seemed to take care of the warnings. Please correct me if I'm wrong about this change, our main goal is to get rid of these warnings.

Additional Context

Add any additional context about the problem here.

  • Root cause and the steps to reproduce. (If applicable)
    These warnings can be seen by running the following bolt plan, which requires this module:
plan whalesay::docker_run() {
  apply_prep('localhost')

  apply('localhost') {
    docker::run{'example run':
      image            => 'docker/whalesay',
      pull_on_start    => true,
      restart          => "no",
    }
  }
}

Related Issues (if any)

Mention any related issues or pull requests.

Checklist

  • 🟢 Spec tests.
  • 🟢 Acceptance tests.
  • Manually verified. (For example puppet apply)

Currently, CD4PE is using this module as part of the version 5
installation. When we use docker::run, we're getting warnings like this
in the customer-facing terminal output:

Unknown variable: 'docker::docker_group'. (file: /Users/eric.putnam/ws/cd4pe/PipelinesInfra/deploy/envs/cdpe6633/.modules/docker/manifests/run.pp, line: 268, column: 19)
Unknown variable: 'docker::service_name'. (file: /Users/eric.putnam/ws/cd4pe/PipelinesInfra/deploy/envs/cdpe6633/.modules/docker/manifests/run.pp, line: 267, column: 19)

This doesn't make for a very good customer experience. Since these vars
are in docker::params, I added "::params" to the two lines where
docker_group and service_name are assigned and that seemed to take care
of the warnings. Please correct me if I'm wrong about this change, our
main goal is to get rid of these warnings.
@eputnam eputnam requested a review from a team as a code owner April 18, 2024 20:54
Copy link
Collaborator

@smortex smortex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Directly using $docker::params::* is not correct because it contain a default value for a parameter the end user may have provided a specific one.

I added details and a better approach in in-line comments.

Thanks!

Comment on lines +267 to +268
$service_name = $docker::params::service_name
$docker_group = $docker::params::docker_group
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docker class inherits form docker::params and allow personalization of these parameters (using the values from docker::params for default values if not provided).

In order to access $docker::* variables, including this class should be enough:

  include docker

@kenyon
Copy link
Contributor

kenyon commented Apr 19, 2024

Also, params.pp should be eliminated, like what I've done for the APT module in puppetlabs/puppetlabs-apt#1172. This docker module would take a lot more effort though.

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

Successfully merging this pull request may close these issues.

3 participants