Skip to content

Commit

Permalink
chore: merge branch '3.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyworld committed Jul 18, 2024
2 parents 0b318e9 + 69abb5b commit ed46fd3
Show file tree
Hide file tree
Showing 59 changed files with 674 additions and 207 deletions.
12 changes: 9 additions & 3 deletions apiserver/facades/client/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/juju/juju/apiserver/facade"
"github.com/juju/juju/cloudconfig/podcfg"
"github.com/juju/juju/controller"
"github.com/juju/juju/core/arch"
"github.com/juju/juju/core/cache"
"github.com/juju/juju/core/leadership"
"github.com/juju/juju/core/multiwatcher"
Expand Down Expand Up @@ -327,6 +328,11 @@ func (c *Client) toolVersionsForCAAS(args params.FindToolsParams, streamsVersion
if err != nil {
return result, errors.Trace(err)
}

wantArch := args.Arch
if wantArch == "" {
wantArch = arch.DefaultArchitecture
}
for _, tag := range tags {
number := tag.AgentVersion()
if number.Compare(current) <= 0 {
Expand All @@ -351,21 +357,21 @@ func (c *Client) toolVersionsForCAAS(args params.FindToolsParams, streamsVersion
continue
}
}
arch, err := reg.GetArchitecture(imageName, number.String())
arches, err := reg.GetArchitectures(imageName, number.String())
if errors.IsNotFound(err) {
continue
}
if err != nil {
return result, errors.Annotatef(err, "cannot get architecture for %s:%s", imageName, number.String())
}
if args.Arch != "" && arch != args.Arch {
if !set.NewStrings(arches...).Contains(wantArch) {
continue
}
tools := tools.Tools{
Version: version.Binary{
Number: number,
Release: coreos.HostOSTypeName(),
Arch: arch,
Arch: wantArch,
},
}
result.List = append(result.List, &tools)
Expand Down
31 changes: 21 additions & 10 deletions apiserver/facades/client/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,15 @@ func (s *findToolsSuite) getModelConfig(c *gc.C, agentVersion string) *config.Co
return mCfg
}

func (s *findToolsSuite) TestFindToolsCAASReleasedDefault(c *gc.C) {
s.assertFindToolsCAASReleased(c, "", "amd64")
}

func (s *findToolsSuite) TestFindToolsCAASReleased(c *gc.C) {
s.assertFindToolsCAASReleased(c, "arm64", "arm64")
}

func (s *findToolsSuite) assertFindToolsCAASReleased(c *gc.C, wantArch, expectArch string) {
ctrl := gomock.NewController(c)
defer ctrl.Finish()

Expand All @@ -502,6 +510,9 @@ func (s *findToolsSuite) TestFindToolsCAASReleased(c *gc.C) {
{Version: version.MustParseBinary("2.9.9-ubuntu-amd64")},
{Version: version.MustParseBinary("2.9.10-ubuntu-amd64")},
{Version: version.MustParseBinary("2.9.11-ubuntu-amd64")},
{Version: version.MustParseBinary("2.9.9-ubuntu-arm64")},
{Version: version.MustParseBinary("2.9.10-ubuntu-arm64")},
{Version: version.MustParseBinary("2.9.11-ubuntu-arm64")},
}
s.PatchValue(&coreos.HostOS, func() coreos.OSType { return coreos.Ubuntu })

Expand All @@ -513,7 +524,7 @@ func (s *findToolsSuite) TestFindToolsCAASReleased(c *gc.C) {
authorizer.EXPECT().HasPermission(permission.WriteAccess, coretesting.ModelTag).Return(nil),

backend.EXPECT().Model().Return(model, nil),
toolsFinder.EXPECT().FindAgents(common.FindAgentsParams{MajorVersion: 2}).
toolsFinder.EXPECT().FindAgents(common.FindAgentsParams{MajorVersion: 2, Arch: wantArch}).
Return(simpleStreams, nil),
model.EXPECT().Type().Return(state.ModelTypeCAAS),
model.EXPECT().Config().Return(s.getModelConfig(c, "2.9.9"), nil),
Expand All @@ -536,8 +547,8 @@ func (s *findToolsSuite) TestFindToolsCAASReleased(c *gc.C) {
image.NewImageInfo(version.MustParse("2.9.11")),
image.NewImageInfo(version.MustParse("2.9.12")), // skip: it's not released in simplestream yet.
}, nil),
registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.10").Return("amd64", nil),
registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.11").Return("amd64", nil),
registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.10").Return([]string{"amd64", "arm64"}, nil),
registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.11").Return([]string{"amd64", "arm64"}, nil),
registryProvider.EXPECT().Close().Return(nil),
)

Expand All @@ -558,12 +569,12 @@ func (s *findToolsSuite) TestFindToolsCAASReleased(c *gc.C) {
},
)
c.Assert(err, jc.ErrorIsNil)
result, err := api.FindTools(params.FindToolsParams{MajorVersion: 2})
result, err := api.FindTools(params.FindToolsParams{MajorVersion: 2, Arch: wantArch})
c.Assert(err, jc.ErrorIsNil)
c.Assert(result, gc.DeepEquals, params.FindToolsResult{
List: []*tools.Tools{
{Version: version.MustParseBinary("2.9.10-ubuntu-amd64")},
{Version: version.MustParseBinary("2.9.11-ubuntu-amd64")},
{Version: version.MustParseBinary("2.9.10-ubuntu-" + expectArch)},
{Version: version.MustParseBinary("2.9.11-ubuntu-" + expectArch)},
},
})
}
Expand Down Expand Up @@ -618,10 +629,10 @@ func (s *findToolsSuite) TestFindToolsCAASNonReleased(c *gc.C) {
image.NewImageInfo(version.MustParse("2.9.12")),
image.NewImageInfo(version.MustParse("2.9.13")), // skip: it's not released in simplestream yet.
}, nil),
registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.10.1").Return("amd64", nil),
registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.10").Return("amd64", nil),
registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.11").Return("amd64", nil),
registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.12").Return("", errors.NotFoundf("2.9.12")), // This can only happen on a non-official registry account.
registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.10.1").Return([]string{"amd64", "arm64"}, nil),
registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.10").Return([]string{"amd64", "arm64"}, nil),
registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.11").Return([]string{"amd64", "arm64"}, nil),
registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.12").Return(nil, errors.NotFoundf("2.9.12")), // This can only happen on a non-official registry account.
registryProvider.EXPECT().Close().Return(nil),
)

