Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions mantle/cmd/kola/qemuexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"fmt"
"io/ioutil"
"os/exec"
"path/filepath"
"strings"

Expand Down Expand Up @@ -117,7 +116,6 @@ func parseBindOpt(s string) (string, string, error) {

func runQemuExec(cmd *cobra.Command, args []string) error {
var err error
var config *conf.Conf

/// Qemu allows passing disk images directly, but this bypasses all of our snapshot
/// infrastructure and it's too easy to accidentally do `cosa run foo.qcow2` instead of
Expand Down Expand Up @@ -199,21 +197,17 @@ func runQemuExec(cmd *cobra.Command, args []string) error {
builder := platform.NewQemuBuilder()
defer builder.Close()

var config *conf.Conf
if butane != "" {
tmpf, err := builder.TempFile("ignition")
buf, err := ioutil.ReadFile(butane)
if err != nil {
return err
}
defer tmpf.Close()
cmd := exec.Command("fcct", butane)
cmd.Stdout = tmpf
if err = cmd.Run(); err != nil {
return err
config, err = conf.Butane(string(buf)).Render()
if err != nil {
return errors.Wrapf(err, "parsing %s", butane)
}
ignition = tmpf.Name()
}

if !directIgnition && ignition != "" {
} else if !directIgnition && ignition != "" {
buf, err := ioutil.ReadFile(ignition)
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion mantle/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190929091402-5711055976b5
github.com/aliyun/aliyun-oss-go-sdk v2.0.3+incompatible
github.com/aws/aws-sdk-go v1.34.28
github.com/coreos/butane v0.12.1
github.com/coreos/go-semver v0.3.0
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
github.com/coreos/go-systemd/v22 v22.0.0
Expand All @@ -32,7 +33,7 @@ require (
github.com/pin/tftp v2.1.0+incompatible
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v0.0.6
github.com/spf13/pflag v1.0.3
github.com/spf13/pflag v1.0.5
github.com/ulikunitz/xz v0.5.4
github.com/vincent-petithory/dataurl v0.0.0-20191104211930-d1553a71de50
github.com/vishvananda/netlink v0.0.0-20150710184826-9cff81214893
Expand Down
77 changes: 18 additions & 59 deletions mantle/go.sum

Large diffs are not rendered by default.

19 changes: 9 additions & 10 deletions mantle/kola/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
Expand Down Expand Up @@ -595,8 +594,8 @@ func runExternalTest(c cluster.TestCluster, mach platform.Machine) error {
}
}

func registerExternalTest(testname, executable, dependencydir, ignition string, baseMeta externalTestMeta) error {
config, err := conf.Ignition(ignition).Render()
func registerExternalTest(testname, executable, dependencydir string, userdata *conf.UserData, baseMeta externalTestMeta) error {
config, err := userdata.Render()
if err != nil {
return errors.Wrapf(err, "Parsing config.ign")
}
Expand Down Expand Up @@ -712,7 +711,7 @@ func registerTestDir(dir, testprefix string, children []os.FileInfo) error {
var dependencydir string
var meta externalTestMeta
var err error
ignition := `{ "ignition": { "version": "3.0.0" } }`
userdata := conf.EmptyIgnition()
executables := []string{}
for _, c := range children {
fpath := filepath.Join(dir, c.Name())
Expand All @@ -731,13 +730,13 @@ func registerTestDir(dir, testprefix string, children []os.FileInfo) error {
if err != nil {
return errors.Wrapf(err, "reading %s", c.Name())
}
ignition = string(v)
} else if isreg && c.Name() == "config.fcc" {
b, err := exec.Command("fcct", fpath).Output()
userdata = conf.Ignition(string(v))
} else if isreg && (c.Name() == "config.bu" || c.Name() == "config.fcc") {
v, err := ioutil.ReadFile(filepath.Join(dir, c.Name()))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's less exact but technically we could always group the Ignition & Butane/FCCT sections together and use conf.Unknown's detection logic no? Could maybe even loosen it to config* as the qualifier for a config object if we go that route.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought about that. Since we already have separate command-line options to distinguish the config types, I'm inclined to keep using those, rather than combining them and expecting the code to guess.

if err != nil {
return errors.Wrapf(err, "failed to fcct %s", fpath)
return errors.Wrapf(err, "reading %s", c.Name())
}
ignition = string(b)
userdata = conf.Butane(string(v))
} else if isreg && c.Name() == "kola.json" {
f, err := os.Open(fpath)
if err != nil {
Expand Down Expand Up @@ -795,7 +794,7 @@ func registerTestDir(dir, testprefix string, children []os.FileInfo) error {
continue
}

err := registerExternalTest(testname, executable, dependencydir, ignition, meta)
err := registerExternalTest(testname, executable, dependencydir, userdata, meta)
if err != nil {
return err
}
Expand Down
16 changes: 12 additions & 4 deletions mantle/kola/tests/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ func init() {
Name: "docker.userns",
Distros: []string{"cl"},
// TODO: Update for Fedora CoreOS
UserData: conf.Ignition(`
UserData: conf.Butane(`
variant: fcos
version: 1.3.0
systemd:
units:
- name: docker.service
Expand Down Expand Up @@ -127,7 +129,9 @@ passwd:
Name: "docker.btrfs-storage",
// Note: copied verbatim from https://github.com/coreos/docs/blob/master/os/mounting-storage.md#creating-and-mounting-a-btrfs-volume-file
// TODO: Update for Fedora CoreOS
UserData: conf.Ignition(`
UserData: conf.Butane(`
variant: fcos
version: 1.3.0
systemd:
units:
- name: format-var-lib-docker.service
Expand Down Expand Up @@ -169,7 +173,9 @@ systemd:
ClusterSize: 1,
Distros: []string{"cl"},
// TODO: Update for Fedora CoreOS
UserData: conf.Ignition(`
UserData: conf.Butane(`
variant: fcos
version: 1.3.0
systemd:
units:
- name: docker.service
Expand Down Expand Up @@ -211,7 +217,9 @@ systemd:
ClusterSize: 1,
Distros: []string{"cl"},
// TODO: Update for Fedora CoreOS
UserData: conf.Ignition(`
UserData: conf.Butane(`
variant: fcos
version: 1.3.0
systemd:
units:
- name: docker.service
Expand Down
Loading