Skip to content

Commit 58397a0

Browse files
committed
mantle: Replace all uses of system.RpmArch with standard arch API
Related: coreos@8d35527 To make it very clear that stream-metadata-go contains the canonical logic for getting the current RPM/CoreOS architecture, as distinct from the Go nomenclature.
1 parent 493c480 commit 58397a0

File tree

21 files changed

+90
-107
lines changed

21 files changed

+90
-107
lines changed

mantle/cmd/kola/kola.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"github.com/coreos/mantle/kola/register"
4141
"github.com/coreos/mantle/system"
4242
"github.com/coreos/mantle/util"
43+
coreosarch "github.com/coreos/stream-metadata-go/arch"
4344

4445
// register OS test suite
4546
_ "github.com/coreos/mantle/kola/registry"
@@ -558,15 +559,15 @@ func syncFindParentImageOptions() error {
558559
// Hardcoded for now based on https://github.com/openshift/installer/blob/release-4.6/data/data/rhcos.json
559560
tag := "rhcos-4.6"
560561
release := "46.82.202011260640-0"
561-
switch system.RpmArch() {
562+
switch coreosarch.CurrentRpmArch() {
562563
case "s390x":
563-
tag += "-" + system.RpmArch()
564+
tag += "-" + coreosarch.CurrentRpmArch()
564565
release = "46.82.202011261339-0"
565566
case "ppc64le":
566-
tag += "-" + system.RpmArch()
567+
tag += "-" + coreosarch.CurrentRpmArch()
567568
release = "46.82.202011260639-0"
568569
}
569-
parentBaseURL = fmt.Sprintf("https://rhcos.mirror.openshift.com/art/storage/releases/%s/%s/%s/", tag, release, system.RpmArch())
570+
parentBaseURL = fmt.Sprintf("https://rhcos.mirror.openshift.com/art/storage/releases/%s/%s/%s/", tag, release, coreosarch.CurrentRpmArch())
570571
// sigh...someday we'll get the stuff signed by ART or maybe https://github.com/openshift/enhancements/pull/201 will just happen
571572
skipSignature = true
572573
default:

mantle/cmd/kola/options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"strconv"
2222
"strings"
2323

24+
coreosarch "github.com/coreos/stream-metadata-go/arch"
2425
"github.com/coreos/stream-metadata-go/stream"
2526
"github.com/pkg/errors"
2627

@@ -65,7 +66,7 @@ func init() {
6566
sv(&kola.Options.Stream, "stream", "", "CoreOS stream ID (e.g. for Fedora CoreOS: stable, testing, next)")
6667
sv(&kola.Options.CosaWorkdir, "workdir", "", "coreos-assembler working directory")
6768
sv(&kola.Options.CosaBuildId, "build", "", "coreos-assembler build ID")
68-
sv(&kola.Options.CosaBuildArch, "arch", system.RpmArch(), "The target architecture of the build")
69+
sv(&kola.Options.CosaBuildArch, "arch", coreosarch.CurrentRpmArch(), "The target architecture of the build")
6970
// rhcos-specific options
7071
sv(&kola.Options.OSContainer, "oscontainer", "", "oscontainer image pullspec for pivot (RHCOS only)")
7172

mantle/cmd/kola/testiso.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ import (
3131
"time"
3232

3333
"github.com/coreos/mantle/platform/conf"
34-
"github.com/coreos/mantle/system"
3534
"github.com/coreos/mantle/util"
35+
coreosarch "github.com/coreos/stream-metadata-go/arch"
3636
"github.com/pkg/errors"
3737

3838
"github.com/spf13/cobra"
@@ -310,7 +310,7 @@ func newQemuBuilderWithDisk(outdir string) (*platform.QemuBuilder, *conf.Conf, e
310310
}
311311

312312
//TBD: see if we can remove this and just use AddDisk and inject bootindex during startup
313-
if system.RpmArch() == "s390x" || system.RpmArch() == "aarch64" {
313+
if coreosarch.CurrentRpmArch() == "s390x" || coreosarch.CurrentRpmArch() == "aarch64" {
314314
// s390x and aarch64 need to use bootindex as they don't support boot once
315315
if err := builder.AddDisk(&disk); err != nil {
316316
return nil, nil, err
@@ -340,7 +340,7 @@ func runTestIso(cmd *cobra.Command, args []string) error {
340340
}
341341

342342
// s390x: iso-install does not work because s390x uses an El Torito image
343-
if system.RpmArch() == "s390x" {
343+
if coreosarch.CurrentRpmArch() == "s390x" {
344344
fmt.Println("Skipping iso-install on s390x")
345345
noiso = true
346346
}
@@ -464,7 +464,7 @@ func runTestIso(cmd *cobra.Command, args []string) error {
464464
if kola.CosaBuild.Meta.BuildArtifacts.LiveIso == nil {
465465
return fmt.Errorf("build %s has no live ISO", kola.CosaBuild.Meta.Name)
466466
}
467-
switch system.RpmArch() {
467+
switch coreosarch.CurrentRpmArch() {
468468
case "x86_64":
469469
ranTest = true
470470
duration, err := testAsDisk(ctx, filepath.Join(outputDir, scenarioISOAsDisk))
@@ -474,7 +474,7 @@ func runTestIso(cmd *cobra.Command, args []string) error {
474474
}
475475
default:
476476
// no hybrid partition table to boot from
477-
fmt.Printf("%s unsupported on %s; skipping\n", scenarioISOAsDisk, system.RpmArch())
477+
fmt.Printf("%s unsupported on %s; skipping\n", scenarioISOAsDisk, coreosarch.CurrentRpmArch())
478478
}
479479
}
480480
if _, ok := targetScenarios[scenarioMinISOInstall]; ok {

mantle/cmd/ore/openstack/create.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ import (
1818
"fmt"
1919
"os"
2020

21-
"github.com/coreos/mantle/system"
2221
"github.com/spf13/cobra"
22+
23+
coreosarch "github.com/coreos/stream-metadata-go/arch"
2324
)
2425

2526
var (
@@ -44,7 +45,7 @@ After a successful run, the final line of output will be the ID of the image.
4445

4546
func init() {
4647
OpenStack.AddCommand(cmdCreate)
47-
cmdCreate.Flags().StringVar(&arch, "arch", system.RpmArch(), "The architecture of the image")
48+
cmdCreate.Flags().StringVar(&arch, "arch", coreosarch.CurrentRpmArch(), "The architecture of the image")
4849
cmdCreate.Flags().StringVar(&path, "file", "", "path to OpenStack image")
4950
cmdCreate.Flags().StringVar(&name, "name", "", "image name")
5051
cmdCreate.Flags().StringVar(&visibility, "visibility", "private", "Image visibility within OpenStack")

mantle/fcos/metadata.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ import (
2121
"net/http"
2222
"net/url"
2323

24+
coreosarch "github.com/coreos/stream-metadata-go/arch"
2425
"github.com/coreos/stream-metadata-go/fedoracoreos"
2526
fcosinternals "github.com/coreos/stream-metadata-go/fedoracoreos/internals"
2627
"github.com/coreos/stream-metadata-go/release"
2728
"github.com/coreos/stream-metadata-go/stream"
28-
29-
"github.com/coreos/mantle/system"
3029
)
3130

3231
func fetchURL(u url.URL) ([]byte, error) {
@@ -92,7 +91,7 @@ func FetchCanonicalStreamArtifacts(stream, architecture string) (*stream.Arch, e
9291
// FetchStreamThisArchitecture returns artifacts for the current architecture from
9392
// the given stream.
9493
func FetchStreamThisArchitecture(stream string) (*stream.Arch, error) {
95-
return FetchCanonicalStreamArtifacts(stream, system.RpmArch())
94+
return FetchCanonicalStreamArtifacts(stream, coreosarch.CurrentRpmArch())
9695
}
9796

9897
// GetCosaBuildURL returns a URL prefix for the coreos-assembler build.

mantle/kola/harness.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import (
5757
"github.com/coreos/mantle/platform/machine/unprivqemu"
5858
"github.com/coreos/mantle/system"
5959
"github.com/coreos/mantle/util"
60+
coreosarch "github.com/coreos/stream-metadata-go/arch"
6061
)
6162

6263
// InstalledTestsDir is a directory where "installed" external
@@ -595,7 +596,7 @@ func filterTests(tests map[string]*register.Test, patterns []string, pltfrm stri
595596
isExcluded = true
596597
break
597598
}
598-
allowedArchitecture, _ := isAllowed(system.RpmArch(), t.Architectures, t.ExcludeArchitectures)
599+
allowedArchitecture, _ := isAllowed(coreosarch.CurrentRpmArch(), t.Architectures, t.ExcludeArchitectures)
599600
allowed = allowed || (allowedPlatform && allowedArchitecture)
600601
}
601602
if isExcluded || !allowed {
@@ -618,7 +619,7 @@ func filterTests(tests map[string]*register.Test, patterns []string, pltfrm stri
618619
delete(t.NativeFuncs, k)
619620
continue
620621
}
621-
_, excluded = isAllowed(system.RpmArch(), nil, NativeFuncWrap.Exclusions)
622+
_, excluded = isAllowed(coreosarch.CurrentRpmArch(), nil, NativeFuncWrap.Exclusions)
622623
if excluded {
623624
delete(t.NativeFuncs, k)
624625
}
@@ -1042,7 +1043,7 @@ ExecStart=%s
10421043

10431044
// Architectures using 64k pages use slightly more memory, ask for more than requested
10441045
// to make sure that we don't run out of it. Currently ppc64le and aarch64 use 64k pages.
1045-
switch system.RpmArch() {
1046+
switch coreosarch.CurrentRpmArch() {
10461047
case "ppc64le", "aarch64":
10471048
if targetMeta.MinMemory <= 4096 {
10481049
targetMeta.MinMemory = targetMeta.MinMemory * 2

mantle/kola/tests/ignition/luks.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import (
44
"fmt"
55
"time"
66

7+
coreosarch "github.com/coreos/stream-metadata-go/arch"
8+
79
"github.com/coreos/mantle/kola"
810
"github.com/coreos/mantle/kola/cluster"
911
"github.com/coreos/mantle/kola/register"
1012
ut "github.com/coreos/mantle/kola/tests/util"
1113
"github.com/coreos/mantle/platform"
1214
"github.com/coreos/mantle/platform/conf"
1315
"github.com/coreos/mantle/platform/machine/unprivqemu"
14-
"github.com/coreos/mantle/system"
1516
"github.com/coreos/mantle/util"
1617
)
1718

@@ -90,8 +91,8 @@ func setupTangMachine(c cluster.TestCluster) ut.TangServer {
9091
// TODO: move container image to centralized namespace
9192
// container source: https://github.com/mike-nguyen/tang-docker-container/
9293
containerImage := "quay.io/mike_nguyen/tang"
93-
if system.RpmArch() != "x86_64" {
94-
containerImage = "quay.io/multi-arch/tang:" + system.RpmArch()
94+
if coreosarch.CurrentRpmArch() != "x86_64" {
95+
containerImage = "quay.io/multi-arch/tang:" + coreosarch.CurrentRpmArch()
9596
}
9697

9798
containerID, errMsg, err := m.SSH("sudo podman run -d -p 80:80 " + containerImage)
@@ -161,7 +162,7 @@ func runTest(c cluster.TestCluster, tpm2 bool, threshold int, killTangAfterFirst
161162
MinMemory: 4096,
162163
}
163164
// ppc64le and aarch64 use 64K pages
164-
switch system.RpmArch() {
165+
switch coreosarch.CurrentRpmArch() {
165166
case "ppc64le", "aarch64":
166167
opts.MinMemory = 8192
167168
}
@@ -171,7 +172,7 @@ func runTest(c cluster.TestCluster, tpm2 bool, threshold int, killTangAfterFirst
171172
}
172173
rootPart := "/dev/disk/by-partlabel/root"
173174
// hacky, but needed for s390x because of gpt issue with naming on big endian systems: https://bugzilla.redhat.com/show_bug.cgi?id=1899990
174-
if system.RpmArch() == "s390x" {
175+
if coreosarch.CurrentRpmArch() == "s390x" {
175176
rootPart = "/dev/disk/by-id/virtio-primary-disk-part4"
176177
}
177178
ut.LUKSSanityTest(c, tangd, m, tpm2, killTangAfterFirstBoot, rootPart)

mantle/kola/tests/misc/boot-mirror.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ import (
1818
"strings"
1919
"time"
2020

21+
coreosarch "github.com/coreos/stream-metadata-go/arch"
22+
2123
"github.com/coreos/mantle/kola"
2224
"github.com/coreos/mantle/kola/cluster"
2325
"github.com/coreos/mantle/kola/register"
2426
"github.com/coreos/mantle/kola/tests/util"
2527
"github.com/coreos/mantle/platform"
2628
"github.com/coreos/mantle/platform/conf"
2729
"github.com/coreos/mantle/platform/machine/unprivqemu"
28-
"github.com/coreos/mantle/system"
2930
ut "github.com/coreos/mantle/util"
3031
)
3132

@@ -99,7 +100,7 @@ func runBootMirrorTest(c cluster.TestCluster) {
99100
}
100101
// FIXME: for QEMU tests kola currently assumes the host CPU architecture
101102
// matches the one under test
102-
userdata := bootmirror.Subst("LAYOUT", system.RpmArch())
103+
userdata := bootmirror.Subst("LAYOUT", coreosarch.CurrentRpmArch())
103104
m, err = c.Cluster.(*unprivqemu.Cluster).NewMachineWithQemuOptions(userdata, options)
104105
if err != nil {
105106
c.Fatal(err)
@@ -146,7 +147,7 @@ func runBootMirrorLUKSTest(c cluster.TestCluster) {
146147
}
147148
// FIXME: for QEMU tests kola currently assumes the host CPU architecture
148149
// matches the one under test
149-
userdata := bootmirrorluks.Subst("LAYOUT", system.RpmArch())
150+
userdata := bootmirrorluks.Subst("LAYOUT", coreosarch.CurrentRpmArch())
150151
m, err = c.Cluster.(*unprivqemu.Cluster).NewMachineWithQemuOptions(userdata, options)
151152
if err != nil {
152153
c.Fatal(err)
@@ -180,7 +181,7 @@ func runBootMirrorLUKSTest(c cluster.TestCluster) {
180181
func luksTPMTest(c cluster.TestCluster, m platform.Machine, tpm2 bool) {
181182
rootPart := "/dev/md/md-root"
182183
// hacky, but needed for s390x because of gpt issue with naming on big endian systems: https://bugzilla.redhat.com/show_bug.cgi?id=1899990
183-
if system.RpmArch() == "s390x" {
184+
if coreosarch.CurrentRpmArch() == "s390x" {
184185
rootPart = "/dev/disk/by-id/virtio-primary-disk-part4"
185186
}
186187
var tangd util.TangServer
@@ -197,7 +198,7 @@ func bootMirrorSanityTest(c cluster.TestCluster, m platform.Machine, devices []s
197198
// Check that we took ownership of the rootfs
198199
c.RunCmdSync(m, "sudo test -f /boot/.root_uuid")
199200
// Check for bootuuid dropins where available
200-
switch system.RpmArch() {
201+
switch coreosarch.CurrentRpmArch() {
201202
case "s390x":
202203
case "x86_64", "aarch64":
203204
for _, dev := range devices {

mantle/kola/tests/misc/multipath.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ package misc
1717
import (
1818
"strings"
1919

20+
coreosarch "github.com/coreos/stream-metadata-go/arch"
21+
2022
"github.com/coreos/mantle/kola/cluster"
2123
"github.com/coreos/mantle/kola/register"
2224
"github.com/coreos/mantle/platform"
2325
"github.com/coreos/mantle/platform/conf"
24-
"github.com/coreos/mantle/system"
2526
)
2627

2728
var (
@@ -131,7 +132,7 @@ func verifyBootDropins(c cluster.TestCluster, m platform.Machine, checkBootuuid
131132
c.RunCmdSync(m, "sudo test -f /boot/.root_uuid")
132133
if checkBootuuid {
133134
// Check for bootuuid dropins where available
134-
switch system.RpmArch() {
135+
switch coreosarch.CurrentRpmArch() {
135136
case "s390x":
136137
case "x86_64", "aarch64":
137138
c.RunCmdSync(m, `

mantle/kola/tests/rhcos/upgrade.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ import (
2525
"time"
2626

2727
cosa "github.com/coreos/coreos-assembler/pkg/builds"
28+
coreosarch "github.com/coreos/stream-metadata-go/arch"
29+
2830
"github.com/coreos/mantle/kola"
2931
"github.com/coreos/mantle/kola/cluster"
3032
"github.com/coreos/mantle/kola/register"
3133
"github.com/coreos/mantle/kola/tests/util"
3234
"github.com/coreos/mantle/platform"
3335
"github.com/coreos/mantle/platform/conf"
3436
"github.com/coreos/mantle/platform/machine/unprivqemu"
35-
"github.com/coreos/mantle/system"
3637
installer "github.com/coreos/mantle/util"
3738
)
3839

@@ -374,7 +375,7 @@ func downloadLatestReleasedRHCOS(target string) (string, error) {
374375
latestBaseUrl := fmt.Sprintf("https://rhcos-redirector.apps.art.xq1c.p1.openshiftapps.com/art/storage/releases/rhcos-%s/%s/%s",
375376
ocpVersionF,
376377
rhcosVersion,
377-
system.RpmArch())
378+
coreosarch.CurrentRpmArch())
378379
latestRhcosBuildMetaUrl := fmt.Sprintf("%s/meta.json", latestBaseUrl)
379380
if err := getJson(latestRhcosBuildMetaUrl, &latestOcpRhcosBuild); err != nil {
380381
return "", err

mantle/platform/api/aws/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ func tagSpecCreatedByMantle(name, resourceType string) []*ec2.TagSpecification {
118118
{
119119
ResourceType: aws.String(resourceType),
120120
Tags: []*ec2.Tag{
121-
&ec2.Tag{
121+
{
122122
Key: aws.String("CreatedBy"),
123123
Value: aws.String("mantle"),
124124
},
125-
&ec2.Tag{
125+
{
126126
Key: aws.String("Name"),
127127
Value: aws.String(name),
128128
},

mantle/platform/api/aws/ec2.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,14 @@ func (a *API) CreateInstances(name, keyname, userdata string, count uint64, minD
149149
UserData: ud,
150150
BlockDeviceMappings: rootBlockDev,
151151
TagSpecifications: []*ec2.TagSpecification{
152-
&ec2.TagSpecification{
152+
{
153153
ResourceType: aws.String(ec2.ResourceTypeInstance),
154154
Tags: []*ec2.Tag{
155-
&ec2.Tag{
155+
{
156156
Key: aws.String("Name"),
157157
Value: aws.String(name),
158158
},
159-
&ec2.Tag{
159+
{
160160
Key: aws.String("CreatedBy"),
161161
Value: aws.String("mantle"),
162162
},
@@ -252,7 +252,7 @@ func (a *API) gcEC2(gracePeriod time.Duration) error {
252252

253253
instances, err := a.ec2.DescribeInstances(&ec2.DescribeInstancesInput{
254254
Filters: []*ec2.Filter{
255-
&ec2.Filter{
255+
{
256256
Name: aws.String("tag:CreatedBy"),
257257
Values: aws.StringSlice([]string{"mantle"}),
258258
},
@@ -357,7 +357,7 @@ func (a *API) GetZonesForInstanceType(instanceType string) ([]string, error) {
357357
input := ec2.DescribeInstanceTypeOfferingsInput{
358358
LocationType: aws.String(ec2.LocationTypeAvailabilityZone),
359359
Filters: []*ec2.Filter{
360-
&ec2.Filter{
360+
{
361361
Name: aws.String("instance-type"),
362362
Values: []*string{aws.String(instanceType)},
363363
},

0 commit comments

Comments
 (0)