Expand Down
12 changes: 9 additions & 3 deletions apiserver/facades/client/modelupgrader/findagents.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/juju/juju/apiserver/common"
"github.com/juju/juju/cloudconfig/podcfg"
"github.com/juju/juju/controller"
"github.com/juju/juju/core/arch"
coreos "github.com/juju/juju/core/os"
"github.com/juju/juju/docker"
envtools "github.com/juju/juju/environs/tools"
Expand Down Expand Up @@ -121,6 +122,11 @@ func (m *ModelUpgraderAPI) agentVersionsForCAAS(
if err != nil {
return nil, errors.Trace(err)
}

wantArch := args.Arch
if wantArch == "" {
wantArch = arch.DefaultArchitecture
}
for _, tag := range tags {
number := tag.AgentVersion()
if args.MajorVersion > 0 {
Expand All @@ -145,21 +151,21 @@ func (m *ModelUpgraderAPI) agentVersionsForCAAS(
continue
}
}
arch, err := reg.GetArchitecture(imageName, number.String())
arches, err := reg.GetArchitectures(imageName, number.String())
if errors.Is(err, errors.NotFound) {
continue
}
if err != nil {
return nil, errors.Annotatef(err, "cannot get architecture for %s:%s", imageName, number.String())
}
if args.Arch != "" && arch != args.Arch {
if !set.NewStrings(arches...).Contains(wantArch) {
continue
}
tools := coretools.Tools{
Version: version.Binary{
Number: number,
Release: coreos.HostOSTypeName(),
Arch: arch,
Arch: wantArch,
},
}
result = append(result, &tools)
Expand Down
43 changes: 28 additions & 15 deletions apiserver/facades/client/modelupgrader/upgrader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,15 @@ func (s *modelUpgradeSuite) TestFindToolsIAAS(c *gc.C) {
})
}

func (s *modelUpgradeSuite) TestFindToolsCAASReleasedDefault(c *gc.C) {
s.assertFindToolsCAASReleased(c, "", "amd64")
}

func (s *modelUpgradeSuite) TestFindToolsCAASReleased(c *gc.C) {
s.assertFindToolsCAASReleased(c, "arm64", "arm64")
}

func (s *modelUpgradeSuite) assertFindToolsCAASReleased(c *gc.C, wantArch, expectArch string) {
ctrl, api := s.getModelUpgraderAPI(c)
defer ctrl.Finish()

Expand All @@ -786,13 +794,17 @@ func (s *modelUpgradeSuite) TestFindToolsCAASReleased(c *gc.C) {
{Version: version.MustParseBinary("2.9.9-ubuntu-amd64")},
{Version: version.MustParseBinary("2.9.10-ubuntu-amd64")},
{Version: version.MustParseBinary("2.9.11-ubuntu-amd64")},
{Version: version.MustParseBinary("2.9.9-ubuntu-arm64")},
{Version: version.MustParseBinary("2.9.10-ubuntu-arm64")},
{Version: version.MustParseBinary("2.9.11-ubuntu-arm64")},
}
s.PatchValue(&coreos.HostOS, func() coreos.OSType { return coreos.Ubuntu })

gomock.InOrder(
s.toolsFinder.EXPECT().FindAgents(common.FindAgentsParams{
MajorVersion: 2, MinorVersion: 9,
ModelType: state.ModelTypeCAAS,
Arch: wantArch,
}).Return(simpleStreams, nil),
s.registryProvider.EXPECT().Tags("jujud-operator").Return(coretools.Versions{
image.NewImageInfo(version.MustParse("2.9.8")),
Expand All @@ -802,20 +814,21 @@ func (s *modelUpgradeSuite) TestFindToolsCAASReleased(c *gc.C) {
image.NewImageInfo(version.MustParse("2.9.11")),
image.NewImageInfo(version.MustParse("2.9.12")), // skip: it's not released in simplestream yet.
}, nil),
s.registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.9").Return("amd64", nil),
s.registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.10.1").Return("amd64", nil),
s.registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.10").Return("amd64", nil),
s.registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.11").Return("amd64", nil),
s.registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.9").Return([]string{"amd64", "arm64"}, nil),
s.registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.10.1").Return([]string{"amd64", "arm64"}, nil),
s.registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.10").Return([]string{"amd64", "arm64"}, nil),
s.registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.11").Return([]string{"amd64", "arm64"}, nil),
s.registryProvider.EXPECT().Close().Return(nil),
)

result, err := api.FindAgents(common.FindAgentsParams{MajorVersion: 2, MinorVersion: 9, ModelType: state.ModelTypeCAAS})
result, err := api.FindAgents(common.FindAgentsParams{
MajorVersion: 2, MinorVersion: 9, ModelType: state.ModelTypeCAAS, Arch: wantArch})
c.Assert(err, jc.ErrorIsNil)
c.Assert(result, gc.DeepEquals, coretools.Versions{
&coretools.Tools{Version: version.MustParseBinary("2.9.9-ubuntu-amd64")},
&coretools.Tools{Version: version.MustParseBinary("2.9.10.1-ubuntu-amd64")},
&coretools.Tools{Version: version.MustParseBinary("2.9.10-ubuntu-amd64")},
&coretools.Tools{Version: version.MustParseBinary("2.9.11-ubuntu-amd64")},
&coretools.Tools{Version: version.MustParseBinary("2.9.9-ubuntu-" + expectArch)},
&coretools.Tools{Version: version.MustParseBinary("2.9.10.1-ubuntu-" + expectArch)},
&coretools.Tools{Version: version.MustParseBinary("2.9.10-ubuntu-" + expectArch)},
&coretools.Tools{Version: version.MustParseBinary("2.9.11-ubuntu-" + expectArch)},
})
}

Expand Down Expand Up @@ -845,7 +858,7 @@ func (s *modelUpgradeSuite) TestFindToolsCAASReleasedExact(c *gc.C) {
image.NewImageInfo(version.MustParse("2.9.11")),
image.NewImageInfo(version.MustParse("2.9.12")),
}, nil),
s.registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.10").Return("amd64", nil),
s.registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.10").Return([]string{"amd64"}, nil),
s.registryProvider.EXPECT().Close().Return(nil),
)

