mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-04-27 19:28:59 +00:00
gear: Be sure to run datasource before install
Seems in certain condition the datasource is kicking late and serving the datasource not fast as wanted. We make sure to pull it before install, so we also give chance to convoluted setups to pull configs. Also wires up autoinstall tests to CI
This commit is contained in:
parent
6c08ac78a8
commit
09b41735f4
@ -65,6 +65,13 @@ func Install(dir ...string) error {
|
||||
}
|
||||
})
|
||||
|
||||
// Try to pull userdata once more. best-effort
|
||||
if _, err := os.Stat("/oem/userdata"); err != nil {
|
||||
if err := machine.ExecuteCloudConfig("/system/oem/00_datasource.yaml", "rootfs.before"); err != nil {
|
||||
fmt.Println("Warning: Failed pulling from datasources")
|
||||
}
|
||||
}
|
||||
|
||||
// Reads config, and if present and offline is defined,
|
||||
// runs the installation
|
||||
cc, err := config.Scan(config.Directories(dir...), config.MergeBootLine)
|
||||
|
@ -145,3 +145,13 @@ func SentinelExist(f string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func ExecuteInlineCloudConfig(cloudConfig, stage string) error {
|
||||
_, err := utils.ShellSTDIN(cloudConfig, fmt.Sprintf("elemental run-stage -s %s -", stage))
|
||||
return err
|
||||
}
|
||||
|
||||
func ExecuteCloudConfig(file, stage string) error {
|
||||
_, err := utils.SH(fmt.Sprintf("elemental run-stage -s %s %s", stage, file))
|
||||
return err
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
@ -31,3 +32,12 @@ func Shell() *exec.Cmd {
|
||||
cmd.Stdin = os.Stdin
|
||||
return cmd
|
||||
}
|
||||
|
||||
func ShellSTDIN(s, c string) (string, error) {
|
||||
cmd := exec.Command("/bin/sh", "-c", c)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdin = bytes.NewBuffer([]byte(s))
|
||||
o, err := cmd.CombinedOutput()
|
||||
return string(o), err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user