Skip to content

Commit

Permalink
Fallout from updating agent binary metadata to use os type instead of…
Browse files Browse the repository at this point in the history
… series.
  • Loading branch information
wallyworld committed Mar 20, 2021
1 parent e42561b commit b7002c6
Show file tree
Hide file tree
Showing 381 changed files with 1,186 additions and 1,178 deletions.
2 changes: 0 additions & 2 deletions acceptancetests/assess_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,12 @@ def setup_agent_metadata(
stream,
version_parts.version,
version_parts.arch,
client.env.get_option('default-series'),
agent_details)
# Trusty needed for wikimedia charm.
stream_server.add_product(
stream,
version_parts.version,
version_parts.arch,
'trusty',
agent_details)


Expand Down
23 changes: 8 additions & 15 deletions acceptancetests/jujupy/stream_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,19 @@ def __init__(self, working_dir):

os.makedirs(self._agent_path)

def add_product(self, content_id, version, arch, series, agent_tgz_path):
def add_product(self, content_id, version, arch, agent_tgz_path):
"""Add a new product to generate stream data for.
:param content_id: String ID (e.g.'proposed', 'release')
:param version: Juju version string for product (i.e. '2.3.3')
:param arch: Architecture string of this product (e.g. 's390x','amd64')
:param series: Series string that appears in item_name
(e.g. 'bionic', 'xenial', 'centos')
:param agent_tgz_path: String full path to agent tarball file to use.
This file is copied into the JujuStreamData working dir to be served
up at a later date.
"""
shutil.copy(agent_tgz_path, self._agent_path)
product_dict = _generate_product_json(
content_id, version, arch, series, agent_tgz_path)
content_id, version, arch, agent_tgz_path)
self.products.append(product_dict)

def generate_stream_data(self):
Expand Down Expand Up @@ -108,20 +106,18 @@ def __init__(self, base_dir, stream_data_type=_JujuStreamData):
self.base_dir = base_dir
self.stream_data = stream_data_type(base_dir)

def add_product(self, content_id, version, arch, series, agent_tgz_path):
def add_product(self, content_id, version, arch, agent_tgz_path):
"""Add a new product to generate stream data for.
:param content_id: String ID (e.g.'proposed', 'released')
:param version: Juju version string for product (i.e. '2.3.3')
:param arch: Architecture string of this product (e.g. 's390x','amd64')
:param series: Series string that appears in item_name
(e.g. 'bionic', 'xenial', 'centos')
:param agent_tgz_path: String full path to agent tarball file to use.
This file is copied into the JujuStreamData working dir to be served
up at a later date.
"""
self.stream_data.add_product(
content_id, version, arch, series, agent_tgz_path)
content_id, version, arch, agent_tgz_path)
# Re-generate when adding a product allows updating the server while
# running.
# Can be noisey in the logs, if a lot of products need to be added can
Expand Down Expand Up @@ -224,25 +220,22 @@ def _series_lookup(series):