Expand Down Expand Up @@ -887,11 +900,11 @@ func (s *modelUpgradeSuite) TestFindToolsCAASNonReleased(c *gc.C) {
image.NewImageInfo(version.MustParse("2.9.12")),
image.NewImageInfo(version.MustParse("2.9.13")), // skip: it's not released in simplestream yet.
}, nil),
s.registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.9").Return("amd64", nil),
s.registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.10.1").Return("amd64", nil),
s.registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.10").Return("amd64", nil),
s.registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.11").Return("amd64", nil),
s.registryProvider.EXPECT().GetArchitecture("jujud-operator", "2.9.12").Return("", errors.NotFoundf("2.9.12")), // This can only happen on a non-official registry account.
s.registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.9").Return([]string{"amd64", "arm64"}, nil),
s.registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.10.1").Return([]string{"amd64", "arm64"}, nil),
s.registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.10").Return([]string{"amd64", "arm64"}, nil),
s.registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.11").Return([]string{"amd64", "arm64"}, nil),
s.registryProvider.EXPECT().GetArchitectures("jujud-operator", "2.9.12").Return(nil, errors.NotFoundf("2.9.12")), // This can only happen on a non-official registry account.
s.registryProvider.EXPECT().Close().Return(nil),
)

