Skip to content

Commit

Permalink
Merge pull request juju#17461 from jack-w-shaw/3.5-into-3.6
Browse files Browse the repository at this point in the history
juju#17461

Forward merge:
- juju#17348
- juju#17413
- juju#17423
- juju#17436
- juju#17422
- juju#17446
- juju#17448
- juju#17444
- juju#17453
- juju#17440
- juju#17458

Conflicts:
- acceptancetests/jujupy/client.py
- acceptancetests/jujupy/tests/test_status.py
- acceptancetests/repository/trusty/haproxy/cm.py
- acceptancetests/tests/test_jujucharm.py
- cmd/juju/cloud/addcredential.go
- core/base/base.go
- environs/bootstrap/bootstrap.go
- provider/azure/environ.go
- provider/azure/internal/imageutils/images.go
- scripts/win-installer/setup.iss
- snap/snapcraft.yaml
- version/version.go

Conflicts mostly trivial

`provider/azure/internal/imageutils/images.go` took a bit of thought. This conflict resulted from my PR juju#17440
  • Loading branch information
jujubot authored Jun 3, 2024
2 parents 4d6ece0 + 17519ad commit 3076211
Show file tree
Hide file tree
Showing 28 changed files with 324 additions and 92 deletions.
28 changes: 27 additions & 1 deletion cmd/juju/application/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"

"github.com/juju/charm/v12"
"github.com/juju/cmd/v3"
"github.com/juju/errors"
"github.com/juju/names/v5"

