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
20 changes: 19 additions & 1 deletion pkg/daemon/rpm-ostree.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -420,10 +421,27 @@ func useKubeletConfigSecrets() error {
return err
}

err = os.Symlink(kubeletAuthFile, "/run/ostree/auth.json")
runningos, err := GetHostRunningOS()
if err != nil {
return err
}

// Short term workaround for https://issues.redhat.com/browse/OKD-63
if runningos.IsFCOS() {
contents, err := ioutil.ReadFile(kubeletAuthFile)
if err != nil {
return err
}
// Note 0644 perms for now
if err := ioutil.WriteFile("/run/ostree/auth.json", contents, 0o644); err != nil {
return err
}
} else {
err = os.Symlink(kubeletAuthFile, "/run/ostree/auth.json")
if err != nil {
return err
}
}
}
}
return nil
Expand Down
39 changes: 38 additions & 1 deletion pkg/daemon/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,44 @@ func (dn *Daemon) updateOS(config *mcfgv1.MachineConfig, osImageContentDir strin
// via a privileged container. This is needed on firstboot of old
// nodes as well as temporarily for 4.11 -> 4.12 upgrades.
func (dn *Daemon) InplaceUpdateViaNewContainer(target string) error {
return runCmdSync("systemd-run", "--unit", "machine-config-daemon-update-rpmostree-via-container", "--collect", "--wait", "--", "podman", "run", "--authfile", "/var/lib/kubelet/config.json", "--privileged", "--pid=host", "--net=host", "--rm", "-v", "/:/run/host", target, "rpm-ostree", "ex", "deploy-from-self", "/run/host")
// HACK: Disable selinux enforcement for this because it's not
// really easily possible to get the correct install_t context
// here when run from a container image.
// xref https://issues.redhat.com/browse/MCO-396
enforceFile := "/sys/fs/selinux/enforce"
enforcingBuf, err := ioutil.ReadFile(enforceFile)
var enforcing bool
if err != nil {
if os.IsNotExist(err) {
enforcing = false
} else {
return fmt.Errorf("failed to read %s: %w", enforceFile, err)
}
} else {
enforcingStr := string(enforcingBuf)
v, err := strconv.Atoi(strings.TrimSpace(enforcingStr))
if err != nil {
return fmt.Errorf("failed to parse selinux enforcing %v: %w", enforcingBuf, err)
}
enforcing = (v == 1)
}
if enforcing {
if err := runCmdSync("setenforce", "0"); err != nil {
return err
}
} else {
glog.Info("SELinux is not enforcing")
}
err = runCmdSync("systemd-run", "--unit", "machine-config-daemon-update-rpmostree-via-container", "--collect", "--wait", "--", "podman", "run", "--authfile", "/var/lib/kubelet/config.json", "--privileged", "--pid=host", "--net=host", "--rm", "-v", "/:/run/host", target, "rpm-ostree", "ex", "deploy-from-self", "/run/host")
if err != nil {
return err
}
if enforcing {
if err := runCmdSync("setenforce", "1"); err != nil {
return err
}
}
return nil
}

// updateLayeredOS updates the system OS to the one specified in newConfig
Expand Down