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

kubevirt: Set transient hostname from metadata #4005

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: afterburn-transient-hostname.service
enabled: true
contents: |
[Unit]
Description=Set Transient Hostname from KubeVirt meta_data
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this have

ConditionPathExists=!/etc/hostname

?

We don't want to set a hostname if one has already been set (e.g. via Ignition).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well not sure, it depends on what the we want do at the end, maybe we want to convert the static into transient hostname.


# Run afterburn service for collect info from metadata server
# see: https://coreos.github.io/afterburn/usage/attributes/
Wants=afterburn.service
After=afterburn.service

# Before hostname is received from DHCP
Before=network-pre.target
Wants=network-pre.target

# Run before kubelet
Before=kubelet.service

[Service]
# Mark afterburn environment file optional, due to it is possible that afterburn service was not executed
EnvironmentFile=/run/metadata/afterburn
Copy link
Member

Choose a reason for hiding this comment

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

The comment says to mark as optional, but this is missing the optional marker.

Also if it's truly missing, then we'd be setting the transient hostname to the empty string, which is not what we want. Likely instead we should add ConditionPathExists=/run/metadata/afterburn to the unit?

ExecStart=hostnamectl hostname --transient "${AFTERBURN_KUBEVIRT_HOSTNAME}"
Type=oneshot

[Install]
WantedBy=network-online.target