canonical / ua-reviewkit

3 stars 6 forks source link

ua-bundle-check fails when overlays are present in the exported bundle #25

Open anna-savchenko opened 1 year ago

anna-savchenko commented 1 year ago

When overlays (e.g. LMA offers) are present in the exported bundle, ua-bundle-check fails with the below error:

$ ./ua-bundle-check.py --bundle ../../exported-bundle.yaml
================================================================================
UA Juju bundle config verification
 * 2022-09-02 13:19:46.272974
 * type=openstack
 * bundle=../../exported-bundle.yaml
 * bundle_sha1=<removed>
 * assertions_sha1=<removed>
================================================================================
ERROR: Error parsing the bundle file: expected a single document in the stream
  in "<unicode string>", line 1, column 1:
    series: focal
    ^
but found another document
  in "<unicode string>", line 3758, column 1:
    --- # overlay.yaml
    ^
Please check the above errors and run again.

Overlay in the exported bundle:

--- # overlay.yaml
applications:
  logstash-server:
    offers:
      logstash-beat:
        endpoints:
        - beat
        acl:
          admin: admin
  nagios:
    offers:
      nagios-monitors:
        endpoints:
        - monitors
        acl:
          admin: admin
  prometheus:
    offers:
      prometheus-target:
        endpoints:
        - target
        acl:
          admin: admin
sombrafam commented 1 year ago

Hi @anna-savchenko , the first line of the bundle is not a valid yaml tag. Can you remove it and run again?

anna-savchenko commented 1 year ago

Hey, @sombrafam I tried removing --- # overlay.yaml but the bundle check still fails. I think it's because the applications are in the exported bundle twice - the ones from the main bundle and the overlay (LMA offers). The bundle check only works when I remove the overlay applications from the exported bundle.

vernhart commented 1 year ago

I have encountered this as well. This seems to happen when the model has offers available such as LMA or COS. I've uploaded my bundle. The issue is that juju is creating a yaml file with multiple documents using the triple-dash (---) separator. cos-bundle.yaml.txt You can use csplit and yq to merge all documents in a single yaml file:

csplit --prefix=bundle-parts cos-bundle.yaml '/---/'
yq eval-all '. as $item ireduce ({}; . * $item )' bundle-parts*

You can then run the ua-bundle-check on the results, but the ua-bundle-check doesn't know what to do with an LMA or COS bundle so this may not be a pressing issue.