-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: create rootfs for system services via /system tmpfs
Container rootfs should be writeable as containerd mounts standard filesystems `/proc` et al. When `/opt` was used as a root of container filesystem this results in a problem: Talos overlay mounts `/opt` on `/var/system` which means that as long as `apid` running `/var` can't be unmounted which breaks upgrades. So instead use `/system/libexec` as rootfs for the containers, `/system` is `tmpfs`, and bind-mount actually executable (`/sbin/init`, machined) into rootfs. This fixes upgrades for 0.10. See also #3425 Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
- Loading branch information
Showing
5 changed files
with
45 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
package services | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
|
||
"golang.org/x/sys/unix" | ||
|
||
"github.com/talos-systems/talos/pkg/machinery/constants" | ||
) | ||
|
||
// prepareRootfs creates /system/libexec/<service> rootfs and bind-mounts /sbin/init there. | ||
func prepareRootfs(id string) error { | ||
rootfsPath := filepath.Join(constants.SystemLibexecPath, id) | ||
|
||
if err := os.MkdirAll(rootfsPath, 0o700); err != nil { | ||
return fmt.Errorf("failed to create rootfs %q: %w", rootfsPath, err) | ||
} | ||
|
||
executablePath := filepath.Join(rootfsPath, id) | ||
|
||
if err := ioutil.WriteFile(executablePath, nil, 0o500); err != nil { | ||
return fmt.Errorf("failed to create empty executable %q: %w", executablePath, err) | ||
} | ||
|
||
if err := unix.Mount("/sbin/init", executablePath, "", unix.MS_BIND, ""); err != nil { | ||
return fmt.Errorf("failed to create bind mount for %q: %w", executablePath, err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters