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

Drop support for series in bundles #17350

Merged

Conversation

jack-w-shaw
Copy link
Member

@jack-w-shaw jack-w-shaw commented May 7, 2024

Drop support for series in bundles

Support for series in bundles is being dropped in 4.0 (major version
bump). Error out if bundles include series

This means we no longer need to parse series into base in the rest of
our bundle deploy code

We do not want to rely the juju/charm BundleData struct to parse series.
We want to keep this data structure clean, so will be removing from
BundleData very soon Series

As such, we need to parse the bundle ourselves. This requires using a
new miner version of "juju/charm" which allows us to access the raw
unparsed bundle

We can also drop compatibility parsing in bundle handlers

Also, rename checkExplicitSeries to checkExplicitBase and stop checking
if series is provided here.

Also, swap our series for base in test bundles

Checklist

  • Code style: imports ordered, good names, simple structure, etc
  • Comments saying why design decisions were made
  • Go unit tests, with comments saying what you're testing
  • Integration tests, with comments saying what you're testing
  • doc.go added or updated in changed packages

QA steps

Attempt to deploy some bundles

(Note: charmed-kubernetes rev 1243 contains series on the top level bundle, no where else)

$ juju deploy charmed-kubernetes --revision 1243
Located bundle "charmed-kubernetes" in charm-hub, revision 1243
ERROR cannot deploy bundle: the provided bundle has the following errors:
base bundle contains invalid key series:
- document 0; bundle contains top level series
$ cat ./bundle.yaml
default-base: ubuntu@22.04/stable
applications:
  ubuntu:
    charm: ubuntu
    num_units: 1
    to:
    - "0"
machines:
  "0":

$ juju deploy ./bundle.yaml
Located charm "ubuntu" in charm-hub, channel latest/stable
Executing changes:
- upload charm ubuntu from charm-hub for base ubuntu@22.04/stable with architecture=amd64
- deploy application ubuntu from charm-hub on ubuntu@22.04/stable
- add new machine 0
- add unit ubuntu/0 to new machine 0
Deploy of bundle completed.
# We should also be able to deploy by specifying a directory with a bundle
$ juju deploy .
Located charm "ubuntu" in charm-hub, channel latest/stable
Executing changes:
- upload charm ubuntu from charm-hub for base ubuntu@22.04/stable with architecture=amd64
- deploy application ubuntu from charm-hub on ubuntu@22.04/stable
- add new machine 0
- add unit ubuntu/0 to new machine 0
Deploy of bundle completed.
$ cat ./bundle.yaml
series: jammy
applications:
  ubuntu:
    charm: ubuntu
    num_units: 1
    to:
    - "0"
machines:
  "0":

$ juju deploy ./bundle.yaml
ERROR cannot deploy bundle: the provided bundle has the following errors:
base bundle contains invalid key series:
- document 0; bundle contains top level series
$ cat bundle.yaml 
series: jammy
applications:
  ubuntu:
    charm: ubuntu
    series: jammy
    num_units: 1
    to:
    - "0"
machines:
  "0":
    series: jammy

$ juju deploy ./bundle.yaml
ERROR cannot deploy bundle: the provided bundle has the following errors:
base bundle contains invalid key series:
- document 0; bundle contains top level series
- docuemnt 0; bundle application "ubuntu" contains series
- document 0; bundle machine "0" contains series

Attempt to deploy some bundles with overlays

$ cat bundle.yaml
series: jammy
applications:
  ubuntu:
    charm: ubuntu
    num_units: 1
    to:
    - "0"
machines:
  "0":
---
applications:
  ubuntu:
    series: jammy
machines:
  "0":
    series: jammy

$ juju deploy ./bundle.yaml
ERROR cannot deploy bundle: the provided bundle has the following errors:
base bundle contains invalid key series:
- document 0; bundle contains top level series
- docuemnt 1; bundle application "ubuntu" contains series
- document 1; bundle machine "0" contains series
$ cat bundle.yaml
applications:
  ubuntu:
    charm: ubuntu
    num_units: 1
    to:
    - "0"
machines:
  "0":

$ cat overlay1.yaml
applications:
  ubuntu:
    series: jammy
machines:
  "0":
    series: jammy

$ juju deploy ./bundle.yaml --overlay ./overlay1.yaml
ERROR cannot deploy bundle: the provided bundle has the following errors:
overlay index 0 contains invalid key series:
- document 0; bundle application "ubuntu" contains series
- document 0; bundle machine "0" contains series
$ cat bundle.yaml
applications:
  ubuntu:
    charm: ubuntu
    num_units: 1
    to:
    - "0"
machines:
  "0":

$ cat overlay1.yaml
applications:
  ubuntu:
    series: jammy
machines:
  "0":
    series: jammy

$ cat overlay2.yaml
applications:
  ubuntu:
    series: jammy
machines:
  "0":
    series: jammy

