Skip to content

Commit

Permalink
Merge branch '3.2' into 3.2-into-3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-w-shaw committed Aug 14, 2023
2 parents a2ecdd4 + 7ccdfdb commit 56b2ae8
Show file tree
Hide file tree
Showing 37 changed files with 93 additions and 421 deletions.
14 changes: 11 additions & 3 deletions apiserver/facades/client/application/deployrepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,14 @@ func (v *deployFromRepositoryValidator) deducePlatform(arg params.DeployFromRepo
}
}
if argBase != nil {
platform.OS = argBase.Name
platform.Channel = argBase.Channel
base, err := corebase.ParseBase(argBase.Name, argBase.Channel)
if err != nil {
return corecharm.Platform{}, usedModelDefaultBase, err
}
platform.OS = base.OS
// platform channels don't model the concept of a risk
// so ensure that only the track is included
platform.Channel = base.Channel.Track
}

// Initial validation of platform from known data.
Expand Down Expand Up @@ -642,7 +648,9 @@ func (v *deployFromRepositoryValidator) deducePlatform(arg params.DeployFromRepo
return corecharm.Platform{}, usedModelDefaultBase, err
}
platform.OS = defaultBase.OS
platform.Channel = defaultBase.Channel.String()
// platform channels don't model the concept of a risk
// so ensure that only the track is included
platform.Channel = defaultBase.Channel.Track
usedModelDefaultBase = true
}
}
Expand Down
24 changes: 23 additions & 1 deletion apiserver/facades/client/application/deployrepository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,28 @@ func (s *validatorSuite) TestDeducePlatformSimple(c *gc.C) {
c.Assert(plat, gc.DeepEquals, corecharm.Platform{Architecture: "amd64"})
}

func (s *validatorSuite) TestDeducePlatformRiskInChannel(c *gc.C) {
defer s.setupMocks(c).Finish()
//model constraint default
s.state.EXPECT().ModelConstraints().Return(constraints.Value{Arch: strptr("amd64")}, nil)

arg := params.DeployFromRepositoryArg{
CharmName: "testme",
Base: &params.Base{
Name: "ubuntu",
Channel: "22.10/stable",
},
}
plat, usedModelDefaultBase, err := s.getValidator().deducePlatform(arg)
c.Assert(err, gc.IsNil)
c.Assert(usedModelDefaultBase, jc.IsFalse)
c.Assert(plat, gc.DeepEquals, corecharm.Platform{
Architecture: "amd64",
OS: "ubuntu",
Channel: "22.10",
})
}

