Skip to content

Commit

Permalink
Environ fallout from updating agent binary simplestream release seman…
Browse files Browse the repository at this point in the history
…tics; upload, sync, bootstrap etc.
  • Loading branch information
wallyworld committed Mar 20, 2021
1 parent 60f5d76 commit e42561b
Show file tree
Hide file tree
Showing 19 changed files with 182 additions and 290 deletions.
9 changes: 5 additions & 4 deletions environs/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/juju/utils/v2"
"github.com/juju/utils/v2/arch"
"github.com/juju/utils/v2/ssh"
"github.com/juju/version"
"github.com/juju/version/v2"

"github.com/juju/juju/api"
"github.com/juju/juju/cloud"
Expand Down Expand Up @@ -509,7 +509,7 @@ func bootstrapIAAS(
// corrected series and arch - this ensures the build
// number is right if we found a valid official build.
version := builtTools.Version
version.Series = tool.Version.Series
version.Release = tool.Version.Release
version.Arch = tool.Version.Arch
// But if not an official build, use the forced version.
if !builtTools.Official {
Expand Down Expand Up @@ -571,12 +571,13 @@ func bootstrapIAAS(
return errors.Trace(err)
}

osType := coreseries.DefaultOSTypeNameFromSeries(result.Series)
matchingTools, err := bootstrapParams.AvailableTools.Match(coretools.Filter{
Arch: result.Arch,
Series: result.Series,
OSType: osType,
})
if err != nil {
return errors.Annotatef(err, "expected tools for %q", result.Series)
return errors.Annotatef(err, "expected tools for %q", osType)
}
selectedToolsList, err := getBootstrapToolsVersion(matchingTools)
if err != nil {
Expand Down
45 changes: 22 additions & 23 deletions environs/bootstrap/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/juju/os/v2/series"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils/v2/arch"
"github.com/juju/version"
"github.com/juju/version/v2"
gc "gopkg.in/check.v1"

"github.com/juju/juju/api"
Expand Down Expand Up @@ -243,7 +243,7 @@ func (s *bootstrapSuite) TestBootstrapSpecifiedBootstrapSeries(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
c.Check(env.bootstrapCount, gc.Equals, 1)
c.Check(env.args.BootstrapSeries, gc.Equals, "trusty")
c.Check(env.args.AvailableTools.AllSeries(), jc.SameContents, []string{"trusty"})
c.Check(env.args.AvailableTools.AllReleases(), jc.SameContents, []string{"ubuntu"})
}

func (s *bootstrapSuite) TestBootstrapFallbackBootstrapSeries(c *gc.C) {
Expand All @@ -264,7 +264,7 @@ func (s *bootstrapSuite) TestBootstrapFallbackBootstrapSeries(c *gc.C) {
})
c.Assert(err, jc.ErrorIsNil)
c.Check(env.bootstrapCount, gc.Equals, 1)
c.Check(env.args.AvailableTools.AllSeries(), jc.SameContents, []string{jujuversion.DefaultSupportedLTS()})
c.Check(env.args.AvailableTools.AllReleases(), jc.SameContents, []string{"ubuntu"})
}

func (s *bootstrapSuite) TestBootstrapForcedBootstrapSeries(c *gc.C) {
Expand All @@ -288,7 +288,7 @@ func (s *bootstrapSuite) TestBootstrapForcedBootstrapSeries(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
c.Check(env.bootstrapCount, gc.Equals, 1)
c.Check(env.args.BootstrapSeries, gc.Equals, "xenial")
c.Check(env.args.AvailableTools.AllSeries(), jc.SameContents, []string{"xenial"})
c.Check(env.args.AvailableTools.AllReleases(), jc.SameContents, []string{"ubuntu"})
}

func (s *bootstrapSuite) TestBootstrapWithInvalidBootstrapSeries(c *gc.C) {
Expand Down Expand Up @@ -626,7 +626,7 @@ func (s *bootstrapSuite) TestBootstrapLocalTools(c *gc.C) {

c.Check(env.bootstrapCount, gc.Equals, 1)
c.Check(env.args.BootstrapSeries, gc.Equals, "trusty")
c.Check(env.args.AvailableTools.AllSeries(), jc.SameContents, []string{"trusty"})
c.Check(env.args.AvailableTools.AllReleases(), jc.SameContents, []string{"ubuntu"})
}

func (s *bootstrapSuite) TestBootstrapLocalToolsMismatchingOS(c *gc.C) {
Expand Down Expand Up @@ -687,7 +687,7 @@ func (s *bootstrapSuite) TestBootstrapLocalToolsDifferentLinuxes(c *gc.C) {

c.Check(env.bootstrapCount, gc.Equals, 1)
c.Check(env.args.BootstrapSeries, gc.Equals, "trusty")
c.Check(env.args.AvailableTools.AllSeries(), jc.SameContents, []string{"trusty"})
c.Check(env.args.AvailableTools.AllReleases(), jc.SameContents, []string{"ubuntu"})
}

func (s *bootstrapSuite) TestBootstrapBuildAgent(c *gc.C) {
Expand Down Expand Up @@ -720,9 +720,9 @@ func (s *bootstrapSuite) TestBootstrapBuildAgent(c *gc.C) {
Official: true,
Version: version.Binary{
// If we found an official build we suppress the build number.
Number: localVer.ToPatch(),
Series: "quental",
Arch: "arm64",
Number: localVer.ToPatch(),
Release: "ubuntu",
Arch: "arm64",
},
}, nil
},
Expand All @@ -747,12 +747,12 @@ func (s *bootstrapSuite) assertBootstrapPackagedToolsAvailable(c *gc.C, clientAr
findToolsOk := false
s.PatchValue(bootstrap.FindTools, func(_ environs.BootstrapEnviron, _ int, _ int, _ []string, filter tools.Filter) (tools.List, error) {
c.Assert(filter.Arch, gc.Equals, toolsArch)
c.Assert(filter.Series, gc.Equals, "quantal")
c.Assert(filter.OSType, gc.Equals, "ubuntu")
findToolsOk = true
vers := version.Binary{
Number: jujuversion.Current,
Series: "quantal",
Arch: toolsArch,
Number: jujuversion.Current,
Release: "ubuntu",
Arch: toolsArch,
}
return tools.List{{
Version: vers,
Expand Down Expand Up @@ -841,11 +841,11 @@ func (s *bootstrapSuite) TestBootstrapNoToolsDevelopmentConfig(c *gc.C) {

func (s *bootstrapSuite) TestBootstrapToolsVersion(c *gc.C) {
availableVersions := []version.Binary{
version.MustParseBinary("1.18.0-trusty-arm64"),
version.MustParseBinary("1.18.1-trusty-arm64"),
version.MustParseBinary("1.18.1.1-trusty-arm64"),
version.MustParseBinary("1.18.1.2-trusty-arm64"),
version.MustParseBinary("1.18.1.3-trusty-arm64"),
version.MustParseBinary("1.18.0-ubuntu-arm64"),
version.MustParseBinary("1.18.1-ubuntu-arm64"),
version.MustParseBinary("1.18.1.1-ubuntu-arm64"),
version.MustParseBinary("1.18.1.2-ubuntu-arm64"),
version.MustParseBinary("1.18.1.3-ubuntu-arm64"),
}
availableTools := make(tools.List, len(availableVersions))
for i, v := range availableVersions {
Expand Down Expand Up @@ -1391,11 +1391,10 @@ func (s *bootstrapSuite) setupBootstrapSpecificVersion(c *gc.C, clientMajor, cli
})
defer envtools.UnregisterToolsDataSourceFunc("local storage")

supportedSeries := jujuversion.DefaultSupportedLTS()
toolsBinaries := []version.Binary{
version.MustParseBinary(fmt.Sprintf("10.11.12-%s-amd64", supportedSeries)),
version.MustParseBinary(fmt.Sprintf("10.11.13-%s-amd64", supportedSeries)),
version.MustParseBinary(fmt.Sprintf("10.11-beta1-%s-amd64", supportedSeries)),
version.MustParseBinary("10.11.12-ubuntu-amd64"),
version.MustParseBinary("10.11.13-ubuntu-amd64"),
version.MustParseBinary("10.11-beta1-ubuntu-amd64"),
}
stream := "released"
if toolsVersion != nil && toolsVersion.Tag != "" {
Expand Down Expand Up @@ -1572,7 +1571,7 @@ func (s *bootstrapSuite) TestTargetSeriesAndArchOverridePriority(c *gc.C) {
})

c.Assert(err, jc.ErrorIsNil)
c.Assert(env.bootstrapEnviron.instanceConfig.ToolsList().String(), gc.Matches, ".*-bionic-amd64", gc.Commentf("expected bootstrap constraints to supersede the values detected by the environment"))
c.Assert(env.bootstrapEnviron.instanceConfig.ToolsList().String(), gc.Matches, ".*-ubuntu-amd64", gc.Commentf("expected bootstrap constraints to supersede the values detected by the environment"))
}

type bootstrapEnviron struct {
Expand Down
26 changes: 15 additions & 11 deletions environs/bootstrap/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (

"github.com/juju/errors"
"github.com/juju/utils/v2/arch"
"github.com/juju/version"
"github.com/juju/version/v2"

"github.com/juju/juju/core/constraints"
jujuos "github.com/juju/juju/core/os"
"github.com/juju/juju/core/series"
coreos "github.com/juju/juju/core/os"
coreseries "github.com/juju/juju/core/series"
"github.com/juju/juju/environs"
envtools "github.com/juju/juju/environs/tools"
coretools "github.com/juju/juju/tools"
Expand Down Expand Up @@ -42,9 +42,9 @@ func validateUploadAllowed(env environs.ConfigGetter, toolsArch, toolsSeries *st
if toolsArch != nil && *toolsArch != hostArch {
return fmt.Errorf("cannot use agent built for %q using a machine running on %q", *toolsArch, hostArch)
}
hostOS := jujuos.HostOS()
hostOS := coreos.HostOS()
if toolsSeries != nil {
toolsSeriesOS, err := series.GetOSFromSeries(*toolsSeries)
toolsSeriesOS, err := coreseries.GetOSFromSeries(*toolsSeries)
if err != nil {
return errors.Trace(err)
}
Expand Down Expand Up @@ -93,21 +93,25 @@ func locallyBuildableTools(toolsSeries *string) (buildable coretools.List, _ ver
buildNumber := jujuversion.Current
// Increment the build number so we know it's a custom build.
buildNumber.Build++
workloadSeries, err := series.AllWorkloadSeries("", "")
workloadSeries, err := coreseries.AllWorkloadSeries("", "")
if err != nil {
return nil, version.Number{}, errors.Trace(err)
}
var osNames []string
for _, ser := range workloadSeries.SortedValues() {
if os, err := series.GetOSFromSeries(ser); err != nil || !os.EquivalentTo(jujuos.HostOS()) {
if os, err := coreseries.GetOSFromSeries(ser); err != nil || !os.EquivalentTo(coreos.HostOS()) {
continue
}
if toolsSeries != nil && ser != *toolsSeries {
continue
}
osNames = append(osNames, coreseries.DefaultOSTypeNameFromSeries(ser))
}
for _, osName := range osNames {
binary := version.Binary{
Number: buildNumber,
Series: ser,
Arch: localToolsArch(),
Number: buildNumber,
Release: osName,
Arch: localToolsArch(),
}
buildable = append(buildable, &coretools.Tools{Version: binary})
}
Expand All @@ -126,7 +130,7 @@ func findBootstrapTools(env environs.BootstrapEnviron, vers *version.Number, arc
filter.Arch = *arch
}
if series != nil {
filter.Series = *series
filter.OSType = coreseries.DefaultOSTypeNameFromSeries(*series)
}
if vers != nil {
filter.Number = *vers
Expand Down
26 changes: 10 additions & 16 deletions environs/bootstrap/tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
package bootstrap_test

import (
"time"

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

"github.com/juju/juju/core/os"
Expand Down Expand Up @@ -224,19 +222,15 @@ func (s *toolsSuite) TestFindAvailableToolsCompleteNoValidate(c *gc.C) {
s.PatchValue(&arch.HostArch, func() string { return arch.AMD64 })
s.PatchValue(&series.UbuntuDistroInfo, "/path/notexists")

workloadSeries, err := series.WorkloadSeries(time.Now(), "", "")
c.Assert(err, jc.ErrorIsNil)
var allTools tools.List
for _, series := range workloadSeries.Values() {
binary := version.Binary{
Number: jujuversion.Current,
Series: series,
Arch: arch.HostArch(),
}
allTools = append(allTools, &tools.Tools{
Version: binary,
URL: "http://testing.invalid/tools.tar.gz",
})
allTools := tools.List{
&tools.Tools{
Version: version.Binary{
Number: jujuversion.Current,
Release: "ubuntu",
Arch: arch.HostArch(),
},
URL: "http://testing.invalid/tools.tar.gz",
},
}

s.PatchValue(bootstrap.FindTools, func(_ environs.BootstrapEnviron, major, minor int, streams []string, f tools.Filter) (tools.List, error) {
Expand Down
2 changes: 1 addition & 1 deletion environs/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/juju/proxy"
"github.com/juju/schema"
"github.com/juju/utils/v2"
"github.com/juju/version"
"github.com/juju/version/v2"
"gopkg.in/juju/environschema.v1"
"gopkg.in/yaml.v2"

Expand Down
2 changes: 1 addition & 1 deletion environs/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/juju/schema"
jujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/version"
"github.com/juju/version/v2"
gc "gopkg.in/check.v1"
"gopkg.in/juju/environschema.v1"

Expand Down
2 changes: 1 addition & 1 deletion environs/gui/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strings"

"github.com/juju/errors"
"github.com/juju/version"
"github.com/juju/version/v2"
)

// DashboardArchiveVersion retrieves the Dashboard version
Expand Down
2 changes: 1 addition & 1 deletion environs/gui/simplestreams.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/juju/errors"
"github.com/juju/utils/v2"
"github.com/juju/version"
"github.com/juju/version/v2"

"github.com/juju/juju/environs/simplestreams"
"github.com/juju/juju/juju/keys"
Expand Down
2 changes: 1 addition & 1 deletion environs/gui/simplestreams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"

jc "github.com/juju/testing/checkers"
"github.com/juju/version"
"github.com/juju/version/v2"
gc "gopkg.in/check.v1"

"github.com/juju/juju/environs/gui"
Expand Down
2 changes: 1 addition & 1 deletion environs/imagedownloads/simplestreams.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ var validArches = map[string]bool{
arch.PPC64EL: true,
}

// Filter collects only matching products. Series and Arch are filtered by
// Filter collects only matching products. Release and Arch are filtered by
// imagemetadata.ImageConstraints. So this really only let's us filter on a
// file type.
func Filter(ftype string) simplestreams.AppendMatchingFunc {
Expand Down
2 changes: 1 addition & 1 deletion environs/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"io"

"github.com/juju/jsonschema"
"github.com/juju/version"
"github.com/juju/version/v2"
"gopkg.in/juju/environschema.v1"

"github.com/juju/juju/cloud"
Expand Down
Loading

0 comments on commit e42561b

Please sign in to comment.