Expand Down Expand Up @@ -250,7 +251,7 @@ func applicationConfigValue(key string, valueMap interface{}) (interface{}, erro
// combined bundle data. Returns a slice of errors encountered while
// processing the bundle. They are for informational purposes and do
// not require failing the bundle deployment.
func ComposeAndVerifyBundle(base BundleDataSource, pathToOverlays []string) (*charm.BundleData, []error, error) {
func ComposeAndVerifyBundle(ctx *cmd.Context, base BundleDataSource, pathToOverlays []string) (*charm.BundleData, []error, error) {

verifyConstraints := func(s string) error {
_, err := constraints.Parse(s)
Expand Down Expand Up @@ -286,6 +287,8 @@ func ComposeAndVerifyBundle(base BundleDataSource, pathToOverlays []string) (*ch
return nil, nil, errors.Trace(err)
}

deprecationWarningForSeries(ctx, bundleData)

return bundleData, unMarshallErrors, nil
}

Expand Down Expand Up @@ -355,6 +358,29 @@ func verifyBundle(data *charm.BundleData, bundleDir string, verifyConstraints fu
return errors.Trace(verifyError)
}

func deprecationWarningForSeries(ctx *cmd.Context, data *charm.BundleData) {
includeSeries := false
if data.Series != "" {
includeSeries = true
}
for _, m := range data.Machines {
if m != nil && m.Series != "" {
includeSeries = true
break
}
}
for _, app := range data.Applications {
if app != nil && app.Series != "" {
includeSeries = true
break
}
}

if includeSeries {
ctx.Warningf("series in being deprecated in favour of bases. For more information about the transition to bases see https://discourse.charmhub.io/t/transition-from-series-to-base-in-juju-4-0/14127")
}
}

func verifyMixedSeriesBasesMatch(data *charm.BundleData) error {
if data == nil {
return nil
Expand Down
33 changes: 25 additions & 8 deletions cmd/juju/application/bundle/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"

"github.com/juju/charm/v12"
"github.com/juju/cmd/v3"
"github.com/juju/errors"
jc "github.com/juju/testing/checkers"
"go.uber.org/mock/gomock"
Expand Down Expand Up @@ -213,8 +214,10 @@ func (s *composeAndVerifyRepSuite) TestComposeAndVerifyBundleEmpty(c *gc.C) {
defer s.setupMocks(c).Finish()
s.expectEmptyParts()
s.expectBasePath()
ctx, err := cmd.DefaultContext()
c.Assert(err, jc.ErrorIsNil)

obtained, _, err := ComposeAndVerifyBundle(s.bundleDataSource, nil)
obtained, _, err := ComposeAndVerifyBundle(ctx, s.bundleDataSource, nil)
c.Assert(err, gc.ErrorMatches, ".*bundle is empty not valid")
c.Assert(obtained, gc.IsNil)
}
Expand All @@ -225,8 +228,10 @@ func (s *composeAndVerifyRepSuite) TestComposeAndVerifyBundleUnsupportedConstrai
c.Assert(err, jc.ErrorIsNil)
s.expectParts(&charm.BundleDataPart{Data: bundleData})
s.expectBasePath()
ctx, err := cmd.DefaultContext()
c.Assert(err, jc.ErrorIsNil)

obtained, _, err := ComposeAndVerifyBundle(s.bundleDataSource, nil)
obtained, _, err := ComposeAndVerifyBundle(ctx, s.bundleDataSource, nil)
c.Assert(err, gc.ErrorMatches, "*'image-id' constraint in a base bundle not supported")
c.Assert(obtained, gc.IsNil)
}
Expand All @@ -237,8 +242,10 @@ func (s *composeAndVerifyRepSuite) TestComposeAndVerifyBundleNoOverlay(c *gc.C)
c.Assert(err, jc.ErrorIsNil)
s.expectParts(&charm.BundleDataPart{Data: bundleData})
s.expectBasePath()
ctx, err := cmd.DefaultContext()
c.Assert(err, jc.ErrorIsNil)

obtained, _, err := ComposeAndVerifyBundle(s.bundleDataSource, nil)
obtained, _, err := ComposeAndVerifyBundle(ctx, s.bundleDataSource, nil)
c.Assert(err, jc.ErrorIsNil)
c.Assert(obtained, gc.DeepEquals, bundleData)
}
Expand All @@ -250,13 +257,15 @@ func (s *composeAndVerifyRepSuite) TestComposeAndVerifyBundleOverlay(c *gc.C) {
s.expectParts(&charm.BundleDataPart{Data: bundleData})
s.expectBasePath()
s.setupOverlayFile(c)
ctx, err := cmd.DefaultContext()
c.Assert(err, jc.ErrorIsNil)

expected := *bundleData
expected.Applications["wordpress"].Options = map[string]interface{}{
"blog-title": "magic bundle config",
}

obtained, _, err := ComposeAndVerifyBundle(s.bundleDataSource, []string{s.overlayFile})
obtained, _, err := ComposeAndVerifyBundle(ctx, s.bundleDataSource, []string{s.overlayFile})
c.Assert(err, jc.ErrorIsNil)
c.Assert(obtained, gc.DeepEquals, &expected)
}
Expand All @@ -268,13 +277,15 @@ func (s *composeAndVerifyRepSuite) TestComposeAndVerifyBundleOverlayUnsupportedC
s.expectParts(&charm.BundleDataPart{Data: bundleData})
s.expectBasePath()
s.setupOverlayFile(c)
ctx, err := cmd.DefaultContext()
c.Assert(err, jc.ErrorIsNil)

expected := *bundleData
expected.Applications["wordpress"].Options = map[string]interface{}{
"blog-title": "magic bundle config",
}

obtained, _, err := ComposeAndVerifyBundle(s.bundleDataSource, []string{s.overlayFile})
obtained, _, err := ComposeAndVerifyBundle(ctx, s.bundleDataSource, []string{s.overlayFile})
c.Assert(err, gc.ErrorMatches, "*'image-id' constraint in a base bundle not supported")
c.Assert(obtained, gc.IsNil)
}
Expand All @@ -290,13 +301,15 @@ func (s *composeAndVerifyRepSuite) TestComposeAndVerifyBundleOverlayUnmarshallEr
})
s.expectBasePath()
s.setupOverlayFile(c)
ctx, err := cmd.DefaultContext()
c.Assert(err, jc.ErrorIsNil)

expected := *bundleData
expected.Applications["wordpress"].Options = map[string]interface{}{
"blog-title": "magic bundle config",
}

obtained, unmarshallErrors, err := ComposeAndVerifyBundle(s.bundleDataSource, []string{s.overlayFile})
obtained, unmarshallErrors, err := ComposeAndVerifyBundle(ctx, s.bundleDataSource, []string{s.overlayFile})
c.Assert(err, jc.ErrorIsNil)
c.Assert(obtained, gc.DeepEquals, &expected)
c.Assert(unmarshallErrors, gc.HasLen, 1)
Expand All @@ -309,8 +322,10 @@ func (s *composeAndVerifyRepSuite) TestComposeAndVerifyBundleMixingBaseAndSeries
c.Assert(err, jc.ErrorIsNil)
s.expectParts(&charm.BundleDataPart{Data: bundleData})
s.expectBasePath()
ctx, err := cmd.DefaultContext()
c.Assert(err, jc.ErrorIsNil)

obtained, _, err := ComposeAndVerifyBundle(s.bundleDataSource, nil)
obtained, _, err := ComposeAndVerifyBundle(ctx, s.bundleDataSource, nil)
c.Assert(err, jc.ErrorIsNil)
c.Assert(obtained, gc.DeepEquals, bundleData)
}
Expand All @@ -321,8 +336,10 @@ func (s *composeAndVerifyRepSuite) TestComposeAndVerifyBundleMixingBaseAndSeries
c.Assert(err, jc.ErrorIsNil)
s.expectParts(&charm.BundleDataPart{Data: bundleData})
s.expectBasePath()
ctx, err := cmd.DefaultContext()
c.Assert(err, jc.ErrorIsNil)

obtained, _, err := ComposeAndVerifyBundle(s.bundleDataSource, []string{s.overlayFile})
obtained, _, err := ComposeAndVerifyBundle(ctx, s.bundleDataSource, []string{s.overlayFile})
c.Assert(err, gc.ErrorMatches, `(?s)the provided bundle has the following errors:.*application "wordpress" series "jammy" and base "[email protected]" must match if both supplied.*invalid constraints.*`)
c.Assert(obtained, gc.IsNil)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/application/deployer/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (d *deployBundle) deploy(
d.accountUser = accountDetails.User

// Compose bundle to be deployed and check its validity.
bundleData, unmarshalErrors, err := bundle.ComposeAndVerifyBundle(d.bundleDataSource, d.bundleOverlayFile)
bundleData, unmarshalErrors, err := bundle.ComposeAndVerifyBundle(ctx, d.bundleDataSource, d.bundleOverlayFile)
if err != nil {
return errors.Annotatef(err, "cannot deploy bundle")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/application/diffbundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (c *diffBundleCommand) Run(ctx *cmd.Context) error {
return errors.Trace(err)
}

bundle, _, err := appbundle.ComposeAndVerifyBundle(baseSrc, c.bundleOverlays)
bundle, _, err := appbundle.ComposeAndVerifyBundle(ctx, baseSrc, c.bundleOverlays)
if err != nil {
return errors.Trace(err)
}
Expand Down
1 change: 0 additions & 1 deletion cmd/juju/cloud/addcredential.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ Use --controller option to upload a credential to a controller.
Use --client option to add a credential to the current client.
`

const usageAddCredentialExamples = `
Expand Down
3 changes: 0 additions & 3 deletions cmd/juju/cloud/addcredential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,6 @@ Enter credential name:
Using auth-type "jsonfile".
Enter path to the .json file containing a service account key for your project
(detailed instructions available at https://discourse.charmhub.io/t/1508).
Path:
`[1:]
stderr := `
Expand Down Expand Up @@ -973,7 +972,6 @@ Enter your choice, or type Q|q to quit: Enter credential name:
Using auth-type "jsonfile".
Enter path to the .json file containing a service account key for your project
(detailed instructions available at https://discourse.charmhub.io/t/1508).
Path:
Credential "blah" added locally for cloud "remote".
Expand Down Expand Up @@ -1002,7 +1000,6 @@ Enter credential name:
Using auth-type "jsonfile".
Enter path to the .json file containing a service account key for your project
(detailed instructions available at https://discourse.charmhub.io/t/1508).
Path:
`[1:]
stderr := `
Expand Down
19 changes: 19 additions & 0 deletions core/base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,25 @@ func (b Base) IsCompatible(other Base) bool {
return b.OS == other.OS && b.Channel.Track == other.Channel.Track
}

// ubuntuLTSes lists the Ubuntu LTS releases that
// this version of Juju knows about
var ubuntuLTSes = []Base{
MakeDefaultBase(UbuntuOS, "20.04"),
MakeDefaultBase(UbuntuOS, "22.04"),
MakeDefaultBase(UbuntuOS, "24.04"),
}

// IsUbuntuLTS returns true if this base is a recognised
// Ubuntu LTS.
func (b Base) IsUbuntuLTS() bool {
for _, ubuntuLTS := range ubuntuLTSes {
if b.IsCompatible(ubuntuLTS) {
return true
}
}
return false
}

// DisplayString returns the base string ignoring risk.
func (b Base) DisplayString() string {
if b.Channel.Track == "" || b.OS == "" {
Expand Down
38 changes: 38 additions & 0 deletions core/base/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,41 @@ func (s *BaseSuite) TestParseManifestBases(c *gc.C) {
}
c.Assert(obtained, jc.DeepEquals, expected)
}

var ubuntuLTS = []Base{
MustParseBaseFromString("[email protected]"),
MustParseBaseFromString("[email protected]"),
MustParseBaseFromString("[email protected]"),
MustParseBaseFromString("[email protected]/stable"),
MustParseBaseFromString("[email protected]/edge"),
}

func (s *BaseSuite) TestIsUbuntuLTSForLTSes(c *gc.C) {
for i, lts := range ubuntuLTS {
c.Logf("Checking index %d base %v", i, lts)
c.Check(lts.IsUbuntuLTS(), jc.IsTrue)
}
}

var nonUbuntuLTS = []Base{
MustParseBaseFromString("[email protected]"),
MustParseBaseFromString("[email protected]"),
MustParseBaseFromString("[email protected]"),

MustParseBaseFromString("[email protected]"),
MustParseBaseFromString("[email protected]"),
MustParseBaseFromString("[email protected]"),

MustParseBaseFromString("[email protected]"),
MustParseBaseFromString("[email protected]"),

MustParseBaseFromString("centos@7"),
MustParseBaseFromString("[email protected]"),
}

func (s *BaseSuite) TestIsUbuntuLTSForNonLTSes(c *gc.C) {
for i, lts := range nonUbuntuLTS {
c.Logf("Checking index %d base %v", i, lts)
c.Check(lts.IsUbuntuLTS(), jc.IsFalse)
}
}
3 changes: 0 additions & 3 deletions provider/azure/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,9 +1085,6 @@ func newOSProfile(
}

instOS := ostype.OSTypeForName(instanceConfig.Base.OS)
if err != nil {
return nil, ostype.Unknown, errors.Trace(err)
}
switch instOS {
case ostype.Ubuntu, ostype.CentOS:
// SSH keys are handled by custom data, but must also be
Expand Down
2 changes: 1 addition & 1 deletion provider/azure/instancetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ func (env *azureEnviron) findInstanceSpec(
if err != nil {
return nil, errors.Trace(err)
}
image, err := imageutils.SeriesImage(ctx, constraint.Base, imageStream, constraint.Region, client)
image, err := imageutils.BaseImage(ctx, constraint.Base, imageStream, constraint.Region, client)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down
Loading

0 comments on commit 3076211

Please sign in to comment.