func (s *validatorSuite) TestDeducePlatformArgArchBase(c *gc.C) {
defer s.setupMocks(c).Finish()

Expand Down Expand Up @@ -635,7 +657,7 @@ func (s *validatorSuite) TestDeducePlatformModelDefaultBase(c *gc.C) {
c.Assert(plat, gc.DeepEquals, corecharm.Platform{
Architecture: "amd64",
OS: "ubuntu",
Channel: "22.04/stable",
Channel: "22.04",
})
}

Expand Down
34 changes: 0 additions & 34 deletions cloudconfig/cloudinit/cloudinit_opensuse.go

This file was deleted.

11 changes: 0 additions & 11 deletions cloudconfig/cloudinit/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,17 +447,6 @@ func New(osname string, opts ...func(*cloudConfig)) (CloudConfig, error) {
cloudConfig: cfg,
helper: centOSHelper{},
}, nil
case os.OpenSUSE:
cfg.paccmder = map[jujupackaging.PackageManagerName]commands.PackageCommander{
jujupackaging.ZypperPackageManager: commands.NewZypperPackageCommander(),
}
cfg.pacconfer = map[jujupackaging.PackageManagerName]config.PackagingConfigurer{
jujupackaging.ZypperPackageManager: config.NewZypperPackagingConfigurer(osname),
}
return &centOSCloudConfig{
cloudConfig: cfg,
helper: openSUSEHelper{paccmder: commands.NewZypperPackageCommander()},
}, nil
default:
return nil, errors.NotFoundf("cloudconfig for os %q", osname)
}
Expand Down
2 changes: 1 addition & 1 deletion cloudconfig/machinecloudconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func NewMachineInitReaderFromConfig(cfg MachineInitReaderConfig) InitReader {
// machine. It is sourced from both Cloud-Init and Curtin data.
func (r *MachineInitReader) GetInitConfig() (map[string]interface{}, error) {
switch utilsos.OSTypeForName(r.config.Base.OS) {
case utilsos.Ubuntu, utilsos.CentOS, utilsos.OpenSUSE:
case utilsos.Ubuntu, utilsos.CentOS:
hostSeries, err := osseries.HostSeries()
series, err2 := corebase.GetSeriesFromBase(r.config.Base)
if err != nil || err2 != nil || series != hostSeries {
Expand Down
6 changes: 0 additions & 6 deletions cloudconfig/machinecloudconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ var cloudinitDataVerifyTests = []cloudinitDataVerifyTest{
containerBase: corebase.MakeDefaultBase("centos", "7"),
result: expectedResult,
},
{
description: "centos8 on centos8",
machineBase: corebase.MakeDefaultBase("centos", "8"),
containerBase: corebase.MakeDefaultBase("centos", "8"),
result: expectedResult,
},
}

func (s *fromHostSuite) TestGetMachineCloudInitDataVerifySeries(c *gc.C) {
Expand Down
4 changes: 0 additions & 4 deletions cloudconfig/userdatacfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ func NewUserdataConfig(icfg *instancecfg.InstanceConfig, conf cloudinit.CloudCon
return &unixConfigure{base}, nil
case os.CentOS:
return &unixConfigure{base}, nil
case os.OpenSUSE:
return &unixConfigure{base}, nil
default:
return nil, errors.NotSupportedf("OS %s", icfg.Base.OS)
}
Expand Down Expand Up @@ -143,8 +141,6 @@ func SetUbuntuUser(conf cloudinit.CloudConfig, authorizedKeys string) {
groups = UbuntuGroups
case os.CentOS:
groups = CentOSGroups
case os.OpenSUSE:
groups = OpenSUSEGroups
}
conf.AddUser(&cloudinit.User{
Name: "ubuntu",
Expand Down
23 changes: 0 additions & 23 deletions cloudconfig/userdatacfg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,18 +429,6 @@ systemctl is-active firewalld &> /dev/null && systemctl stop firewalld || true
sed -i "s/\^\.\*requiretty/#Defaults requiretty/" /etc/sudoers
`,
},
// OpenSUSE non controller
{
cfg: makeNormalConfig(corebase.MakeDefaultBase("opensuse", "opensuse42"), 0),
inexactMatch: true,
upgradedToVersion: "1.2.3",
expectScripts: `
systemctl is-enabled firewalld &> /dev/null && systemctl mask firewalld || true
systemctl is-active firewalld &> /dev/null && systemctl stop firewalld || true
sed -i "s/\^\.\*requiretty/#Defaults requiretty/" /etc/sudoers
`,
},

// check that it works ok with compound machine ids.
{
cfg: makeNormalConfig(jammy, 0).mutate(func(cfg *testInstanceConfig) {
Expand Down Expand Up @@ -1418,14 +1406,3 @@ func (*cloudinitSuite) TestCloudInitBootstrapInitialSSHKeys(c *gc.C) {
`ssh-keygen -t ed25519 -N "" -f /etc/ssh/ssh_host_ed25519_key || true`,
})
}

func (*cloudinitSuite) TestSetUbuntuUserOpenSUSE(c *gc.C) {
ci, err := cloudinit.New("opensuse")
c.Assert(err, jc.ErrorIsNil)
cloudconfig.SetUbuntuUser(ci, "akey\n#also\nbkey")
data, err := ci.RenderYAML()
c.Assert(err, jc.ErrorIsNil)
keys := []string{"akey", "bkey"}
expected := expectedUbuntuUser(cloudconfig.OpenSUSEGroups, keys)
c.Assert(string(data), jc.YAMLEquals, expected)
}
19 changes: 1 addition & 18 deletions cloudconfig/userdatacfg_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ var (
// CentOSGroups is the set of unix groups to add the "ubuntu" user to
// when initializing a CentOS system.
CentOSGroups = []string{"adm", "systemd-journal", "wheel"}

// OpenSUSEGroups is the set of unix groups to add the "ubuntu" user to
// when initializing a OpenSUSE system.
OpenSUSEGroups = []string{"users"}
)

type unixConfigure struct {
Expand Down Expand Up @@ -187,19 +183,6 @@ func (w *unixConfigure) ConfigureBasic() error {

`sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers`,
)
case os.OpenSUSE:
w.conf.AddScripts(
// Mask and stop firewalld, if enabled, so it cannot start. See
// http://pad.lv/1492066. firewalld might be missing, in which case
// is-enabled and is-active prints an error, which is why the output
// is suppressed.
"systemctl is-enabled firewalld &> /dev/null && systemctl mask firewalld || true",
"systemctl is-active firewalld &> /dev/null && systemctl stop firewalld || true",
`sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers`,
//Scripts assume ubuntu group for ubuntu user...
`(grep ubuntu /etc/group) || groupadd ubuntu`,
`usermod -g ubuntu -G ubuntu,users ubuntu`,
)
}
SetUbuntuUser(w.conf, w.icfg.AuthorizedKeys)

Expand Down Expand Up @@ -237,7 +220,7 @@ func (w *unixConfigure) ConfigureBasic() error {
func (w *unixConfigure) setDataDirPermissions() string {
var user string
switch w.os {
case os.CentOS, os.OpenSUSE:
case os.CentOS:
user = "root"
default:
user = "syslog"
Expand Down
8 changes: 4 additions & 4 deletions cmd/juju/application/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (s *DeploySuiteBase) SetUpTest(c *gc.C) {
s.PatchValue(&deployer.SupportedJujuSeries,
func(time.Time, string, string) (set.Strings, error) {
return set.NewStrings(
"centos7", "centos8", "centos9", "genericlinux", "kubernetes", "opensuseleap",
"centos7", "centos9", "genericlinux", "kubernetes",
"jammy", "focal", "jammy", "xenial",
), nil
},
Expand Down Expand Up @@ -1042,7 +1042,7 @@ func (s *CAASDeploySuiteBase) SetUpTest(c *gc.C) {
s.PatchValue(&deployer.SupportedJujuSeries,
func(time.Time, string, string) (set.Strings, error) {
return set.NewStrings(
"centos7", "centos8", "centos9", "genericlinux", "kubernetes", "opensuseleap",
"centos7", "centos9", "genericlinux", "kubernetes",
"jammy", "focal", "jammy", "xenial",
), nil
},
Expand Down Expand Up @@ -1483,7 +1483,7 @@ func (s *DeploySuite) setupNonESMBase(c *gc.C) (corebase.Base, string) {
s.PatchValue(&deployer.SupportedJujuSeries,
func(time.Time, string, string) (set.Strings, error) {
return set.NewStrings(
"centos7", "centos8", "centos9", "genericlinux", "kubernetes", "opensuseleap",
"centos7", "centos9", "genericlinux", "kubernetes",
"jammy", "focal", "jammy", "xenial",
), nil
},
Expand Down Expand Up @@ -1911,7 +1911,7 @@ func (s *DeployUnitTestSuite) SetUpTest(c *gc.C) {
s.PatchValue(&deployer.SupportedJujuSeries,
func(time.Time, string, string) (set.Strings, error) {
return set.NewStrings(
"centos7", "centos8", "centos9", "genericlinux", "kubernetes", "opensuseleap",
"centos7", "centos9", "genericlinux", "kubernetes",
"jammy", "focal", "jammy", "xenial",
), nil
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/application/deployer/deployer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (s *deployerSuite) SetUpTest(_ *gc.C) {
s.PatchValue(&SupportedJujuSeries,
func(time.Time, string, string) (set.Strings, error) {
return set.NewStrings(
"centos7", "centos8", "centos9", "genericlinux", "kubernetes", "opensuseleap",
"centos7", "centos9", "genericlinux", "kubernetes",
"jammy", "focal", "bionic", "xenial",
), nil
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/application/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (s *RepoSuiteBaseSuite) SetUpTest(c *gc.C) {
s.PatchValue(&deployer.SupportedJujuSeries,
func(time.Time, string, string) (set.Strings, error) {
return set.NewStrings(
"centos7", "centos8", "centos9", "genericlinux", "kubernetes", "opensuseleap",
"centos7", "centos9", "genericlinux", "kubernetes",
"jammy", "focal", "bionic", "xenial",
), nil
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/juju/application/refresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ func (s *RefreshErrorsStateSuite) SetUpSuite(c *gc.C) {
s.PatchValue(&deployer.SupportedJujuSeries,
func(time.Time, string, string) (set.Strings, error) {
return set.NewStrings(
"centos7", "centos8", "centos9", "genericlinux", "kubernetes", "opensuseleap",
"centos7", "centos9", "genericlinux", "kubernetes",
"jammy", "focal", "bionic", "xenial",
), nil
},
Expand Down Expand Up @@ -565,7 +565,7 @@ func (s *RefreshSuccessStateSuite) SetUpTest(c *gc.C) {
s.PatchValue(&deployer.SupportedJujuSeries,
func(time.Time, string, string) (set.Strings, error) {
return set.NewStrings(
"centos7", "centos8", "centos9", "genericlinux", "kubernetes", "opensuseleap",
"centos7", "centos9", "genericlinux", "kubernetes",
"jammy", "focal", "bionic", "xenial",
), nil
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/application/unexpose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (s *UnexposeSuite) SetUpTest(c *gc.C) {
s.PatchValue(&deployer.SupportedJujuSeries,
func(time.Time, string, string) (set.Strings, error) {
return set.NewStrings(
"centos7", "centos8", "centos9", "genericlinux", "kubernetes", "opensuseleap",
"centos7", "centos9", "genericlinux", "kubernetes",
"jammy", "focal", "bionic", "xenial",
), nil
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/machine/upgrademachine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (s *UpgradeMachineSuite) SetUpTest(c *gc.C) {
s.PatchValue(&machine.SupportedJujuSeries,
func(time.Time, string, string) (set.Strings, error) {
return set.NewStrings(
"centos7", "centos8", "centos9", "genericlinux", "kubernetes", "opensuseleap",
"centos7", "centos9", "genericlinux", "kubernetes",
"jammy", "focal", "bionic", "xenial",
), nil
},
Expand Down
4 changes: 0 additions & 4 deletions container/lxd/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,6 @@ func constructBaseRemoteAlias(base jujubase.Base, arch string) (string, error) {
return "centos/9-Stream/cloud/amd64", nil
}
}
case jujuos.OpenSUSE:
if base.Channel.Track == "opensuse42" && arch == jujuarch.AMD64 {
return "opensuse/42.2/amd64", nil
}
}
return "", errors.NotSupportedf("base %q", base.DisplayString())
}
Loading

0 comments on commit 56b2ae8

Please sign in to comment.