$ juju deploy ./bundle.yaml --overlay ./overlay1.yaml --overlay ./overlay2.yaml
ERROR cannot deploy bundle: the provided bundle has the following errors:
overlay index 0 contains invalid key series:
- docuemnt 0; bundle application "ubuntu" contains series
- document 0; bundle machine "0" contains series
overlay index 1 contains invalid key series:
- docuemnt 0; bundle application "ubuntu" contains series
- document 0; bundle machine "0" contains series

Links

Jira card: JUJU-5996

@jack-w-shaw jack-w-shaw force-pushed the JUJU-5996_drop_support_for_series_in_bundles branch from e166f3d to b4ffde6 Compare May 7, 2024 15:07
Copy link
Member

@SimonRichardson SimonRichardson left a comment

Choose a reason for hiding this comment

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

TBH: I think we just remove Series from the bundle code and nothing happens it's just ignored.

cmd/juju/application/bundle/bundle.go Outdated Show resolved Hide resolved
@hpidcock hpidcock added the 4.0 label May 8, 2024
@jack-w-shaw jack-w-shaw force-pushed the JUJU-5996_drop_support_for_series_in_bundles branch 2 times, most recently from 3d366da to 4f0ca93 Compare May 9, 2024 13:40
@jack-w-shaw jack-w-shaw marked this pull request as draft May 9, 2024 13:43
@jack-w-shaw jack-w-shaw force-pushed the JUJU-5996_drop_support_for_series_in_bundles branch from 4f0ca93 to cec4f30 Compare May 9, 2024 14:41
@jack-w-shaw jack-w-shaw force-pushed the JUJU-5996_drop_support_for_series_in_bundles branch from cec4f30 to 4ea92d6 Compare May 16, 2024 12:53
@jack-w-shaw
Copy link
Member Author

TBH: I think we just remove Series from the bundle code and nothing happens it's just ignored.

We have discussed this together further and landed on erroring out if series is provided, but parsing for this in juju/juju

@jack-w-shaw jack-w-shaw force-pushed the JUJU-5996_drop_support_for_series_in_bundles branch from 4ea92d6 to a47fb94 Compare May 16, 2024 13:14
Copy link
Member

@SimonRichardson SimonRichardson left a comment

Choose a reason for hiding this comment

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

This is good to go once we change the method name from RawBytes()

errs := []string{}

// The first dslist is always the bundle itself
bundleErrs := verifyBundleNoSeries(dslist[0].RawBundle())
Copy link
Member

Choose a reason for hiding this comment

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

I know that there is a check above where this is called to check that dslist is empty, but I don't like this coding style. Instead, can this return an empty string if the list is empty.

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean like a catch guard? Sure thing

} else if err != nil {
// The bundle should already have been parsed if we're
// calling this check, so we should not see this
return []string{fmt.Sprintf("programming error: %w", err)}
Copy link
Member

Choose a reason for hiding this comment

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

Remove programming error. I'd just return the error, things can be refactored and seeing programming error is not ideal.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@jack-w-shaw jack-w-shaw force-pushed the JUJU-5996_drop_support_for_series_in_bundles branch from a47fb94 to 072cf14 Compare May 21, 2024 12:06
jujubot added a commit to juju/charm that referenced this pull request May 21, 2024
…eive_raw_bundle

#427

Add this RawBundle method to Bundle interface and BundleDataSource

In Juju, we have come across a need to run some extra parsing + verification which we do not want to do in juju/charm. We want to keep the data model clean in juju/charm.

As such, we need to way to keep the raw bundle data around for later parsing

Add this to BundleDataSource, as this is what we use in Juju

However, we also implement our own BundleDataSource in Juju. built with the Bundle interface here. So we need to add this method to Bundle as well

You can see a draft implementation for this change here:
juju/juju#17350

As a flyby, delete some incorrect comments

## QA Steps

Compile into juju form the following PR and run it's QA steps:
juju/juju#17350
@jack-w-shaw jack-w-shaw force-pushed the JUJU-5996_drop_support_for_series_in_bundles branch from 072cf14 to e1f3aea Compare May 21, 2024 12:56
@jack-w-shaw jack-w-shaw marked this pull request as ready for review May 21, 2024 12:56
Support for series in bundles is being dropped in 4.0 (major version
bump). Error out if bundles include series

This means we no longer need to parse series into base in the rest of
our bundle deploy code

We do not want to rely the juju/charm BundleData struct to parse series.
We want to keep this data structure clean, so will be removing from
BundleData very soon Series

As such, we need to parse the bundle ourselves. This requires using a
new miner version of "juju/charm" which allows us to access the raw
unparsed bundle

Also, swap our series for base in test bundles
@jack-w-shaw jack-w-shaw force-pushed the JUJU-5996_drop_support_for_series_in_bundles branch from e1f3aea to d74fefb Compare May 21, 2024 13:26
@jack-w-shaw
Copy link
Member Author

/merge

1 similar comment
@jack-w-shaw
Copy link
Member Author

/merge

@jujubot jujubot merged commit 2236e27 into juju:main May 21, 2024
15 of 17 checks passed
@jack-w-shaw jack-w-shaw deleted the JUJU-5996_drop_support_for_series_in_bundles branch May 21, 2024 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants