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

Set $container_uuid and mount basic /run/host #13217

Closed
wants to merge 1 commit into from

Conversation

jfroy
Copy link

@jfroy jfroy commented Feb 11, 2022

The container_uuid environment variable is read by systemd to set the machine ID, per https://systemd.io/CONTAINER_INTERFACE/#environment-variables. This patch modifies generateSpec to apply this environment variable. The "UUID" is the container ID's first 32 characters.

Fixed #13187

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 11, 2022

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jfroy
To complete the pull request process, please assign flouthoc after the PR has been reviewed.
You can assign the PR to them by writing /assign @flouthoc in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rhatdan
Copy link
Member

rhatdan commented Feb 11, 2022

Thanks @jfroy
One issue on not overriding user input.

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM once the comment is addressed

@mheon
Copy link
Member

mheon commented Feb 14, 2022

LGTM aside from existing comments

@jfroy
Copy link
Author

jfroy commented Feb 14, 2022

Thanks for the feedback, I'll be sending an updated patchset soon.

@jfroy jfroy changed the title Set $container_uuid in systemd mode Set $container_uuid and mount basic /run/host Feb 16, 2022
@jfroy
Copy link
Author

jfroy commented Feb 16, 2022

New patchset is up for review. It includes the feedback for the environment variable and also implements a basic /run/host hierarchy.

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 17, 2022
This patch sets the `container_uuid` environment variable to the
container's fist 32 characters.

This patch also mounts a basic /run/host that contains container-manager
and container-uuid.

See https://systemd.io/CONTAINER_INTERFACE for the details.

Fixed containers#13187

Signed-off-by: Jean-Francois Roy <[email protected]>
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 17, 2022
Comment on lines +376 to +382
if err := c.makeRunHostMount(g); err != nil {
return nil, err
}

if err := c.injectContainerUUID(g); err != nil {
return nil, err
}
Copy link
Member

Choose a reason for hiding this comment

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

I think this should only be added for systemd containers

Copy link
Member

Choose a reason for hiding this comment

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

I probably agree, does machinectl and other tools do anything in the case where systemd is not running within the container.

Copy link
Author

@jfroy jfroy Feb 17, 2022

Choose a reason for hiding this comment

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

The container interface is something coming out of systemd, for sure, but if I set that aside, it is not bad to have basic container information available in the filesystem, in addition to the environment. I'm happy to make this conditional.

Copy link
Member

Choose a reason for hiding this comment

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

We have some container information in /run/.containerenv, but we only leak information their in --privileged mode.

podman run --privileged fedora cat /run/.containerenv
engine="podman-4.0.0-rc4"
name="musing_swartz"
id="fde1c78d6d4cc8a461dc2eb53d6f235946b79e43f812a048b7c79ea5a71df950"
image="registry.fedoraproject.org/fedora:latest"
imageid="e417cd49a84e1749071c516c4f0013ea62113cb5adc98a8504a63a04bfd43479"
rootless=1

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 2, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 2, 2022

@jfroy: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@github-actions
Copy link

github-actions bot commented Apr 2, 2022

A friendly reminder that this PR had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Apr 2, 2022

container_uuid is now set when running in systemd mode, rebase and repush if you want the rest of this PR.

@rhatdan rhatdan closed this Apr 2, 2022
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. stale-pr
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set $container_uuid for systemd containers
5 participants