Skip to content

Commit

Permalink
Merge pull request juju#17538 from Aflynn50/3.4-3.5
Browse files Browse the repository at this point in the history
juju#17538

Merge up 3.4 into 3.5. There were conflicts in one test file for bundles which were easy to resolve. The charm url no longer appears to include the series in 3.5 and since "noble" had been added to the url in several of the tests in 3.4 these changes could be dropped.

The commits in this merge up PR are:
- juju#17535 from SimonRichardson
- juju#17513 from Aflynn50
- juju#17485 from hpidcock
- juju#17510 from SimonRichardson
- juju#17497 from nvinuesa
- juju#17502 from ycliuhw/fix
- juju#17484 from hpidcock
  • Loading branch information
jujubot authored Jun 18, 2024
2 parents 6e3239a + f2c6ae4 commit da76609
Show file tree
Hide file tree
Showing 27 changed files with 324 additions and 59 deletions.
6 changes: 4 additions & 2 deletions apiserver/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,10 @@ func (a *admin) authenticate(ctx context.Context, req params.LoginRequest) (*aut
startPinger = false
controllerConn = true
}
} else if a.root.model == nil {
// Anonymous login to unknown model.
}
if a.root.model == nil {
// Login to an unknown or migrated model.
// See maybeEmitRedirectError for user logins who are redirected.
// Hide the fact that the model does not exist.
return nil, errors.Unauthorizedf("invalid entity name or password")
}
Expand Down
1 change: 1 addition & 0 deletions apiserver/facades/client/client/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ var scenarioStatus = &params.FullStatus{
"": network.AlphaSpaceName,
"server": network.AlphaSpaceName,
"server-admin": network.AlphaSpaceName,
"db-router": network.AlphaSpaceName,
"metrics-client": network.AlphaSpaceName,
},
},
Expand Down
18 changes: 9 additions & 9 deletions apiserver/facades/client/modelupgrader/upgrader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ var winVersions = []string{
"win2016", "win2016hv", "win2019", "win7", "win8", "win81", "win10",
}

