Add bundle-config option for deploying bundles. #7825

Merged
merged 1 commit into from Sep 5, 2017

Conversation

Projects
None yet
3 participants
Owner

howbazaar commented Sep 5, 2017

This branch adds a --bundle-config option for the deploy command that allows the user to specify a config YAML file that is used to augment the bundle before any validation is called.

This allows people to have a standard bundle defined for generic deployment and have custom configuration of that bundle handled in a different file. The new include-file and include-base64 values for options and annotations are also allowed in the bundle-config YAML.

The contents of the bundle-config file currently matches the applications component of a normal bundle. Any values specified in the bundle-config will override the bundle values. The exception to this is maps, where the values are augmented.

This branch also refactors a few of the deploy tests for better clarity, and also removes the special resources suite as it was rerunning all the standard deploy tests.

QA steps

Create a file called metrics.yaml and have this content:

series: xenial
applications:
  grafana:
    charm: cs:~prometheus-charmers/grafana
    num_units: 1
    to:
     - "3"
  prometheus:
    charm: cs:~prometheus-charmers/prometheus
    num_units: 1
    to:
      - "3"
machines:
  "3":
    annotations:
      foo: bar
relations:
  -  - prometheus:grafana-source
     - grafana:grafana-source

Now create another file called config.yaml with this contents:

applications:
  prometheus:
    options:
      scrape-jobs: include://scrape-jobs.yaml

And create a file called scrape-jobs.yaml in the same directory as the config.yaml.

  - job_name: machine-0
    metrics_path: /introspection/metrics
    scheme: https
    static_configs:
      - targets: ['10.250.171.239:17070']
    basic_auth:
      username: user-prometheus
      password: password
    tls_config:
      ca_file: /var/snap/prometheus/current/controller-ca.cert
  - job_name: machine-1
    metrics_path: /introspection/metrics
    scheme: https
    static_configs:
      - targets: ['10.250.171.3:17070']
    basic_auth:
      username: user-prometheus
      password: password
    tls_config:
      ca_file: /var/snap/prometheus/current/controller-ca.cert
  - job_name: machine-2
    metrics_path: /introspection/metrics
    scheme: https
    static_configs:
      - targets: ['10.250.171.220:17070']
    basic_auth:
      username: user-prometheus
      password: password
    tls_config:
      ca_file: /var/snap/prometheus/current/controller-ca.cert
# specifying bundle-config for charm deploys errors.
$ juju deploy wordpress --bundle-config foo

$ juju deploy ./metrics.yaml --bundle-config config.yaml

Wait for deploy, then check the scrape-jobs settings of the prometheus application.

$ juju config prometheus scrape-jobs

Documentation changes

Yes, documentation will need to be updated for bundle deploys.

Looks good to me!

+
+ fieldCheck := configCheck.Applications[appName]
+
+ if _, set := fieldCheck["charm"]; set {
@babbageclunk

babbageclunk Sep 5, 2017

Member

This stuff's kind of messy and a bit gross - it seems like there should be a cleaner way that doesn't require you to know the mapping between attrs and yaml keys and do all the map overlaying, but I can't see what it would be.

@@ -444,7 +448,7 @@ var (
// charmOnlyFlags and bundleOnlyFlags are used to validate flags based on
// whether we are deploying a charm or a bundle.
charmOnlyFlags = []string{"bind", "config", "constraints", "force", "n", "num-units", "series", "to", "resource"}
- bundleOnlyFlags = []string{}
@babbageclunk

babbageclunk Sep 5, 2017

Member

Lucky this already existed! Was it vestigial?

@howbazaar

howbazaar Sep 5, 2017

Owner

I don't know.

Owner

howbazaar commented Sep 5, 2017

$$merge$$

Contributor

jujubot commented Sep 5, 2017

Status: merge request accepted. Url: http://ci.jujucharms.com/job/github-merge-juju

@jujubot jujubot merged commit 244574b into juju:2.2 Sep 5, 2017

1 check passed

continuous-integration/jenkins/pr-merge This commit looks good
Details

@howbazaar howbazaar deleted the howbazaar:2.2-bundle-config branch Sep 5, 2017

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