Skip to content

Commit

Permalink
Merge pull request coreos#1165 from cgwalters/kola-parse-build
Browse files Browse the repository at this point in the history
kola: Add a --cosa-build argument
  • Loading branch information
Stephen Lowrie committed Jan 16, 2020
2 parents 7997129 + b955bcf commit b88c369
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 14 deletions.
45 changes: 31 additions & 14 deletions cmd/kola/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,26 @@
package main

import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"strings"

"github.com/coreos/mantle/auth"
"github.com/coreos/mantle/cosa"
"github.com/coreos/mantle/kola"
"github.com/coreos/mantle/platform"
"github.com/coreos/mantle/sdk"
)

var (
outputDir string
kolaPlatform string
defaultTargetBoard = sdk.DefaultBoard()
kolaArchitectures = []string{"amd64"}
kolaPlatforms = []string{"aws", "azure", "do", "esx", "gce", "openstack", "packet", "qemu", "qemu-unpriv"}
kolaDistros = []string{"fcos", "rhcos"}
kolaDefaultImages = map[string]string{
"amd64-usr": sdk.BuildRoot() + "/images/amd64-usr/latest/coreos_production_image.bin",
"arm64-usr": sdk.BuildRoot() + "/images/arm64-usr/latest/coreos_production_image.bin",
}
outputDir string
kolaPlatform string
defaultTargetBoard = sdk.DefaultBoard()
kolaArchitectures = []string{"amd64"}
kolaPlatforms = []string{"aws", "azure", "do", "esx", "gce", "openstack", "packet", "qemu", "qemu-unpriv"}
kolaDistros = []string{"fcos", "rhcos"}
kolaIgnitionVersionDefaults = map[string]string{
"cl": "v2",
"fcos": "v3",
Expand All @@ -62,6 +61,7 @@ func init() {
sv(&kola.Options.IgnitionVersion, "ignition-version", "", "Ignition version override: v2, v3")
ssv(&kola.BlacklistedTests, "blacklist-test", []string{}, "List of tests to blacklist")
bv(&kola.Options.SSHOnTestFailure, "ssh-on-test-failure", false, "SSH into a machine when tests fail")
sv(&kola.Options.CosaBuild, "cosa-build", "", "File path for coreos-assembler meta.json")
// rhcos-specific options
sv(&kola.Options.OSContainer, "oscontainer", "", "oscontainer image pullspec for pivot (RHCOS only)")

Expand Down Expand Up @@ -171,13 +171,29 @@ func syncOptions() error {
return err
}

image, ok := kolaDefaultImages[kola.QEMUOptions.Board]
if kola.QEMUOptions.Distribution == "cl" && !ok {
return fmt.Errorf("unsupport board %q", kola.QEMUOptions.Board)
var cosaBuild *cosa.Build
if kola.Options.CosaBuild != "" {
f, err := os.Open(kola.Options.CosaBuild)
if err != nil {
return err
}
defer f.Close()
dec := json.NewDecoder(f)
// FIXME enable this to prevent schema regressions https://github.com/coreos/coreos-assembler/pull/1059
// dec.DisallowUnknownFields()
var tmpBuild cosa.Build
if err := dec.Decode(&tmpBuild); err != nil {
return err
}
cosaBuild = &tmpBuild
}

if kola.QEMUOptions.DiskImage == "" {
kola.QEMUOptions.DiskImage = image
if cosaBuild != nil {
kola.QEMUOptions.DiskImage = filepath.Join(filepath.Dir(kola.Options.CosaBuild), cosaBuild.Images.QEMU.Path)
} else {
return fmt.Errorf("No --qemu-image or --cosa-build provided")
}
}

units, _ := root.PersistentFlags().GetStringSlice("debug-systemd-units")
Expand All @@ -194,6 +210,7 @@ func syncOptions() error {
}

if kola.Options.IgnitionVersion == "" {
var ok bool
kola.Options.IgnitionVersion, ok = kolaIgnitionVersionDefaults[kola.Options.Distribution]
if !ok {
return fmt.Errorf("Distribution %q has no default Ignition version", kola.Options.Distribution)
Expand Down
47 changes: 47 additions & 0 deletions cosa/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2020 Red Hat, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cosa

// Build is the coreos-assembler `meta.json` which defines a build.
// This code was copied from openshift-installer's
// https://github.com/openshift/installer/blob/a0350404997b0493d7bb16aa2875e5c42879b069/pkg/rhcos/builds.go
// For now, copy-paste updates there. Later, maybe consider making this a public API?
type Build struct {
AMIs map[string]struct {
HVM string `json:"hvm"`
} `json:"amis"`
Azure struct {
Image string `json:"image"`
URL string `json:"url"`
}
GCP struct {
Image string `json:"image"`
URL string `json:"url"`
}
BaseURI string `json:"baseURI"`
Images struct {
QEMU struct {
Path string `json:"path"`
SHA256 string `json:"sha256"`
UncompressedSHA256 string `json:"uncompressed-sha256"`
} `json:"qemu"`
OpenStack struct {
Path string `json:"path"`
SHA256 string `json:"sha256"`
UncompressedSHA256 string `json:"uncompressed-sha256"`
} `json:"openstack"`
} `json:"images"`
OSTreeVersion string `json:"ostree-version"`
}
2 changes: 2 additions & 0 deletions platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ type Options struct {
IgnitionVersion string
SystemdDropins []SystemdDropin

CosaBuild string

NoTestExitError bool

// OSContainer is an image pull spec that can be given to the pivot service
Expand Down

0 comments on commit b88c369

Please sign in to comment.