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

host-ctr: add '/etc/bottlerocket-release' to host containers #1883

Merged
merged 1 commit into from Jan 11, 2022

Conversation

jpculp
Copy link
Member

@jpculp jpculp commented Dec 22, 2021

Description of changes:

This grants host containers context to the underlying OS by mounting
Bottlerocket's /etc/os-release as /etc/bottlerocket-release.

Testing done:

  • Built aws-k8s-1.21 instance.
  • Ran cat /etc/bottlerocket-release in both the control and admin host containers.

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

Comment on lines 698 to 703
// Bottlerocket release information for the container
{
Options: []string{"rbind", "r"},
Destination: fmt.Sprintf("/etc/bottlerocket-release"),
Source: fmt.Sprintf("/etc/os-release"),
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this required if it can be accessed from /.bottlerocket/rootfs/etc/release? Is this mount just for better developer ergonomics?

I couldn't find the r option here, I think the options should be:

Suggested change
// Bottlerocket release information for the container
{
Options: []string{"rbind", "r"},
Destination: fmt.Sprintf("/etc/bottlerocket-release"),
Source: fmt.Sprintf("/etc/os-release"),
},
// Bottlerocket release information for the container
{
Destination: fmt.Sprintf("/etc/bottlerocket-release"),
Source: fmt.Sprintf("/etc/os-release"),
Options: []string{"bind", "ro"}
},

bind: you don't need rbind, since nothing underneath /etc/os-release is mounted
ro: set the mount as read-only

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with @arnaldo2792 - unless we have a need/ask for better ergonomics around this file we probably don't need to add this since it's already available! :)

Copy link
Member Author

Choose a reason for hiding this comment

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

We only mount up /.bottlerocket/rootfs/ on superpowered containers, but this file would be potentially useful on less privileged containers as well. Mounting to /etc/bottlerocket-release is also a bit more user friendly.

I was a little silly with the mounting options though, so I will definitely make that change!

This grants host containers context to the underlying OS by mounting
Bottlerocket's '/etc/os-release' as '/etc/bottlerocket-release'.
@jpculp jpculp force-pushed the br-release-in-host-container branch from cc270dd to 47f22aa Compare January 3, 2022 19:23
@jpculp
Copy link
Member Author

jpculp commented Jan 3, 2022

Fixed mount options.

// Bottlerocket release information for the container
{
Options: []string{"bind", "ro"},
Destination: fmt.Sprintf("/etc/bottlerocket-release"),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I do like the simplicity of just having /etc instead of /.bottlerocket/bottlerocket-release, but I still think we should have the prefix just to be consistent with the container's persistent storage mount: /.bottlerocket/<host-containers>/<bootstrap-containers>/

Copy link
Contributor

Choose a reason for hiding this comment

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

I went back and forth on this as well. As a general rule, we try to be hands-off with the container's root filesystem, but we've bent that rule to put things in the "expected" places - apiclient in /usr/local/bin, and the API socket in /run.

Having the release file in /etc seems like a reasonable exception by that standard. And if we're touching /etc in any case, making it a symlink to /.bottlerocket/<blah>/etc just seems overly complicated.

Copy link
Contributor

@zmrow zmrow left a comment

Choose a reason for hiding this comment

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

🐙

@jpculp jpculp merged commit 545380f into bottlerocket-os:develop Jan 11, 2022
@jpculp jpculp deleted the br-release-in-host-container branch January 11, 2022 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants