Skip to content

Commit

Permalink
Merge branch '2.8' into merge-28-develop-5
Browse files Browse the repository at this point in the history
Conflicts:
	agent/agent.go
	agent/agentbootstrap/bootstrap_test.go
	agent/tools/symlinks_test.go
	api/certpool.go
	api/provisioner/provisioner_test.go
	api/upgrader/unitupgrader_test.go
	apiserver/facades/agent/upgrader/unitupgrader_test.go
	apiserver/facades/agent/upgrader/upgrader_test.go
	apiserver/tools_test.go
	caas/kubernetes/provider/init.go
	caas/kubernetes/provider/k8s.go
	cmd/juju/commands/main.go
	cmd/juju/commands/main_test.go
	cmd/juju/commands/synctools_test.go
	cmd/juju/commands/upgradecontroller_test.go
	cmd/juju/commands/version_test.go
	cmd/jujud/agent/agenttest/agent.go
	cmd/jujud/agent/bootstrap_test.go
	cmd/jujud/agent/machine.go
	cmd/jujud/agent/machine_test.go
	cmd/jujud/agent/unit_test.go
	cmd/jujud/agent/util_test.go
	cmd/jujud/run/run.go
	cmd/jujud/util/util.go
	container/kvm/sync.go
	core/paths/paths.go
	environs/testing/tools.go
	environs/tools/build_test.go
	environs/tools/testing/testing.go
	featuretests/introspection_test.go
	featuretests/tools_test.go
	featuretests/upgrade_test.go
	go.mod
	go.sum
	juju/testing/conn.go
	provider/ec2/live_test.go
	provider/ec2/local_test.go
	provider/lxd/upgrades.go
	provider/maas/maas_test.go
	provider/maas/util.go
	service/discovery_test.go
	testing/base.go
	testing/factory/factory.go
	version/version_test.go
	worker/caasoperator/caasoperator_test.go
	worker/deployer/simple_test.go
	worker/proxyupdater/proxyupdater_test.go
	worker/upgrader/upgrader.go
	worker/upgradesteps/worker_test.go
	wrench/wrench.go
  • Loading branch information
