Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tmpfiles: Ensure that /etc/coreos to flatcar symlink exists #7

Merged
merged 1 commit into from
Oct 13, 2020

Conversation

pothos
Copy link
Member

@pothos pothos commented Oct 13, 2020

The entries from the update or locksmith directive of a Container Linux
Config currently use the /etc/coreos/ folder for Ignition files:
printf "locksmith:\n reboot_strategy: off" | ct
results in:
{"ignition":{"config":{},"security":{"tls":{}},"timeouts":{},
"version":"2.3.0"},"networkd":{},"passwd":{},"storage":
{"files":[{"filesystem":"root", "path":"/etc/coreos/update.conf",
"contents":{"source":"data:,%0AREBOOT_STRATEGY%3D%22off%22",
"verification":{}},"mode":420}]},"systemd":{}}
With the pre-built rootfs this works because /etc/coreos is a symlink
to /etc/flatcar. However, with a fresh rootfs created by Ignition this
results in a /etc/coreos folder created by Ignition because there is no
symlink and the resulting files are ignored since only /etc/flatcar/ is
considered by update-engine and locksmith.
Set up the symlink and the target folder through a tmpfile directive to
ensure that it is there when Ignition runs even when with a new rootfs.

Fixes flatcar/Flatcar#190

How to use

Goes together with flatcar/init#28

Using an Ignition config like

{
  "ignition": {
    "version": "2.2.0"
  },
  "storage": {
    "filesystems": [
      {
        "mount": {
          "device": "/dev/disk/by-partlabel/ROOT",
          "format": "ext4",
          "create": {
            "force": true,
            "options": [
              "-L",
              "ROOT",
              "-U",
              "9aa5237a-ab6b-458b-a7e8-f25e2baef1a3"
            ]
          }
        }
      }
    ],
    "files": [
      {
        "filesystem": "root",
        "path": "/etc/coreos/update.conf",
        "contents": {
          "source": "data:,%0AREBOOT_STRATEGY%3D%22off%22",
          "verification": {}
        },
        "mode": 420
      }
    ]
  }
}

should result in /etc/flatcar/update.conf having REBOOT_STRATEGY="off".

Testing done

With the new image that also contains the change from flatcar/init#28 I was able to use the above Ignition config successfully, meaning that the symlink was set up and the update.conf file was created under the flatcar folder.

The entries from the update or locksmith directive of a Container Linux
Config currently use the /etc/coreos/ folder for Ignition files:
  printf "locksmith:\n  reboot_strategy: off" | ct
results in:
  {"ignition":{"config":{},"security":{"tls":{}},"timeouts":{},
  "version":"2.3.0"},"networkd":{},"passwd":{},"storage":
  {"files":[{"filesystem":"root", "path":"/etc/coreos/update.conf",
  "contents":{"source":"data:,%0AREBOOT_STRATEGY%3D%22off%22",
  "verification":{}},"mode":420}]},"systemd":{}}
With the pre-built rootfs this works because /etc/coreos is a symlink
to /etc/flatcar. However, with a fresh rootfs created by Ignition this
results in a /etc/coreos folder created by Ignition because there is no
symlink and the resulting files are ignored since only /etc/flatcar/ is
considered by update-engine and locksmith.
Set up the symlink and the target folder through a tmpfile directive to
ensure that it is there when Ignition runs even when with a new rootfs.

Fixes flatcar/Flatcar#190
@pothos pothos requested a review from a team October 13, 2020 08:44
Copy link

@margamanterola margamanterola left a comment

Choose a reason for hiding this comment

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

LGTM

@pothos
Copy link
Member Author

pothos commented Oct 13, 2020

I will include it in all maintenance branches.

@pothos pothos merged commit 84e618b into flatcar-master Oct 13, 2020
@pothos pothos deleted the kai/ensure-symlink-for-ct branch October 13, 2020 14:04
pothos added a commit to flatcar-archive/coreos-overlay that referenced this pull request Oct 13, 2020
This pulls in
flatcar/init#28 and
flatcar/baselayout#7
to ensure that the /etc/coreos to /etc/flatcar symlink always exists.

Fixes flatcar/Flatcar#190
pothos added a commit to flatcar-archive/coreos-overlay that referenced this pull request Oct 13, 2020
This pulls in
flatcar/init#28 and
flatcar/baselayout#7
to ensure that the /etc/coreos to /etc/flatcar symlink always exists.

Fixes flatcar/Flatcar#190
pothos added a commit to flatcar-archive/coreos-overlay that referenced this pull request Oct 13, 2020
This pulls in
flatcar/init#28 and
flatcar/baselayout#7
to ensure that the /etc/coreos to /etc/flatcar symlink always exists.

Fixes flatcar/Flatcar#190
pothos added a commit to flatcar-archive/coreos-overlay that referenced this pull request Oct 13, 2020
This pulls in
flatcar/init#28 and
flatcar/baselayout#7
to ensure that the /etc/coreos to /etc/flatcar symlink always exists.

Fixes flatcar/Flatcar#190
pothos added a commit to flatcar-archive/coreos-overlay that referenced this pull request Oct 19, 2020
This pulls in
flatcar/init#28 and
flatcar/baselayout#7
to ensure that the /etc/coreos to /etc/flatcar symlink always exists.

Fixes flatcar/Flatcar#190
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants