Skip to content

Commit

Permalink
Merge pull request juju#17674 from wallyworld/merge-3.4-20240708
Browse files Browse the repository at this point in the history
juju#17674

Merge 3.4

juju#17647 [from ycliuhw/fix-misleading-error4strictly-…](juju@7489150)
juju#17644 [from Aflynn50/fix-refresh-command-docs](juju@39772ee)
juju#17641 [from hpidcock/fix-secretexpire-worker-tests](juju@c7a6f6f)
juju#17662 [from wallyworld/fix-lxd-profile](juju@a3617b6)

```
# Conflicts:
# go.mod
#
```
  • Loading branch information
jujubot authored Jul 7, 2024
2 parents 3f404f4 + bcd6bdc commit 5f11a3e
Show file tree
Hide file tree
Showing 24 changed files with 479 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/terraform-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

smoke:
name: Terraform Smoke
runs-on: [self-hosted, linux, x64, aws, xlarge]
runs-on: [self-hosted, linux, x64, aws, xxlarge]
if: github.event.pull_request.draft == false
steps:

Expand Down
5 changes: 2 additions & 3 deletions apiserver/common/charms/appcharminfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
facademocks "github.com/juju/juju/apiserver/facade/mocks"
"github.com/juju/juju/core/permission"
"github.com/juju/juju/rpc/params"
"github.com/juju/juju/state"
)