benhoyt committed Nov 22, 2020
2 parents a149df8 + eb7556a commit 9de1ccf
Show file tree
Hide file tree
Showing 114 changed files with 760 additions and 1,053 deletions.
11 changes: 5 additions & 6 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/names/v4"
"github.com/juju/os/v2/series"
"github.com/juju/utils/v2"
"github.com/juju/utils/v2/shell"
"github.com/juju/version"
Expand All @@ -43,11 +42,11 @@ const (

// These are base values used for the corresponding defaults.
var (
logDir = paths.MustSucceed(paths.LogDir(series.MustHostSeries()))
dataDir = paths.MustSucceed(paths.DataDir(series.MustHostSeries()))
transientDataDir = paths.MustSucceed(paths.TransientDataDir(series.MustHostSeries()))
confDir = paths.MustSucceed(paths.ConfDir(series.MustHostSeries()))
metricsSpoolDir = paths.MustSucceed(paths.MetricsSpoolDir(series.MustHostSeries()))
logDir = paths.LogDir(paths.CurrentOS())
dataDir = paths.DataDir(paths.CurrentOS())
transientDataDir = paths.TransientDataDir(paths.CurrentOS())
confDir = paths.ConfDir(paths.CurrentOS())
metricsSpoolDir = paths.MetricsSpoolDir(paths.CurrentOS())
)

// Agent exposes the agent's configuration to other components. This
Expand Down
3 changes: 1 addition & 2 deletions agent/agentbootstrap/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"path/filepath"

"github.com/juju/names/v4"
"github.com/juju/os/v2/series"
gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils/v2"
Expand Down Expand Up @@ -292,7 +291,7 @@ LXC_BRIDGE="ignored"`[1:])
c.Assert(err, jc.ErrorIsNil)
c.Assert(m.Id(), gc.Equals, "0")
c.Assert(m.Jobs(), gc.DeepEquals, []state.MachineJob{state.JobManageModel})
c.Assert(m.Series(), gc.Equals, series.MustHostSeries())
c.Assert(m.Series(), gc.Equals, testing.HostSeries(c))
c.Assert(m.CheckProvisioned(agent.BootstrapNonce), jc.IsTrue)
c.Assert(m.Addresses(), jc.DeepEquals, filteredAddrs)
gotBootstrapConstraints, err := m.Constraints()
Expand Down
11 changes: 2 additions & 9 deletions agent/tools/symlinks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ import (
"path/filepath"
"time"

"github.com/juju/os/v2/series"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils/v2"
"github.com/juju/utils/v2/arch"
"github.com/juju/utils/v2/symlink"
"github.com/juju/version"
gc "gopkg.in/check.v1"

"github.com/juju/juju/agent/tools"
"github.com/juju/juju/juju/names"
jujuversion "github.com/juju/juju/version"
"github.com/juju/juju/testing"
)

type SymlinksSuite struct {
Expand All @@ -30,11 +27,7 @@ var _ = gc.Suite(&SymlinksSuite{})

func (s *SymlinksSuite) SetUpTest(c *gc.C) {
s.dataDir = c.MkDir()
s.toolsDir = tools.SharedToolsDir(s.dataDir, version.Binary{
Number: jujuversion.Current,
Arch: arch.HostArch(),
Series: series.MustHostSeries(),
})
s.toolsDir = tools.SharedToolsDir(s.dataDir, testing.CurrentVersion(c))
err := os.MkdirAll(s.toolsDir, 0755)
c.Assert(err, jc.ErrorIsNil)
c.Logf("created %s", s.toolsDir)
Expand Down
3 changes: 1 addition & 2 deletions api/certpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import (
"path/filepath"

"github.com/juju/errors"
"github.com/juju/os/v2/series"
"github.com/juju/utils/v2/cert"

"github.com/juju/juju/core/paths"
)

var certDir = filepath.FromSlash(paths.MustSucceed(paths.CertDir(series.MustHostSeries())))
var certDir = filepath.FromSlash(paths.CertDir(paths.CurrentOS()))

// CreateCertPool creates a new x509.CertPool and adds in the caCert passed
// in. All certs from the cert directory (/etc/juju/cert.d on ubuntu) are
Expand Down
12 changes: 3 additions & 9 deletions api/provisioner/provisioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import (
"github.com/golang/mock/gomock"
"github.com/juju/errors"
"github.com/juju/names/v4"
"github.com/juju/os/v2/series"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils/v2"
"github.com/juju/utils/v2/arch"
"github.com/juju/version"
gc "gopkg.in/check.v1"

"github.com/juju/juju/api"
Expand Down Expand Up @@ -774,11 +772,7 @@ func (s *provisionerSuite) TestFindToolsLogicError(c *gc.C) {
}

func (s *provisionerSuite) testFindTools(c *gc.C, matchArch bool, apiError, logicError error) {
current := version.Binary{
Number: jujuversion.Current,
Arch: arch.HostArch(),
Series: series.MustHostSeries(),
}
current := coretesting.CurrentVersion(c)
var toolsList = coretools.List{&coretools.Tools{Version: current}}
var called bool
var a string
Expand All @@ -793,7 +787,7 @@ func (s *provisionerSuite) testFindTools(c *gc.C, matchArch bool, apiError, logi
c.Assert(request, gc.Equals, "FindTools")
expected := params.FindToolsParams{
Number: jujuversion.Current,
Series: series.MustHostSeries(),
Series: current.Series,
Arch: a,
MinorVersion: -1,
MajorVersion: -1,
Expand All @@ -806,7 +800,7 @@ func (s *provisionerSuite) testFindTools(c *gc.C, matchArch bool, apiError, logi
}
return apiError
})
apiList, err := s.provisioner.FindTools(jujuversion.Current, series.MustHostSeries(), a)
apiList, err := s.provisioner.FindTools(jujuversion.Current, current.Series, a)
c.Assert(called, jc.IsTrue)
if apiError != nil {
c.Assert(err, gc.Equals, apiError)
Expand Down
17 changes: 6 additions & 11 deletions api/upgrader/unitupgrader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ package upgrader_test

import (
"github.com/juju/errors"
"github.com/juju/os/v2/series"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils/v2"
"github.com/juju/utils/v2/arch"
"github.com/juju/version"
gc "gopkg.in/check.v1"

Expand All @@ -18,8 +16,8 @@ import (
"github.com/juju/juju/core/watcher/watchertest"
jujutesting "github.com/juju/juju/juju/testing"
"github.com/juju/juju/state"
"github.com/juju/juju/testing"
"github.com/juju/juju/tools"
jujuversion "github.com/juju/juju/version"
)

type unitUpgraderSuite struct {
Expand All @@ -37,12 +35,6 @@ type unitUpgraderSuite struct {

var _ = gc.Suite(&unitUpgraderSuite{})

var current = version.Binary{
Number: jujuversion.Current,
Arch: arch.HostArch(),
Series: series.MustHostSeries(),
}

func (s *unitUpgraderSuite) SetUpTest(c *gc.C) {
s.JujuConnSuite.SetUpTest(c)

Expand Down Expand Up @@ -73,18 +65,19 @@ func (s *unitUpgraderSuite) addMachineApplicationCharmAndUnit(c *gc.C, appName s
}

func (s *unitUpgraderSuite) TestSetVersionWrongUnit(c *gc.C) {
err := s.st.SetVersion("unit-wordpress-42", current)
err := s.st.SetVersion("unit-wordpress-42", testing.CurrentVersion(c))
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", current)
err := s.st.SetVersion("foo-42", testing.CurrentVersion(c))
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)
agentTools, err := s.rawUnit.AgentTools()
c.Assert(err, jc.Satisfies, errors.IsNotFound)
c.Assert(agentTools, gc.IsNil)
Expand All @@ -111,6 +104,7 @@ func (s *unitUpgraderSuite) TestToolsNotUnit(c *gc.C) {
}

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

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

func (s *machineUpgraderSuite) TestSetVersionWrongMachine(c *gc.C) {
err := s.st.SetVersion("machine-42", current)
err := s.st.SetVersion("machine-42", coretesting.CurrentVersion(c))
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", current)
err := s.st.SetVersion("foo-42", coretesting.CurrentVersion(c))
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)
agentTools, err := s.rawMachine.AgentTools()
c.Assert(err, jc.Satisfies, errors.IsNotFound)
c.Assert(agentTools, gc.IsNil)
Expand All @@ -90,6 +91,7 @@ func (s *machineUpgraderSuite) TestToolsNotMachine(c *gc.C) {
}

func (s *machineUpgraderSuite) TestTools(c *gc.C) {
current := coretesting.CurrentVersion(c)
curTools := &tools.Tools{Version: current, URL: ""}
curTools.Version.Minor++
s.rawMachine.SetAgentVersion(current)
Expand Down Expand Up @@ -133,6 +135,7 @@ func (s *machineUpgraderSuite) TestWatchAPIVersion(c *gc.C) {
}

func (s *machineUpgraderSuite) TestDesiredVersion(c *gc.C) {
current := coretesting.CurrentVersion(c)
curTools := &tools.Tools{Version: current, URL: ""}
curTools.Version.Minor++
s.rawMachine.SetAgentVersion(current)
Expand Down
6 changes: 2 additions & 4 deletions apiserver/common/firewall/egressaddresswatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/juju/worker/v2"
"github.com/juju/worker/v2/catacomb"

corenetwork "github.com/juju/juju/core/network"
"github.com/juju/juju/core/watcher"
"github.com/juju/juju/network"
)
Expand Down Expand Up @@ -142,10 +143,7 @@ func (w *EgressAddressWatcher) loop() error {
}
changed = false
if !setEquals(addresses, lastAddresses) {
addressesCIDR, err = network.FormatAsCIDR(addresses.Values())
if err != nil {
return errors.Trace(err)
}
addressesCIDR = corenetwork.SubnetsForAddresses(addresses.Values())
ready = ready || sentInitial
}
}
Expand Down
23 changes: 11 additions & 12 deletions apiserver/common/tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/juju/juju/state"
"github.com/juju/juju/state/binarystorage"
"github.com/juju/juju/state/stateenvirons"
coretesting "github.com/juju/juju/testing"
coretools "github.com/juju/juju/tools"
jujuversion "github.com/juju/juju/version"
)
Expand All @@ -34,12 +35,6 @@ type toolsSuite struct {

var _ = gc.Suite(&toolsSuite{})

var current = version.Binary{
Number: jujuversion.Current,
Arch: arch.HostArch(),
Series: series.MustHostSeries(),
}

func (s *toolsSuite) SetUpTest(c *gc.C) {
s.JujuConnSuite.SetUpTest(c)
var err error
Expand All @@ -63,6 +58,7 @@ func (s *toolsSuite) TestTools(c *gc.C) {
)
c.Assert(tg, gc.NotNil)

current := coretesting.CurrentVersion(c)
err := s.machine0.SetAgentVersion(current)
c.Assert(err, jc.ErrorIsNil)

Expand Down Expand Up @@ -113,6 +109,7 @@ func (s *toolsSuite) TestSetTools(c *gc.C) {
ts := common.NewToolsSetter(s.State, getCanWrite)
c.Assert(ts, gc.NotNil)

current := coretesting.CurrentVersion(c)
err := s.machine0.SetAgentVersion(current)
c.Assert(err, jc.ErrorIsNil)

Expand Down Expand Up @@ -154,7 +151,7 @@ func (s *toolsSuite) TestToolsSetError(c *gc.C) {
AgentTools: []params.EntityVersion{{
Tag: "machine-42",
Tools: &params.Version{
Version: current,
Version: coretesting.CurrentVersion(c),
},
}},
}
Expand Down Expand Up @@ -250,7 +247,7 @@ func (s *toolsSuite) TestFindToolsExactInStorage(c *gc.C) {
}

s.PatchValue(&arch.HostArch, func() string { return arch.AMD64 })
s.PatchValue(&series.MustHostSeries, func() string { return "trusty" })
s.PatchValue(&series.HostSeries, func() (string, error) { return "trusty", nil })
s.PatchValue(&jujuversion.Current, version.MustParseBinary("1.22-beta1-trusty-amd64").Number)
s.testFindToolsExact(c, mockToolsStorage, true, true)
s.PatchValue(&jujuversion.Current, version.MustParseBinary("1.22.0-trusty-amd64").Number)
Expand All @@ -267,10 +264,11 @@ func (s *toolsSuite) TestFindToolsExactNotInStorage(c *gc.C) {

func (s *toolsSuite) testFindToolsExact(c *gc.C, t common.ToolsStorageGetter, inStorage bool, develVersion bool) {
var called bool
current := coretesting.CurrentVersion(c)
s.PatchValue(common.EnvtoolsFindTools, func(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)
c.Assert(filter.Series, gc.Equals, series.MustHostSeries())
c.Assert(filter.Series, gc.Equals, current.Series)
c.Assert(filter.Arch, gc.Equals, arch.HostArch())
if develVersion {
c.Assert(stream, gc.DeepEquals, []string{"devel", "proposed", "released"})
Expand All @@ -287,7 +285,7 @@ func (s *toolsSuite) testFindToolsExact(c *gc.C, t common.ToolsStorageGetter, in
Number: jujuversion.Current,
MajorVersion: -1,
MinorVersion: -1,
Series: series.MustHostSeries(),
Series: current.Series,
Arch: arch.HostArch(),
})
c.Assert(err, jc.ErrorIsNil)
Expand Down Expand Up @@ -326,13 +324,13 @@ func (s *toolsSuite) TestFindToolsToolsStorageError(c *gc.C) {

func (s *toolsSuite) TestToolsURLGetterNoAPIHostPorts(c *gc.C) {
g := common.NewToolsURLGetter("my-uuid", mockAPIHostPortsGetter{})
_, err := g.ToolsURLs(current)
_, err := g.ToolsURLs(coretesting.CurrentVersion(c))
c.Assert(err, gc.ErrorMatches, "no suitable API server address to pick from")
}

func (s *toolsSuite) TestToolsURLGetterAPIHostPortsError(c *gc.C) {
g := common.NewToolsURLGetter("my-uuid", mockAPIHostPortsGetter{err: errors.New("oh noes")})
_, err := g.ToolsURLs(current)
_, err := g.ToolsURLs(coretesting.CurrentVersion(c))
c.Assert(err, gc.ErrorMatches, "oh noes")
}

Expand All @@ -342,6 +340,7 @@ func (s *toolsSuite) TestToolsURLGetter(c *gc.C) {
network.NewSpaceHostPorts(1234, "0.1.2.3"),
},
})
current := coretesting.CurrentVersion(c)
urls, err := g.ToolsURLs(current)
c.Assert(err, jc.ErrorIsNil)
c.Check(urls, jc.DeepEquals, []string{
Expand Down
4 changes: 2 additions & 2 deletions apiserver/facades/agent/caasapplication/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ func (f *Facade) UnitIntroduction(args params.CAASUnitIntroductionArgs) (params.

caCert, _ := controllerConfig.CACert()
version, _ := f.model.AgentVersion()
dataDir, _ := paths.DataDir("kubernetes")
logDir, _ := paths.LogDir("kubernetes")
dataDir := paths.DataDir(paths.OSUnixLike)
logDir := paths.LogDir(paths.OSUnixLike)

conf, err := agent.NewAgentConfig(
agent.AgentConfigParams{
Expand Down
Loading

0 comments on commit 9de1ccf

Please sign in to comment.