var ubuntuVersions = []string{
// unsupportedUbuntuVersions are the ubuntu versions that juju does not support.
var unsupportedUbuntuVersions = []string{
"12.04",
"12.10",
"13.04",
Expand All @@ -65,7 +66,6 @@ var ubuntuVersions = []string{
"22.10",
"23.04",
"23.10",
"24.04",
}

var controllerCfg = controller.Config{
Expand Down Expand Up @@ -257,7 +257,7 @@ func (s *modelUpgradeSuite) assertUpgradeModelForControllerModelJuju3(c *gc.C, d
// - check if the model has win machines;
ctrlState.EXPECT().MachineCountForBase(makeBases("windows", winVersions)).Return(nil, nil)
// - check if the model has deprecated ubuntu machines;
ctrlState.EXPECT().MachineCountForBase(makeBases("ubuntu", ubuntuVersions)).Return(nil, nil)
ctrlState.EXPECT().MachineCountForBase(makeBases("ubuntu", unsupportedUbuntuVersions)).Return(nil, nil)
// - check LXD version.
// - check if model has charm store charms;
ctrlState.EXPECT().AllCharmURLs().Return(nil, errors.NotFoundf("charms"))
Expand All @@ -277,7 +277,7 @@ func (s *modelUpgradeSuite) assertUpgradeModelForControllerModelJuju3(c *gc.C, d
// - check if the model has win machines;
state1.EXPECT().MachineCountForBase(makeBases("windows", winVersions)).Return(nil, nil)
// - check if the model has deprecated ubuntu machines;
state1.EXPECT().MachineCountForBase(makeBases("ubuntu", ubuntuVersions)).Return(nil, nil)
state1.EXPECT().MachineCountForBase(makeBases("ubuntu", unsupportedUbuntuVersions)).Return(nil, nil)
// - check if model has charm store charms;
state1.EXPECT().AllCharmURLs().Return(nil, errors.NotFoundf("charms"))
// - check LXD version.
Expand Down Expand Up @@ -383,7 +383,7 @@ func (s *modelUpgradeSuite) TestUpgradeModelForControllerDyingHostedModelJuju3(c
// - check if the model has win machines;
ctrlState.EXPECT().MachineCountForBase(makeBases("windows", winVersions)).Return(nil, nil)
// - check if the model has deprecated ubuntu machines;
ctrlState.EXPECT().MachineCountForBase(makeBases("ubuntu", ubuntuVersions)).Return(nil, nil)
ctrlState.EXPECT().MachineCountForBase(makeBases("ubuntu", unsupportedUbuntuVersions)).Return(nil, nil)
// - check LXD version.
// - check if model has charm store charms;
ctrlState.EXPECT().AllCharmURLs().Return(nil, errors.NotFoundf("charms"))
Expand Down Expand Up @@ -488,7 +488,7 @@ func (s *modelUpgradeSuite) TestUpgradeModelForControllerModelJuju3Failed(c *gc.
// - check if the model has win machines;
ctrlState.EXPECT().MachineCountForBase(makeBases("windows", winVersions)).Return(map[string]int{"win10": 1, "win7": 2}, nil)
// - check if the model has deprecated ubuntu machines;
ctrlState.EXPECT().MachineCountForBase(makeBases("ubuntu", ubuntuVersions)).Return(map[string]int{"xenial": 2}, nil)
ctrlState.EXPECT().MachineCountForBase(makeBases("ubuntu", unsupportedUbuntuVersions)).Return(map[string]int{"xenial": 2}, nil)
// - check if model has charm store charms;
ctrlState.EXPECT().AllCharmURLs().Return(nil, errors.NotFoundf("charms"))
// - check LXD version.
Expand All @@ -509,7 +509,7 @@ func (s *modelUpgradeSuite) TestUpgradeModelForControllerModelJuju3Failed(c *gc.
// - check if the model has win machines;
state1.EXPECT().MachineCountForBase(makeBases("windows", winVersions)).Return(map[string]int{"win10": 1, "win7": 3}, nil)
// - check if the model has deprecated ubuntu machines;
state1.EXPECT().MachineCountForBase(makeBases("ubuntu", ubuntuVersions)).Return(map[string]int{
state1.EXPECT().MachineCountForBase(makeBases("ubuntu", unsupportedUbuntuVersions)).Return(map[string]int{
"artful": 1, "cosmic": 2, "disco": 3, "eoan": 4, "groovy": 5,
"hirsute": 6, "impish": 7, "precise": 8, "quantal": 9, "raring": 10,
"saucy": 11, "trusty": 12, "utopic": 13, "vivid": 14, "wily": 15,
Expand Down Expand Up @@ -597,7 +597,7 @@ func (s *modelUpgradeSuite) assertUpgradeModelJuju3(c *gc.C, ctrlModelVers strin
// - check if the model has win machines;
st.EXPECT().MachineCountForBase(makeBases("windows", winVersions)).Return(nil, nil)
// - check if the model has deprecated ubuntu machines;
st.EXPECT().MachineCountForBase(makeBases("ubuntu", ubuntuVersions)).Return(nil, nil)
st.EXPECT().MachineCountForBase(makeBases("ubuntu", unsupportedUbuntuVersions)).Return(nil, nil)
// - check LXD version.
serverFactory.EXPECT().RemoteServer(s.cloudSpec).Return(server, nil)
server.EXPECT().ServerVersion().Return("5.2")
Expand Down Expand Up @@ -678,7 +678,7 @@ func (s *modelUpgradeSuite) TestUpgradeModelJuju3Failed(c *gc.C) {
// - check if the model has win machines;
st.EXPECT().MachineCountForBase(makeBases("windows", winVersions)).Return(map[string]int{"win10": 1, "win7": 3}, nil)
// - check if the model has deprecated ubuntu machines;
st.EXPECT().MachineCountForBase(makeBases("ubuntu", ubuntuVersions)).Return(map[string]int{
st.EXPECT().MachineCountForBase(makeBases("ubuntu", unsupportedUbuntuVersions)).Return(map[string]int{
"artful": 1, "cosmic": 2, "disco": 3, "eoan": 4, "groovy": 5,
"hirsute": 6, "impish": 7, "precise": 8, "quantal": 9, "raring": 10,
"saucy": 11, "trusty": 12, "utopic": 13, "vivid": 14, "wily": 15,
Expand Down
8 changes: 4 additions & 4 deletions cmd/juju/application/deployer/bundlehandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ func (s *BundleDeployRepositorySuite) TestDeployKubernetesBundleSuccess(c *gc.C)
s.runDeploy(c, kubernetesGitlabBundle)

c.Assert(s.deployArgs, gc.HasLen, 2)
s.assertDeployArgs(c, gitlabCurl.String(), "gitlab", "ubuntu", "22.04")
s.assertDeployArgs(c, mariadbCurl.String(), "mariadb", "ubuntu", "22.04")
s.assertDeployArgs(c, gitlabCurl.String(), "gitlab", "ubuntu", "24.04")
s.assertDeployArgs(c, mariadbCurl.String(), "mariadb", "ubuntu", "24.04")
s.assertDeployArgsStorage(c, "mariadb", map[string]storage.Constraints{"database": {Pool: "mariadb-pv", Size: 0x14, Count: 0x1}})
s.assertDeployArgsConfig(c, "mariadb", map[string]interface{}{"dataset-size": "70%"})

Expand Down Expand Up @@ -1765,7 +1765,7 @@ func (s *BundleDeployRepositorySuite) TestDeployBundleExpose(c *gc.C) {
{
charmMetaSeries: []string{"jammy", "focal"},
curl: wordpressCurl,
machineUbuntuVersion: "22.04",
machineUbuntuVersion: "24.04",
},
}
s.setupCharmUnits(chUnits)
Expand All @@ -1780,7 +1780,7 @@ applications:
`
s.runDeploy(c, content)

s.assertDeployArgs(c, wordpressCurl.String(), "wordpress", "ubuntu", "22.04")
s.assertDeployArgs(c, wordpressCurl.String(), "wordpress", "ubuntu", "24.04")
c.Check(s.output.String(), gc.Equals, ""+
"Located charm \"wordpress\" in charm-hub\n"+
"Executing changes:\n"+
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/application/deployer/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func NewDeployerFactory(dep DeployerDependencies) DeployerFactory {
}

// GetDeployer returns the correct deployer to use based on the cfg provided.
// A ModelConfigGetter needed to find the deployer.
// A ModelConfigGetter is needed to find the deployer.
func (d *factory) GetDeployer(cfg DeployerConfig, getter ModelConfigGetter, resolver Resolver) (Deployer, error) {
// Determine the type of deploy we have
var dk DeployerKind
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/ssh/debughooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ var debugHooksTests = []struct {
}, {
info: `invalid hook`,
args: []string{"mysql/0", "invalid-hook"},
error: `unit "mysql/0" contains neither hook nor action "invalid-hook", valid actions are [anotherfakeaction fakeaction] and valid hooks are [collect-metrics config-changed install juju-info-relation-broken juju-info-relation-changed juju-info-relation-created juju-info-relation-departed juju-info-relation-joined leader-deposed leader-elected leader-settings-changed meter-status-changed metrics-client-relation-broken metrics-client-relation-changed metrics-client-relation-created metrics-client-relation-departed metrics-client-relation-joined post-series-upgrade pre-series-upgrade remove secret-changed secret-expired secret-remove secret-rotate server-admin-relation-broken server-admin-relation-changed server-admin-relation-created server-admin-relation-departed server-admin-relation-joined server-relation-broken server-relation-changed server-relation-created server-relation-departed server-relation-joined start stop update-status upgrade-charm]`,
error: `unit "mysql/0" contains neither hook nor action "invalid-hook", valid actions are [anotherfakeaction fakeaction] and valid hooks are [collect-metrics config-changed db-router-relation-broken db-router-relation-changed db-router-relation-created db-router-relation-departed db-router-relation-joined install juju-info-relation-broken juju-info-relation-changed juju-info-relation-created juju-info-relation-departed juju-info-relation-joined leader-deposed leader-elected leader-settings-changed meter-status-changed metrics-client-relation-broken metrics-client-relation-changed metrics-client-relation-created metrics-client-relation-departed metrics-client-relation-joined post-series-upgrade pre-series-upgrade remove secret-changed secret-expired secret-remove secret-rotate server-admin-relation-broken server-admin-relation-changed server-admin-relation-created server-admin-relation-departed server-admin-relation-joined server-relation-broken server-relation-changed server-relation-created server-relation-departed server-relation-joined start stop update-status upgrade-charm]`,
}, {
info: `no args at all`,
args: nil,
Expand Down
2 changes: 2 additions & 0 deletions cmd/juju/status/status_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2915,6 +2915,7 @@ var statusTests = []testCase{
"": network.AlphaSpaceName,
"server": network.AlphaSpaceName,
"server-admin": network.AlphaSpaceName,
"db-router": network.AlphaSpaceName,
"metrics-client": network.AlphaSpaceName,
},
}),
Expand Down Expand Up @@ -3047,6 +3048,7 @@ var statusTests = []testCase{
"": network.AlphaSpaceName,
"server": network.AlphaSpaceName,
"server-admin": network.AlphaSpaceName,
"db-router": network.AlphaSpaceName,
"metrics-client": network.AlphaSpaceName,
},
}),
Expand Down
1 change: 1 addition & 0 deletions core/base/supported.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ var ubuntuSeries = map[SeriesName]seriesVersion{
WorkloadType: ControllerWorkloadType,
Version: "24.04",
LTS: true,
Supported: true,
ESMSupported: true,
},
}
Expand Down
2 changes: 1 addition & 1 deletion core/base/supportedseries_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (s *SupportedSeriesLinuxSuite) TestLatestLts(c *gc.C) {
latest, want string
}{
{"testseries", "testseries"},
{"", "jammy"},
{"", "noble"},
}
for _, test := range table {
SetLatestLtsForTesting(test.latest)
Expand Down
5 changes: 3 additions & 2 deletions core/charm/baseselector.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ func (s BaseSelector) validate(supportedCharmBases, supportedJujuBases []base.Ba
// Order of preference is:
// - user requested with --base or defined by bundle when deploying
// - model default, if set, acts like --base
// - juju default ubuntu LTS from charm manifest
// - first base listed in the charm manifest
// - the latest known Ubuntu LTS (if compatible with valid charm bases)
// - juju's default supported Ubuntu LTS (if compatible with valid charm bases)
// - the first supported base in the charm manifest
// - in the case of local charms with no manifest nor base in metadata,
// base must be provided by the user.
func (s BaseSelector) CharmBase() (selectedBase base.Base, err error) {
Expand Down
4 changes: 0 additions & 4 deletions core/charm/baseselector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ func (s *baseSelectorSuite) TestCharmBase(c *gc.C) {
},
}

// Use bionic for LTS for all calls.
previous := base.SetLatestLtsForTesting("focal")
defer base.SetLatestLtsForTesting(previous)

for i, test := range deployBasesTests {
c.Logf("test %d [%s]", i, test.title)
test.selector.logger = s.logger
Expand Down
3 changes: 1 addition & 2 deletions database/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"net"
"os"
Expand Down Expand Up @@ -322,7 +321,7 @@ func (m *NodeManager) WithTLSOption() (app.Option, error) {
// Dqlite as the member of a cluster with peers representing other controllers.
func (m *NodeManager) WithClusterOption(addrs []string) app.Option {
peerAddrs := transform.Slice(addrs, func(addr string) string {
return fmt.Sprintf("%s:%d", addr, m.port)
return net.JoinHostPort(addr, strconv.Itoa(m.port))
})

m.logger.Debugf("determined Dqlite cluster members: %v", peerAddrs)
Expand Down
13 changes: 12 additions & 1 deletion database/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func (s *nodeManagerSuite) TestWithTLSOptionSuccess(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
}

func (s *nodeManagerSuite) TestWithClusterOptionSuccess(c *gc.C) {
func (s *nodeManagerSuite) TestWithClusterOptionIPv4Success(c *gc.C) {
cfg := fakeAgentConfig{}
m := NewNodeManager(cfg, true, stubLogger{}, coredatabase.NoopSlowQueryLogger{})

Expand All @@ -350,6 +350,17 @@ func (s *nodeManagerSuite) TestWithClusterOptionSuccess(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
}

func (s *nodeManagerSuite) TestWithClusterOptionIPv6Success(c *gc.C) {
cfg := fakeAgentConfig{}
m := NewNodeManager(cfg, true, stubLogger{}, coredatabase.NoopSlowQueryLogger{})

dqliteApp, err := app.New(c.MkDir(), m.WithClusterOption([]string{"::1"}))
c.Assert(err, jc.ErrorIsNil)

err = dqliteApp.Close()
c.Assert(err, jc.ErrorIsNil)
}

func (s *nodeManagerSuite) TestWithPreferredCloudLocalAddressOptionNoAddrFallback(c *gc.C) {
ctrl := gomock.NewController(c)
defer ctrl.Finish()
Expand Down
55 changes: 55 additions & 0 deletions provider/ec2/series_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,61 @@ const testImageMetadataProduct = `
{
"content_id": "com.ubuntu.cloud:released:aws",
"products": {
"com.ubuntu.cloud:server:24.04:amd64": {
"release": "noble",
"version": "24.04",
"arch": "amd64",
"versions": {
"20121218": {
"items": {
"usee1pi": {
"root_store": "instance",
"virt": "pv",
"region": "us-east-1",
"id": "ami-02204111"
},
"usww1pe": {
"root_store": "ssd",
"virt": "pv",
"region": "eu-west-1",
"id": "ami-02204116"
},
"apne1pe": {
"root_store": "ssd",
"virt": "pv",
"region": "ap-northeast-1",
"id": "ami-02204126"
},
"apne1he": {
"root_store": "ssd",
"virt": "hvm",
"region": "ap-northeast-1",
"id": "ami-02204187"
},
"test1peebs": {
"root_store": "ssd",
"virt": "pv",
"region": "test",
"id": "ami-02204133"
},
"test1pessd": {
"root_store": "ebs",
"virt": "pv",
"region": "test",
"id": "ami-02204139"
},
"test1he": {
"root_store": "ssd",
"virt": "hvm",
"region": "test",
"id": "ami-02204135"
}
},
"pubname": "ubuntu-noble-24.04-amd64-server-20121218",
"label": "release"
}
}
},
"com.ubuntu.cloud:server:22.04:amd64": {
"release": "jammy",
"version": "22.04",
Expand Down
15 changes: 14 additions & 1 deletion state/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ func (s *ApplicationSuite) TestMergeBindings(c *gc.C) {
"metrics-client": network.AlphaSpaceName,
"server": network.AlphaSpaceName,
"server-admin": network.AlphaSpaceName,
"db-router": network.AlphaSpaceName,
}
b, err := s.mysql.EndpointBindings()
c.Assert(err, jc.ErrorIsNil)
Expand Down Expand Up @@ -499,6 +500,7 @@ func (s *ApplicationSuite) TestMergeBindingsWithForce(c *gc.C) {
"metrics-client": network.AlphaSpaceName,
"server": network.AlphaSpaceName,
"server-admin": network.AlphaSpaceName,
"db-router": network.AlphaSpaceName,
}
b, err := s.mysql.EndpointBindings()
c.Assert(err, jc.ErrorIsNil)
Expand Down Expand Up @@ -2489,6 +2491,17 @@ func (s *ApplicationSuite) TestMysqlEndpoints(c *gc.C) {
Scope: charm.ScopeGlobal,
},
})
dbRouterEP, err := s.mysql.Endpoint("db-router")
c.Assert(err, jc.ErrorIsNil)
c.Assert(dbRouterEP, gc.DeepEquals, state.Endpoint{
ApplicationName: "mysql",
Relation: charm.Relation{
Interface: "db-router",
Name: "db-router",
Role: charm.RoleProvider,
Scope: charm.ScopeGlobal,
},
})
monitoringEP, err := s.mysql.Endpoint("metrics-client")
c.Assert(err, jc.ErrorIsNil)
c.Assert(monitoringEP, gc.DeepEquals, state.Endpoint{
Expand All @@ -2503,7 +2516,7 @@ func (s *ApplicationSuite) TestMysqlEndpoints(c *gc.C) {

eps, err := s.mysql.Endpoints()
c.Assert(err, jc.ErrorIsNil)
c.Assert(eps, jc.SameContents, []state.Endpoint{jiEP, serverEP, serverAdminEP, monitoringEP})
c.Assert(eps, jc.SameContents, []state.Endpoint{jiEP, serverEP, serverAdminEP, dbRouterEP, monitoringEP})
}

func (s *ApplicationSuite) TestRiakEndpoints(c *gc.C) {
Expand Down
12 changes: 6 additions & 6 deletions state/applicationoffers.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ func (s *applicationOffers) UpdateOffer(offerArgs crossmodel.AddApplicationOffer
// case. This prevents users from accidentally breaking saas
// consumers.
goneEndpoints := existingEndpoints.Difference(updatedEndpoints)
if err := s.ensureEndpointsNotInUse(curOfferDoc.ApplicationName, curOfferDoc.OfferUUID, goneEndpoints); err != nil {
if err := s.ensureEndpointsNotInUse(curOfferDoc.ApplicationName, curOfferDoc.OfferUUID, goneEndpoints, updatedEndpoints); err != nil {
return nil, err
}
}
Expand All @@ -705,8 +705,8 @@ func (s *applicationOffers) UpdateOffer(offerArgs crossmodel.AddApplicationOffer
return s.makeApplicationOffer(doc)
}

func (s *applicationOffers) ensureEndpointsNotInUse(appName, offerUUID string, endpoints set.Strings) error {
if len(endpoints) == 0 {
func (s *applicationOffers) ensureEndpointsNotInUse(appName, offerUUID string, removedEndpoints, updatedEndpoints set.Strings) error {
if len(removedEndpoints) == 0 {
return nil
}

Expand All @@ -723,7 +723,7 @@ func (s *applicationOffers) ensureEndpointsNotInUse(appName, offerUUID string, e
return errors.New("malformed relation key")
}

if tokens[0] == appName && endpoints.Contains(tokens[1]) {
if tokens[0] == appName && removedEndpoints.Contains(tokens[1]) {
inUse.Add(tokens[1])
}
}
Expand All @@ -733,9 +733,9 @@ func (s *applicationOffers) ensureEndpointsNotInUse(appName, offerUUID string, e
case 0:
return nil
case 1:
return errors.Errorf("application endpoint %q has active consumers", inUse.Values()[0])
return errors.Errorf("updating offer %s:%s would remove endpoint %q which has active consumers", appName, strings.Join(updatedEndpoints.SortedValues(), ", "), inUse.Values()[0])
default:
return errors.Errorf("application endpoints %q have active consumers", strings.Join(inUse.SortedValues(), ", "))
return errors.Errorf("updating offer %s:%s would remove endpoints %q which have active consumers", appName, strings.Join(updatedEndpoints.SortedValues(), ", "), strings.Join(inUse.SortedValues(), ", "))
}
}

Expand Down
Loading

0 comments on commit da76609

Please sign in to comment.