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

Merge 2.9 into develop #14452

Merged
merged 21 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
015f4fe
Removes the requirement to disable v6 for lxd.
tlm Aug 4, 2022
a96f051
[ck test] increase teardown timeout to 60m
barrettj12 Aug 4, 2022
9428f8d
[ck test] kill controller afterwards
barrettj12 Aug 5, 2022
1e89108
Fix controller name in ck test teardown
wallyworld Aug 5, 2022
5281f44
Kill controller at end of ck test
wallyworld Aug 8, 2022
6947102
Added agent-metadata-url and agent stream to pre_bootstrap
anvial Aug 8, 2022
bcb73bc
Added SHORT_GIT_COMMIT env var check.
anvial Aug 8, 2022
c42b3f4
Fixed statis-analysis.
anvial Aug 8, 2022
958ad6b
Add credential format example for GCE for add-credential command;
ycliuhw Aug 9, 2022
2122430
Added model-defaults agent-metadata-url, agent-stream.
anvial Aug 9, 2022
806e768
Added JUJU_VERSION check to manually set the version for tests.
anvial Aug 9, 2022
6e1119d
Added arch constraints in bundle yaml, which depends on MODEL_ARCH.
anvial Aug 9, 2022
f8ddaa8
Fix test race in dummy provider
wallyworld Aug 10, 2022
480c14d
[smoke test] add timeout
barrettj12 Jul 18, 2022
a07214b
[bash tests] change wait_for timeout from attempts to seconds
barrettj12 Jul 22, 2022
1fd5d71
[ck test] Add 5 min timeout for mariadb-k8s
barrettj12 Aug 10, 2022
be348dc
[refresh] correct error when local charm not found
barrettj12 Aug 10, 2022
4cca482
Added dependency check for yq. Removed installation code of yq from t…
anvial Aug 10, 2022
c956dfa
Fixed whitespace issue in case MODEL_ARCH is undefined.
anvial Aug 11, 2022
ed2f41b
Fixed statis-analysis..
anvial Aug 11, 2022
26a57a7
Remnamed exported-bundle.yaml to exported_bundle.yaml.
anvial Aug 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agent/tools/symlinks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var _ = gc.Suite(&SymlinksSuite{})