def _generate_product_json(content_id, version, arch, series, agent_tgz_path):
"""Return dict containing product metadata from provided args."""
series_name, series_code = _get_series_details(series)
tgz_name = os.path.basename(agent_tgz_path)
file_details = _get_tgz_file_details(agent_tgz_path)
item_name = '{version}-{series}-{arch}'.format(
item_name = '{version}-ubuntu-{arch}'.format(
version=version,
series='{}:{}'.format(series_name, series_code),
arch=arch)
return dict(
arch=arch,
content_id='com.ubuntu.juju:{}:tools'.format(content_id),
content_id='com.ubuntu.juju:{}:agents'.format(content_id),
format='products:1.0',
ftype='tar.gz',
item_name=item_name,
md5=file_details['md5'],
path=os.path.join('agent', tgz_name),
product_name='com.ubuntu.juju:{series_code}:{arch}'.format(
series_code=series_code,
product_name='com.ubuntu.juju:ubuntu:{arch}'.format(
arch=arch),
release=series_name,
release='ubuntu',
sha256=file_details['sha256'],
size=file_details['size'],
version=version,
Expand Down
2 changes: 1 addition & 1 deletion agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/juju/names/v4"
"github.com/juju/utils/v2"
"github.com/juju/utils/v2/shell"
"github.com/juju/version"
"github.com/juju/version/v2"

"github.com/juju/juju/api"
"github.com/juju/juju/controller"
Expand Down
2 changes: 1 addition & 1 deletion agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

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

"github.com/juju/juju/agent"
Expand Down
2 changes: 1 addition & 1 deletion agent/format-2.0.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/juju/errors"
"github.com/juju/names/v4"
"github.com/juju/version"
"github.com/juju/version/v2"
goyaml "gopkg.in/yaml.v2"

"github.com/juju/juju/controller"
Expand Down
2 changes: 1 addition & 1 deletion agent/format-2.0_whitebox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

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

"github.com/juju/juju/core/model"
Expand Down
2 changes: 1 addition & 1 deletion agent/tools/diskmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package tools
import (
"io"

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

"github.com/juju/juju/tools"
)
Expand Down
14 changes: 7 additions & 7 deletions agent/tools/diskmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"path/filepath"

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

agenttools "github.com/juju/juju/agent/tools"
Expand Down Expand Up @@ -48,14 +48,14 @@ func (s *DiskManagerSuite) TestUnpackToolsContents(c *gc.C) {
gzfile, checksum := coretesting.TarGz(files...)
t1 := &coretools.Tools{
URL: "http://foo/bar",
Version: version.MustParseBinary("1.2.3-quantal-amd64"),
Version: version.MustParseBinary("1.2.3-ubuntu-amd64"),
Size: int64(len(gzfile)),
SHA256: checksum,
}

err := s.manager.UnpackTools(t1, bytes.NewReader(gzfile))
c.Assert(err, jc.ErrorIsNil)
assertDirNames(c, s.toolsDir(), []string{"1.2.3-quantal-amd64"})
assertDirNames(c, s.toolsDir(), []string{"1.2.3-ubuntu-amd64"})
s.assertToolsContents(c, t1, files)

// Try to unpack the same version of tools again - it should succeed,
Expand All @@ -67,20 +67,20 @@ func (s *DiskManagerSuite) TestUnpackToolsContents(c *gc.C) {
gzfile2, checksum2 := coretesting.TarGz(files2...)
t2 := &coretools.Tools{
URL: "http://arble",
Version: version.MustParseBinary("1.2.3-quantal-amd64"),
Version: version.MustParseBinary("1.2.3-ubuntu-amd64"),
Size: int64(len(gzfile2)),
SHA256: checksum2,
}
err = s.manager.UnpackTools(t2, bytes.NewReader(gzfile2))
c.Assert(err, jc.ErrorIsNil)
assertDirNames(c, s.toolsDir(), []string{"1.2.3-quantal-amd64"})
assertDirNames(c, s.toolsDir(), []string{"1.2.3-ubuntu-amd64"})
s.assertToolsContents(c, t1, files)
}

func (t *DiskManagerSuite) TestSharedToolsDir(c *gc.C) {
manager := agenttools.NewDiskManager("/var/lib/juju")
dir := manager.SharedToolsDir(version.MustParseBinary("1.2.3-precise-amd64"))
c.Assert(dir, gc.Equals, "/var/lib/juju/tools/1.2.3-precise-amd64")
dir := manager.SharedToolsDir(version.MustParseBinary("1.2.3-ubuntu-amd64"))
c.Assert(dir, gc.Equals, "/var/lib/juju/tools/1.2.3-ubuntu-amd64")
}

// assertToolsContents asserts that the directory for the tools
Expand Down
2 changes: 1 addition & 1 deletion agent/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"io"

"github.com/juju/loggo"
"github.com/juju/version"
"github.com/juju/version/v2"

"github.com/juju/juju/tools"
)
Expand Down
32 changes: 16 additions & 16 deletions agent/tools/tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

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

agenttools "github.com/juju/juju/agent/tools"
Expand Down Expand Up @@ -88,7 +88,7 @@ func (t *ToolsSuite) TestUnpackToolsBadData(c *gc.C) {
c.Logf("test %d", i)
testTools := &coretest.Tools{
URL: "http://foo/bar",
Version: version.MustParseBinary("1.2.3-quantal-amd64"),
Version: version.MustParseBinary("1.2.3-ubuntu-amd64"),
Size: int64(len(test.data)),
SHA256: test.checksum,
}
Expand All @@ -102,7 +102,7 @@ func (t *ToolsSuite) TestUnpackToolsBadChecksum(c *gc.C) {
data, _ := testing.TarGz(testing.NewTarFile("tools", agenttools.DirPerm, "some data"))
testTools := &coretest.Tools{
URL: "http://foo/bar",
Version: version.MustParseBinary("1.2.3-quantal-amd64"),
Version: version.MustParseBinary("1.2.3-ubuntu-amd64"),
Size: int64(len(data)),
SHA256: "1234",
}
Expand All @@ -124,14 +124,14 @@ func (t *ToolsSuite) TestUnpackToolsContents(c *gc.C) {
data, checksum := testing.TarGz(files...)
testTools := &coretest.Tools{
URL: "http://foo/bar",
Version: version.MustParseBinary("1.2.3-quantal-amd64"),
Version: version.MustParseBinary("1.2.3-ubuntu-amd64"),
Size: int64(len(data)),
SHA256: checksum,
}

err := agenttools.UnpackTools(t.dataDir, testTools, bytes.NewReader(data))
c.Assert(err, jc.ErrorIsNil)
assertDirNames(c, t.toolsDir(), []string{"1.2.3-quantal-amd64"})
assertDirNames(c, t.toolsDir(), []string{"1.2.3-ubuntu-amd64"})
t.assertToolsContents(c, testTools, files)

// Try to unpack the same version of tools again - it should succeed,
Expand All @@ -143,18 +143,18 @@ func (t *ToolsSuite) TestUnpackToolsContents(c *gc.C) {
data2, checksum2 := testing.TarGz(files2...)
tools2 := &coretest.Tools{
URL: "http://arble",
Version: version.MustParseBinary("1.2.3-quantal-amd64"),
Version: version.MustParseBinary("1.2.3-ubuntu-amd64"),
Size: int64(len(data2)),
SHA256: checksum2,
}
err = agenttools.UnpackTools(t.dataDir, tools2, bytes.NewReader(data2))
c.Assert(err, jc.ErrorIsNil)
assertDirNames(c, t.toolsDir(), []string{"1.2.3-quantal-amd64"})
assertDirNames(c, t.toolsDir(), []string{"1.2.3-ubuntu-amd64"})
t.assertToolsContents(c, testTools, files)
}

func (t *ToolsSuite) TestReadToolsErrors(c *gc.C) {
vers := version.MustParseBinary("1.2.3-precise-amd64")
vers := version.MustParseBinary("1.2.3-ubuntu-amd64")
testTools, err := agenttools.ReadTools(t.dataDir, vers)
c.Assert(testTools, gc.IsNil)
c.Assert(err, gc.ErrorMatches, "cannot read agent metadata in directory .*")
Expand Down Expand Up @@ -220,7 +220,7 @@ func (t *ToolsSuite) TestChangeAgentTools(c *gc.C) {
data, checksum := testing.TarGz(files...)
testTools := &coretest.Tools{
URL: "http://foo/bar1",
Version: version.MustParseBinary("1.2.3-quantal-amd64"),
Version: version.MustParseBinary("1.2.3-ubuntu-amd64"),
Size: int64(len(data)),
SHA256: checksum,
}
Expand All @@ -231,18 +231,18 @@ func (t *ToolsSuite) TestChangeAgentTools(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
c.Assert(*gotTools, gc.Equals, *testTools)

assertDirNames(c, t.toolsDir(), []string{"1.2.3-quantal-amd64", "testagent"})
assertDirNames(c, t.toolsDir(), []string{"1.2.3-ubuntu-amd64", "testagent"})
assertDirNames(c, agenttools.ToolsDir(t.dataDir, "testagent"), []string{"jujuc", "jujud", agenttools.ToolsFile})

// Upgrade again to check that the link replacement logic works ok.
files2 := []*testing.TarFile{
testing.NewTarFile("quantal", agenttools.DirPerm, "foo content"),
testing.NewTarFile("ubuntu", agenttools.DirPerm, "foo content"),
testing.NewTarFile("amd64", agenttools.DirPerm, "bar content"),
}
data2, checksum2 := testing.TarGz(files2...)
tools2 := &coretest.Tools{
URL: "http://foo/bar2",
Version: version.MustParseBinary("1.2.4-quantal-amd64"),
Version: version.MustParseBinary("1.2.4-ubuntu-amd64"),
Size: int64(len(data2)),
SHA256: checksum2,
}
Expand All @@ -253,13 +253,13 @@ func (t *ToolsSuite) TestChangeAgentTools(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
c.Assert(*gotTools, gc.Equals, *tools2)

assertDirNames(c, t.toolsDir(), []string{"1.2.3-quantal-amd64", "1.2.4-quantal-amd64", "testagent"})
assertDirNames(c, agenttools.ToolsDir(t.dataDir, "testagent"), []string{"quantal", "amd64", agenttools.ToolsFile})
assertDirNames(c, t.toolsDir(), []string{"1.2.3-ubuntu-amd64", "1.2.4-ubuntu-amd64", "testagent"})
assertDirNames(c, agenttools.ToolsDir(t.dataDir, "testagent"), []string{"ubuntu", "amd64", agenttools.ToolsFile})
}

func (t *ToolsSuite) TestSharedToolsDir(c *gc.C) {
dir := agenttools.SharedToolsDir("/var/lib/juju", version.MustParseBinary("1.2.3-precise-amd64"))
c.Assert(dir, gc.Equals, "/var/lib/juju/tools/1.2.3-precise-amd64")
dir := agenttools.SharedToolsDir("/var/lib/juju", version.MustParseBinary("1.2.3-ubuntu-amd64"))
c.Assert(dir, gc.Equals, "/var/lib/juju/tools/1.2.3-ubuntu-amd64")
}

func (t *ToolsSuite) TestSharedGUIDir(c *gc.C) {
Expand Down
2 changes: 1 addition & 1 deletion agent/tools/toolsdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

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

coretools "github.com/juju/juju/tools"
)
Expand Down
2 changes: 1 addition & 1 deletion api/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/juju/names/v4"
"github.com/juju/utils/v2"
"github.com/juju/utils/v2/parallel"
"github.com/juju/version"
"github.com/juju/version/v2"
"gopkg.in/macaroon.v2"
"gopkg.in/retry.v1"

Expand Down
2 changes: 1 addition & 1 deletion api/base/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package base
import (
"time"

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

"github.com/juju/juju/core/instance"
"github.com/juju/juju/core/life"
Expand Down
2 changes: 1 addition & 1 deletion api/caasapplicationprovisioner/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/juju/charm/v8"
"github.com/juju/errors"
"github.com/juju/names/v4"
"github.com/juju/version"
"github.com/juju/version/v2"

"github.com/juju/juju/api/base"
"github.com/juju/juju/api/common"
Expand Down
2 changes: 1 addition & 1 deletion api/caasapplicationprovisioner/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/juju/names/v4"
"github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/version"
"github.com/juju/version/v2"
gc "gopkg.in/check.v1"

basetesting "github.com/juju/juju/api/base/testing"
Expand Down
2 changes: 1 addition & 1 deletion api/caasmodeloperator/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package caasmodeloperator

import (
"github.com/juju/errors"
"github.com/juju/version"
"github.com/juju/version/v2"

"github.com/juju/juju/api/base"
"github.com/juju/juju/apiserver/params"
Expand Down
2 changes: 1 addition & 1 deletion api/caasmodeloperator/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package caasmodeloperator_test
import (
"github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/version"
"github.com/juju/version/v2"
gc "gopkg.in/check.v1"

basetesting "github.com/juju/juju/api/base/testing"
Expand Down
2 changes: 1 addition & 1 deletion api/caasoperator/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/juju/charm/v8"
"github.com/juju/errors"
"github.com/juju/names/v4"
"github.com/juju/version"
"github.com/juju/version/v2"

"github.com/juju/juju/api/base"
"github.com/juju/juju/api/common"
Expand Down
2 changes: 1 addition & 1 deletion api/caasoperator/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/juju/names/v4"
"github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/version"
"github.com/juju/version/v2"
gc "gopkg.in/check.v1"

basetesting "github.com/juju/juju/api/base/testing"
Expand Down
Loading

0 comments on commit b7002c6

Please sign in to comment.