Expand Down
22 changes: 18 additions & 4 deletions cmd/juju/action/cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,26 @@ func (c *cancelCommand) SetFlags(f *gnuflag.FlagSet) {
const cancelDoc = `
Cancel pending or running tasks matching given IDs or partial ID prefixes.`

const cancelExamples = `
To cancel a task by ID:
juju cancel-task 1
To cancel multiple tasks by ID:
juju cancel-task 1 2 3
`

func (c *cancelCommand) Info() *cmd.Info {
info := &cmd.Info{
Name: "cancel-task",
Args: "(<task-id>|<task-id-prefix>) [...]",
Purpose: "Cancel pending or running tasks.",
Doc: cancelDoc,
Name: "cancel-task",
Args: "(<task-id>|<task-id-prefix>) [...]",
Purpose: "Cancel pending or running tasks.",
Doc: cancelDoc,
Examples: cancelExamples,
SeeAlso: []string{
"show-task",
},
}
return jujucmd.Info(info)
}
Expand Down
22 changes: 18 additions & 4 deletions cmd/juju/action/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,27 @@ those arguments. For example:
`

const example = `
juju exec --all -- hostname -f
juju exec --unit hello/0 env
juju exec --unit controller/0 juju-engine-report
`

// Info implements Command.Info.
func (c *execCommand) Info() *cmd.Info {
info := jujucmd.Info(&cmd.Info{
Name: "exec",
Args: "<commands>",
Purpose: "Run the commands on the remote targets specified.",
Doc: execDoc,
Name: "exec",
Args: "<commands>",
Purpose: "Run the commands on the remote targets specified.",
Doc: execDoc,
Examples: example,
SeeAlso: []string{
"run",
"ssh",
},
})
return info
}
Expand Down
1 change: 1 addition & 0 deletions cmd/juju/action/showtask.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func (c *showTaskCommand) Info() *cmd.Info {
Doc: showTaskDoc,
Examples: showTaskExamples,
SeeAlso: []string{
"cancel-task",
"run",
"operations",
"show-operation",
Expand Down
3 changes: 3 additions & 0 deletions cmd/juju/agree/agree/agree.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ func (c *agreeCommand) Info() *cmd.Info {
Purpose: "Agree to terms.",
Doc: agreeDoc,
Examples: agreeExamples,
SeeAlso: []string{
"agreements",
},
})
}

Expand Down
18 changes: 11 additions & 7 deletions cmd/juju/agree/listagreements/listagreements.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ In other words, some applications may only be installed if a user agrees to
accept some terms defined by the charm.
This command lists the terms that the user has agreed to.
`

See also:
agree
const listAgreementsExamples = `
juju agreements
`

// NewListAgreementsCommand returns a new command that can be
Expand Down Expand Up @@ -73,10 +73,14 @@ func (c *listAgreementsCommand) SetFlags(f *gnuflag.FlagSet) {
// Info implements Command.Info.
func (c *listAgreementsCommand) Info() *cmd.Info {
return jujucmd.Info(&cmd.Info{
Name: "agreements",
Purpose: "List user's agreements.",
Doc: listAgreementsDoc,
Aliases: []string{"list-agreements"},
Name: "agreements",
Purpose: "List user's agreements.",
Doc: listAgreementsDoc,
Aliases: []string{"list-agreements"},
Examples: listAgreementsExamples,
SeeAlso: []string{
"agree",
},
})
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/juju/application/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ func (c *bindCommand) Info() *cmd.Info {
Purpose: "Change bindings for a deployed application.",
Doc: bindCmdDoc,
Examples: bindCmdExamples,
SeeAlso: []string{
"spaces",
"show-space",
"show-application",
},
})
}

Expand Down
Loading

0 comments on commit ed46fd3

Please sign in to comment.