func (s *SymlinksSuite) SetUpTest(c *gc.C) {
s.dataDir = c.MkDir()
s.toolsDir = tools.SharedToolsDir(s.dataDir, testing.CurrentVersion(c))
s.toolsDir = tools.SharedToolsDir(s.dataDir, testing.CurrentVersion())
err := os.MkdirAll(s.toolsDir, 0755)
c.Assert(err, jc.ErrorIsNil)
c.Logf("created %s", s.toolsDir)
Expand Down
2 changes: 1 addition & 1 deletion api/agent/provisioner/provisioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ func (s *provisionerSuite) TestFindToolsLogicError(c *gc.C) {
}

func (s *provisionerSuite) testFindTools(c *gc.C, matchArch bool, apiError, logicError error) {
current := coretesting.CurrentVersion(c)
current := coretesting.CurrentVersion()
var toolsList = coretools.List{&coretools.Tools{Version: current}}
var called bool
var a string
Expand Down
10 changes: 5 additions & 5 deletions api/agent/upgrader/unitupgrader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ func (s *unitUpgraderSuite) addMachineApplicationCharmAndUnit(c *gc.C, appName s
}

func (s *unitUpgraderSuite) TestSetVersionWrongUnit(c *gc.C) {
err := s.st.SetVersion("unit-wordpress-42", testing.CurrentVersion(c))
err := s.st.SetVersion("unit-wordpress-42", testing.CurrentVersion())
c.Assert(err, gc.ErrorMatches, "permission denied")
c.Assert(err, jc.Satisfies, params.IsCodeUnauthorized)
}

func (s *unitUpgraderSuite) TestSetVersionNotUnit(c *gc.C) {
err := s.st.SetVersion("foo-42", testing.CurrentVersion(c))
err := s.st.SetVersion("foo-42", testing.CurrentVersion())
c.Assert(err, gc.ErrorMatches, "permission denied")
c.Assert(err, jc.Satisfies, params.IsCodeUnauthorized)
}

func (s *unitUpgraderSuite) TestSetVersion(c *gc.C) {
current := testing.CurrentVersion(c)
current := testing.CurrentVersion()
agentTools, err := s.rawUnit.AgentTools()
c.Assert(err, jc.Satisfies, errors.IsNotFound)
c.Assert(agentTools, gc.IsNil)
Expand All @@ -115,7 +115,7 @@ func (s *unitUpgraderSuite) TestToolsNotUnit(c *gc.C) {
}

func (s *unitUpgraderSuite) TestTools(c *gc.C) {
current := testing.CurrentVersion(c)
current := testing.CurrentVersion()
curTools := &tools.Tools{Version: current, URL: ""}
curTools.Version.Minor++
s.rawMachine.SetAgentVersion(current)
Expand Down Expand Up @@ -162,7 +162,7 @@ func (s *unitUpgraderSuite) TestWatchAPIVersionNotUnit(c *gc.C) {
}

func (s *unitUpgraderSuite) TestDesiredVersion(c *gc.C) {
current := testing.CurrentVersion(c)
current := testing.CurrentVersion()
curTools := &tools.Tools{Version: current, URL: ""}
curTools.Version.Minor++
s.rawMachine.SetAgentVersion(current)
Expand Down
10 changes: 5 additions & 5 deletions api/agent/upgrader/upgrader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ func (s *machineUpgraderSuite) TestNew(c *gc.C) {
}

func (s *machineUpgraderSuite) TestSetVersionWrongMachine(c *gc.C) {
err := s.st.SetVersion("machine-42", coretesting.CurrentVersion(c))
err := s.st.SetVersion("machine-42", coretesting.CurrentVersion())
c.Assert(err, gc.ErrorMatches, "permission denied")
c.Assert(err, jc.Satisfies, params.IsCodeUnauthorized)
}

func (s *machineUpgraderSuite) TestSetVersionNotMachine(c *gc.C) {
err := s.st.SetVersion("foo-42", coretesting.CurrentVersion(c))
err := s.st.SetVersion("foo-42", coretesting.CurrentVersion())
c.Assert(err, gc.ErrorMatches, "permission denied")
c.Assert(err, jc.Satisfies, params.IsCodeUnauthorized)
}

func (s *machineUpgraderSuite) TestSetVersion(c *gc.C) {
current := coretesting.CurrentVersion(c)
current := coretesting.CurrentVersion()
agentTools, err := s.rawMachine.AgentTools()
c.Assert(err, jc.Satisfies, errors.IsNotFound)
c.Assert(agentTools, gc.IsNil)
Expand All @@ -90,7 +90,7 @@ func (s *machineUpgraderSuite) TestToolsNotMachine(c *gc.C) {
}

func (s *machineUpgraderSuite) TestTools(c *gc.C) {
current := coretesting.CurrentVersion(c)
current := coretesting.CurrentVersion()
err := s.rawMachine.SetAgentVersion(current)
c.Assert(err, jc.ErrorIsNil)

Expand Down Expand Up @@ -132,7 +132,7 @@ func (s *machineUpgraderSuite) TestWatchAPIVersion(c *gc.C) {
}

func (s *machineUpgraderSuite) TestDesiredVersion(c *gc.C) {
current := coretesting.CurrentVersion(c)
current := coretesting.CurrentVersion()
err := s.rawMachine.SetAgentVersion(current)
c.Assert(err, jc.ErrorIsNil)

Expand Down
16 changes: 8 additions & 8 deletions apiserver/common/tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (s *getToolsSuite) TestTools(c *gc.C) {
},
}

current := coretesting.CurrentVersion(c)
current := coretesting.CurrentVersion()
configAttrs := map[string]interface{}{
"name": "some-name",
"type": "some-type",
Expand Down Expand Up @@ -162,7 +162,7 @@ func (s *setToolsSuite) TestSetTools(c *gc.C) {
ts := common.NewToolsSetter(s.entityFinder, getCanWrite)
c.Assert(ts, gc.NotNil)

current := coretesting.CurrentVersion(c)
current := coretesting.CurrentVersion()
args := params.EntitiesVersion{
AgentTools: []params.EntityVersion{{
Tag: "machine-0",
Expand Down Expand Up @@ -206,7 +206,7 @@ func (s *setToolsSuite) TestToolsSetError(c *gc.C) {
AgentTools: []params.EntityVersion{{
Tag: "machine-42",
Tools: &params.Version{
Version: coretesting.CurrentVersion(c),
Version: coretesting.CurrentVersion(),
},
}},
}
Expand Down Expand Up @@ -256,7 +256,7 @@ func (s *findToolsSuite) expectMatchingStorageTools(c *gc.C, storageMetadata []b
}

func (s *findToolsSuite) expectBootstrapEnvironConfig(c *gc.C) {
current := coretesting.CurrentVersion(c)
current := coretesting.CurrentVersion()
configAttrs := map[string]interface{}{
"name": "some-name",
"type": "some-type",
Expand Down Expand Up @@ -434,7 +434,7 @@ func (s *findToolsSuite) TestFindToolsExactNotInStorage(c *gc.C) {

func (s *findToolsSuite) testFindToolsExact(c *gc.C, inStorage bool, develVersion bool) {
var called bool
current := coretesting.CurrentVersion(c)
current := coretesting.CurrentVersion()
s.PatchValue(common.EnvtoolsFindTools, func(_ envtools.SimplestreamsFetcher, e environs.BootstrapEnviron, major, minor int, stream []string, filter coretools.Filter) (list coretools.List, err error) {
called = true
c.Assert(filter.Number, gc.Equals, jujuversion.Current)
Expand Down Expand Up @@ -506,7 +506,7 @@ func (s *getUrlSuite) TestToolsURLGetterNoAPIHostPorts(c *gc.C) {
s.apiHostPortsGetter.EXPECT().APIHostPortsForAgents().Return(nil, nil)

g := common.NewToolsURLGetter("my-uuid", s.apiHostPortsGetter)
_, err := g.ToolsURLs(coretesting.CurrentVersion(c))
_, err := g.ToolsURLs(coretesting.CurrentVersion())
c.Assert(err, gc.ErrorMatches, "no suitable API server address to pick from")
}

Expand All @@ -516,7 +516,7 @@ func (s *getUrlSuite) TestToolsURLGetterAPIHostPortsError(c *gc.C) {
s.apiHostPortsGetter.EXPECT().APIHostPortsForAgents().Return(nil, errors.New("oh noes"))

g := common.NewToolsURLGetter("my-uuid", s.apiHostPortsGetter)
_, err := g.ToolsURLs(coretesting.CurrentVersion(c))
_, err := g.ToolsURLs(coretesting.CurrentVersion())
c.Assert(err, gc.ErrorMatches, "oh noes")
}

Expand All @@ -528,7 +528,7 @@ func (s *getUrlSuite) TestToolsURLGetter(c *gc.C) {
}, nil)

g := common.NewToolsURLGetter("my-uuid", s.apiHostPortsGetter)
current := coretesting.CurrentVersion(c)
current := coretesting.CurrentVersion()
urls, err := g.ToolsURLs(current)
c.Assert(err, jc.ErrorIsNil)
c.Assert(urls, jc.DeepEquals, []string{
Expand Down
10 changes: 5 additions & 5 deletions apiserver/facades/agent/upgrader/unitupgrader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (s *unitUpgraderSuite) TestToolsForAgent(c *gc.C) {
// The machine must have its existing tools set before we query for the
// next tools. This is so that we can grab Arch and OSType without
// having to pass it in again
current := testing.CurrentVersion(c)
current := testing.CurrentVersion()
err := s.rawMachine.SetAgentVersion(current)
c.Assert(err, jc.ErrorIsNil)

Expand Down Expand Up @@ -220,7 +220,7 @@ func (s *unitUpgraderSuite) TestSetToolsRefusesWrongAgent(c *gc.C) {
AgentTools: []params.EntityVersion{{
Tag: s.rawUnit.Tag().String(),
Tools: &params.Version{
Version: testing.CurrentVersion(c),
Version: testing.CurrentVersion(),
},
}},
}
Expand All @@ -232,7 +232,7 @@ func (s *unitUpgraderSuite) TestSetToolsRefusesWrongAgent(c *gc.C) {
}

func (s *unitUpgraderSuite) TestSetTools(c *gc.C) {
cur := testing.CurrentVersion(c)
cur := testing.CurrentVersion()
_, err := s.rawUnit.AgentTools()
c.Assert(err, jc.Satisfies, errors.IsNotFound)
args := params.EntitiesVersion{
Expand Down Expand Up @@ -290,7 +290,7 @@ func (s *unitUpgraderSuite) TestDesiredVersionRefusesWrongAgent(c *gc.C) {
}

func (s *unitUpgraderSuite) TestDesiredVersionNoticesMixedAgents(c *gc.C) {
current := testing.CurrentVersion(c)
current := testing.CurrentVersion()
err := s.rawMachine.SetAgentVersion(current)
c.Assert(err, jc.ErrorIsNil)
args := params.Entities{Entities: []params.Entity{
Expand All @@ -311,7 +311,7 @@ func (s *unitUpgraderSuite) TestDesiredVersionNoticesMixedAgents(c *gc.C) {
}

func (s *unitUpgraderSuite) TestDesiredVersionForAgent(c *gc.C) {
current := testing.CurrentVersion(c)
current := testing.CurrentVersion()
err := s.rawMachine.SetAgentVersion(current)
c.Assert(err, jc.ErrorIsNil)
args := params.Entities{Entities: []params.Entity{{Tag: s.rawUnit.Tag().String()}}}
Expand Down
8 changes: 4 additions & 4 deletions apiserver/facades/agent/upgrader/upgrader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (s *upgraderSuite) TestToolsRefusesWrongAgent(c *gc.C) {
}

func (s *upgraderSuite) TestToolsForAgent(c *gc.C) {
current := coretesting.CurrentVersion(c)
current := coretesting.CurrentVersion()
agent := params.Entity{Tag: s.rawMachine.Tag().String()}

// The machine must have its existing tools set before we query for the
Expand Down Expand Up @@ -284,7 +284,7 @@ func (s *upgraderSuite) TestSetToolsRefusesWrongAgent(c *gc.C) {
AgentTools: []params.EntityVersion{{
Tag: s.rawMachine.Tag().String(),
Tools: &params.Version{
Version: coretesting.CurrentVersion(c),
Version: coretesting.CurrentVersion(),
},
}},
}
Expand All @@ -296,7 +296,7 @@ func (s *upgraderSuite) TestSetToolsRefusesWrongAgent(c *gc.C) {
}

func (s *upgraderSuite) TestSetTools(c *gc.C) {
current := coretesting.CurrentVersion(c)
current := coretesting.CurrentVersion()
_, err := s.rawMachine.AgentTools()
c.Assert(err, jc.Satisfies, errors.IsNotFound)
args := params.EntitiesVersion{
Expand Down Expand Up @@ -378,7 +378,7 @@ func (s *upgraderSuite) TestDesiredVersionForAgent(c *gc.C) {
func (s *upgraderSuite) bumpDesiredAgentVersion(c *gc.C) version.Number {
// In order to call SetModelAgentVersion we have to first SetTools on
// all the existing machines
current := coretesting.CurrentVersion(c)
current := coretesting.CurrentVersion()
err := s.apiMachine.SetAgentVersion(current)
c.Assert(err, jc.ErrorIsNil)
err = s.rawMachine.SetAgentVersion(current)
Expand Down
6 changes: 3 additions & 3 deletions apiserver/tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ func (s *toolsSuite) TestUploadConvertsSeries(c *gc.C) {

func (s *toolsSuite) TestDownloadModelUUIDPath(c *gc.C) {
tools := s.storeFakeTools(c, s.State, "abc", binarystorage.Metadata{
Version: testing.CurrentVersion(c).String(),
Version: testing.CurrentVersion().String(),
Size: 3,
SHA256: "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
})
Expand All @@ -447,7 +447,7 @@ func (s *toolsSuite) TestDownloadOtherModelUUIDPath(c *gc.C) {
defer newSt.Close()

tools := s.storeFakeTools(c, newSt, "abc", binarystorage.Metadata{
Version: testing.CurrentVersion(c).String(),
Version: testing.CurrentVersion().String(),
Size: 3,
SHA256: "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
})
Expand All @@ -456,7 +456,7 @@ func (s *toolsSuite) TestDownloadOtherModelUUIDPath(c *gc.C) {

func (s *toolsSuite) TestDownloadTopLevelPath(c *gc.C) {
tools := s.storeFakeTools(c, s.State, "abc", binarystorage.Metadata{
Version: testing.CurrentVersion(c).String(),
Version: testing.CurrentVersion().String(),
Size: 3,
SHA256: "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
})
Expand Down
7 changes: 5 additions & 2 deletions cmd/juju/application/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,11 @@ func (c *refreshCommand) Run(ctx *cmd.Context) error {
// Ensure that the switchURL (if provided) always contains a schema. If
// one is missing inject the default value we selected above.
if c.SwitchURL != "" {
if c.SwitchURL, err = charm.EnsureSchema(c.SwitchURL, defaultCharmSchema); err != nil {
return errors.Trace(err)
// Don't prepend `ch:` when referring to a local charm
if !refresher.IsLocalURL(c.SwitchURL) {
if c.SwitchURL, err = charm.EnsureSchema(c.SwitchURL, defaultCharmSchema); err != nil {
return errors.Trace(err)
}
}
}

Expand Down
29 changes: 29 additions & 0 deletions cmd/juju/application/refresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,35 @@ func (s *RefreshSuccessStateSuite) TestCharmPath(c *gc.C) {
s.assertLocalRevision(c, 42, myriakPath)
}

func (s *RefreshSuccessStateSuite) TestCharmPathNotFound(c *gc.C) {
myriakPath := filepath.Join(c.MkDir(), "riak")
_, err := os.Stat(myriakPath)
c.Assert(err, gc.ErrorMatches, ".*no such file or directory")
_, err = s.runRefresh(c, s.cmd, "riak", "--path", myriakPath)
c.Assert(err, gc.ErrorMatches, ".*file does not exist")
}

func (s *RefreshSuccessStateSuite) TestSwitchToLocal(c *gc.C) {
myriakPath := testcharms.RepoWithSeries("bionic").ClonedDirPath(c.MkDir(), "riak")

// Change the revision to 42 and upgrade to it with explicit revision.
err := ioutil.WriteFile(path.Join(myriakPath, "revision"), []byte("42"), 0644)
c.Assert(err, jc.ErrorIsNil)
_, err = s.runRefresh(c, s.cmd, "riak", "--switch", myriakPath)
c.Assert(err, jc.ErrorIsNil)
curl := s.assertUpgraded(c, s.riak, 42, false)
c.Assert(curl.String(), gc.Equals, "local:bionic/riak-42")
s.assertLocalRevision(c, 42, myriakPath)
}

func (s *RefreshSuccessStateSuite) TestSwitchToLocalNotFound(c *gc.C) {
myriakPath := filepath.Join(c.MkDir(), "riak")
_, err := os.Stat(myriakPath)
c.Assert(err, gc.ErrorMatches, ".*no such file or directory")
_, err = s.runRefresh(c, s.cmd, "riak", "--switch", myriakPath)
c.Assert(err, gc.ErrorMatches, ".*file does not exist")
}

func (s *RefreshSuccessStateSuite) TestCharmPathNoRevUpgrade(c *gc.C) {
// Revision 7 is running to start with.
myriakPath := testcharms.RepoWithSeries("bionic").ClonedDirPath(c.MkDir(), "riak")
Expand Down
13 changes: 13 additions & 0 deletions cmd/juju/application/refresher/refresher.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,24 @@ func (d *localCharmRefresher) Refresh() (*CharmID, error) {
return nil, errors.Trace(err)
}

if IsLocalURL(d.charmRef) {
// This was clearly meant to refer to a local charm, which we've not
// been able to find, so return the error
return nil, errors.Annotatef(err, "%q", d.charmRef)
}

// Not a valid local charm, in this case, we should move onto the next
// refresher.
return nil, ErrExhausted
}

// IsLocalURL checks if the provided URL refers to a local charm (i.e. it
// begins with one of `/` `./` `../` ).
func IsLocalURL(url string) bool {
return strings.HasPrefix(url, "/") || strings.HasPrefix(url, "./") ||
strings.HasPrefix(url, "../")
}

func (d *localCharmRefresher) String() string {
return fmt.Sprintf("attempting to refresh local charm %q", d.charmRef)
}
Expand Down
13 changes: 10 additions & 3 deletions cmd/juju/cloud/addcredential.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Providing the ` + "`-f <credentials.yaml>` " + `option switches to the
non-interactive mode. <credentials.yaml> must be a path to a correctly
formatted YAML-formatted file.

Sample yaml file shows four credentials being stored against three clouds:
Sample yaml file shows five credentials being stored against four clouds:

credentials:
aws:
Expand All @@ -54,12 +54,19 @@ Sample yaml file shows four credentials being stored against three clouds:
application-password: <password>
subscription-id: <uuid>
lxd:
<credential-name>:
<credential-a>:
auth-type: interactive
trust-password: <password>
<credential-name>:
<credential-b>:
auth-type: interactive
trust-password: <password>
google:
<credential-name>:
auth-type: oauth2
project-id: <project-id>
private-key: <private-key>
client-email: <email>
client-id: <client-id>

The <credential-name> parameter of each credential is arbitrary, but must
be unique within each <cloud-name>. This allows allow each cloud to store
Expand Down
Loading