type appCharmInfoSuite struct{}
Expand Down Expand Up @@ -47,7 +46,7 @@ func (s *appCharmInfoSuite) TestBasic(c *gc.C) {
ch.EXPECT().Actions().Return(&charm.Actions{})
ch.EXPECT().Metrics().Return(&charm.Metrics{})
ch.EXPECT().Manifest().Return(&charm.Manifest{})
ch.EXPECT().LXDProfile().Return(&state.LXDProfile{})
ch.EXPECT().LXDProfile().Return(&charm.LXDProfile{})

authorizer := facademocks.NewMockAuthorizer(ctrl)
authorizer.EXPECT().AuthController().Return(true)
Expand Down Expand Up @@ -134,7 +133,7 @@ func (s *appCharmInfoSuite) TestSidecarCharm(c *gc.C) {
ch.EXPECT().Actions().Return(&charm.Actions{})
ch.EXPECT().Metrics().Return(&charm.Metrics{})
ch.EXPECT().Manifest().Return(&charm.Manifest{})
ch.EXPECT().LXDProfile().Return(&state.LXDProfile{})
ch.EXPECT().LXDProfile().Return(&charm.LXDProfile{})

authorizer := facademocks.NewMockAuthorizer(ctrl)
authorizer.EXPECT().AuthController().Return(true)
Expand Down
3 changes: 1 addition & 2 deletions apiserver/common/charms/charminfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
facademocks "github.com/juju/juju/apiserver/facade/mocks"
"github.com/juju/juju/core/permission"
"github.com/juju/juju/rpc/params"
"github.com/juju/juju/state"
)

type charmInfoSuite struct{}
Expand All @@ -41,7 +40,7 @@ func (s *charmInfoSuite) TestBasic(c *gc.C) {
ch.EXPECT().Actions().Return(&charm.Actions{})
ch.EXPECT().Metrics().Return(&charm.Metrics{})
ch.EXPECT().Manifest().Return(&charm.Manifest{})
ch.EXPECT().LXDProfile().Return(&state.LXDProfile{})
ch.EXPECT().LXDProfile().Return(&charm.LXDProfile{})
ch.EXPECT().URL().Return("ch:foo-1")

authorizer := facademocks.NewMockAuthorizer(ctrl)
Expand Down
4 changes: 2 additions & 2 deletions apiserver/common/charms/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Charm interface {
Manifest() *charm.Manifest
Metrics() *charm.Metrics
Actions() *charm.Actions
LXDProfile() *state.LXDProfile
LXDProfile() *charm.LXDProfile
}

type Model interface {
Expand Down Expand Up @@ -335,7 +335,7 @@ func convertCharmExtraBindingMap(bindings map[string]charm.ExtraBinding) map[str
return result
}

func convertCharmLXDProfile(profile *state.LXDProfile) *params.CharmLXDProfile {
func convertCharmLXDProfile(profile *charm.LXDProfile) *params.CharmLXDProfile {
return &params.CharmLXDProfile{
Description: profile.Description,
Config: convertCharmLXDProfileConfig(profile.Config),
Expand Down
5 changes: 2 additions & 3 deletions apiserver/common/charms/mocks/mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions apiserver/facades/client/application/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (s *applicationSuite) TestApplicationDeployToMachineWithLXDProfile(c *gc.C)
c.Assert(expected.Config(), gc.DeepEquals, ch.Config())

expectedProfile := ch.(charm.LXDProfiler).LXDProfile()
c.Assert(expected.LXDProfile(), gc.DeepEquals, &state.LXDProfile{
c.Assert(expected.LXDProfile(), gc.DeepEquals, &charm.LXDProfile{
Description: expectedProfile.Description,
Config: expectedProfile.Config,
Devices: expectedProfile.Devices,
Expand Down Expand Up @@ -357,7 +357,7 @@ func (s *applicationSuite) TestApplicationDeployToMachineWithInvalidLXDProfileAn
c.Assert(expected.Config(), gc.DeepEquals, ch.Config())

expectedProfile := ch.(charm.LXDProfiler).LXDProfile()
c.Assert(expected.LXDProfile(), gc.DeepEquals, &state.LXDProfile{
c.Assert(expected.LXDProfile(), gc.DeepEquals, &charm.LXDProfile{
Description: expectedProfile.Description,
Config: expectedProfile.Config,
Devices: expectedProfile.Devices,
Expand Down
4 changes: 2 additions & 2 deletions cmd/juju/application/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ is determined by the contents of the charm at the specified path.
--switch and --revision are mutually exclusive.
Use of the --force-units option is not generally recommended; units upgraded
while in an error state will not have refreshed hooks executed, and may cause
unexpected behavior.
while in an error state will not have upgrade-charm hooks executed, and may
cause unexpected behavior.
--force option for LXD Profiles is not generally recommended when upgrading an
application; overriding profiles on the container may cause unexpected
Expand Down
26 changes: 10 additions & 16 deletions cmd/juju/caas/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -876,34 +876,28 @@ func (c *AddCAASCommand) getClusterMetadataFunc(ctx *cmd.Context) provider.GetCl
}

func (c *AddCAASCommand) verifyName(name string) error {
public, _, err := c.cloudMetadataStore.PublicCloudMetadata()
if err != nil {
return err
if name == k8s.K8sCloudMicrok8s {
return fmt.Errorf(`%q is the name of a built-in cloud.
If you want to use Juju with microk8s, the recommended way is to install the strictly confined microk8s snap.
Using the strictly confined microk8s snap means that Juju and microk8s will work together out of the box.`, name)
}
msg, err := nameExists(name, public)

public, _, err := c.cloudMetadataStore.PublicCloudMetadata()
if err != nil {
return errors.Trace(err)
}
if msg != "" {
return errors.Errorf(msg)
}
return nil
}

// nameExists returns either an empty string if the name does not exist, or a
// non-empty string with an error message if it does exist.
func nameExists(name string, public map[string]jujucloud.Cloud) (string, error) {
if _, ok := public[name]; ok {
return fmt.Sprintf("%q is the name of a public cloud", name), nil
return fmt.Errorf("%q is the name of a public cloud", name)
}
builtin, err := common.BuiltInClouds()
if err != nil {
return "", errors.Trace(err)
return errors.Trace(err)
}
if _, ok := builtin[name]; ok {
return fmt.Sprintf("%q is the name of a built-in cloud", name), nil
return fmt.Errorf("%q is the name of a built-in cloud", name)
}
return "", nil
return nil
}

func addCloudToLocal(cloudMetadataStore CloudMetadataStore, newCloud jujucloud.Cloud) error {
Expand Down
9 changes: 9 additions & 0 deletions cmd/juju/caas/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ func (s *addCAASSuite) TestMissingName(c *gc.C) {
c.Assert(err, gc.ErrorMatches, `missing k8s name.`)
}

func (s *addCAASSuite) TestInvalidName(c *gc.C) {
command := s.makeCommand(c, true, true, true)
_, err := s.runCommand(c, nil, command, "microk8s")
c.Assert(err, gc.ErrorMatches, `
"microk8s" is the name of a built-in cloud.
If you want to use Juju with microk8s, the recommended way is to install the strictly confined microk8s snap.
Using the strictly confined microk8s snap means that Juju and microk8s will work together out of the box.`[1:])
}

func (s *addCAASSuite) TestMissingArgs(c *gc.C) {
command := s.makeCommand(c, true, true, true)
_, err := s.runCommand(c, nil, command)
Expand Down
42 changes: 42 additions & 0 deletions cmd/output/progress/mocks/clock_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions container/lxd/mocks/clock_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ require (
github.com/juju/ansiterm v1.0.0
github.com/juju/blobstore/v3 v3.0.2
github.com/juju/charm/v12 v12.0.2
github.com/juju/clock v1.0.3
github.com/juju/clock v1.1.1
github.com/juju/cmd/v3 v3.0.14
github.com/juju/collections v1.0.4
github.com/juju/description/v5 v5.0.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,8 @@ github.com/juju/clock v0.0.0-20190205081909-9c5c9712527c/go.mod h1:nD0vlnrUjcjJh
github.com/juju/clock v0.0.0-20220202072423-1b0f830854c4/go.mod h1:zDZCPSgCJQINeZtQwHx2/cFk4seaBC8Yiqe8V82xiP0=
github.com/juju/clock v0.0.0-20220203021603-d9deb868a28a/go.mod h1:GZ/FY8Cqw3KHG6DwRVPUKbSPTAwyrU28xFi5cqZnLsc=
github.com/juju/clock v1.0.0/go.mod h1:GZ/FY8Cqw3KHG6DwRVPUKbSPTAwyrU28xFi5cqZnLsc=
github.com/juju/clock v1.0.3 h1:yJHIsWXeU8j3QcBdiess09SzfiXRRrsjKPn2whnMeds=
github.com/juju/clock v1.0.3/go.mod h1:HIBvJ8kiV/n7UHwKuCkdYL4l/MDECztHR2sAvWDxxf0=
github.com/juju/clock v1.1.1 h1:NvgHG9DQmOpBevgt6gzkyimdWBooLXDy1cQn89qJzBI=
github.com/juju/clock v1.1.1/go.mod h1:HIBvJ8kiV/n7UHwKuCkdYL4l/MDECztHR2sAvWDxxf0=
github.com/juju/cmd v0.0.0-20171107070456-e74f39857ca0/go.mod h1:yWJQHl73rdSX4DHVKGqkAip+huBslxRwS8m9CrOLq18=
github.com/juju/cmd/v3 v3.0.0-20220202061353-b1cc80b193b0/go.mod h1:EoGJiEG+vbMwO9l+Es0SDTlaQPjH6nLcnnc4NfZB3cY=
github.com/juju/cmd/v3 v3.0.14 h1:KuuamArSH7vQ6SdQKEHYK2scEMkJTEZKLs8abrlW3XE=
Expand Down
42 changes: 42 additions & 0 deletions service/snap/clock_mock_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions state/charm.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func insertCharmOps(mb modelBackend, info CharmInfo) ([]txn.Op, error) {
}
lpc, ok := info.Charm.(charm.LXDProfiler)
if !ok {
return nil, errors.New("charm does no implement LXDProfiler")
return nil, errors.New("charm does not implement LXDProfiler")
}
doc.LXDProfile = safeLXDProfile(lpc.LXDProfile())

Expand Down Expand Up @@ -490,6 +490,8 @@ type Charm struct {
charmURL *charm.URL
}

var _ charm.LXDProfiler = (*Charm)(nil)

func newCharm(st *State, cdoc *charmDoc) *Charm {
// Because we probably just read the doc from state, make sure we
// unescape any config option names for "$" and ".". See
Expand Down Expand Up @@ -678,8 +680,15 @@ func (c *Charm) Actions() *charm.Actions {
}

// LXDProfile returns the lxd profile definition of the charm.
func (c *Charm) LXDProfile() *LXDProfile {
return c.doc.LXDProfile
func (c *Charm) LXDProfile() *charm.LXDProfile {
if c.doc.LXDProfile == nil {
return nil
}
return &charm.LXDProfile{
Config: c.doc.LXDProfile.Config,
Description: c.doc.LXDProfile.Description,
Devices: c.doc.LXDProfile.Devices,
}
}

// StoragePath returns the storage path of the charm bundle.
Expand Down
Loading

0 comments on commit 5f11a3e

Please sign in to comment.