-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add systemd unit for Mariner live patching (#4088)
- Loading branch information
Showing
892 changed files
with
1,315 additions
and
1,394 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
56 changes: 56 additions & 0 deletions
56
parts/linux/cloud-init/artifacts/mariner/mariner-package-update.sh
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,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o nounset | ||
set -e | ||
|
||
# source dnf_update | ||
source /opt/azure/containers/provision_source_distro.sh | ||
|
||
KUBECTL="/usr/local/bin/kubectl --kubeconfig /var/lib/kubelet/kubeconfig" | ||
|
||
# At startup, we need to wait for kubelet to finish TLS bootstrapping to create the kubeconfig file. | ||
n=0 | ||
while [ ! -f /var/lib/kubelet/kubeconfig ]; do | ||
echo 'Waiting for TLS bootstrapping' | ||
if [[ $n -lt 100 ]]; then | ||
n=$((n+1)) | ||
sleep 3 | ||
else | ||
echo "timeout waiting for kubeconfig to be present" | ||
exit 1 | ||
fi | ||
done | ||
|
||
node_name=$(hostname) | ||
if [ -z "${node_name}" ]; then | ||
echo "cannot get node name" | ||
exit 1 | ||
fi | ||
|
||
# retrieve golden timestamp from node annotation | ||
golden_timestamp=$($KUBECTL get node ${node_name} -o jsonpath="{.metadata.annotations['kubernetes\.azure\.com/live-patching-golden-timestamp']}") | ||
if [ -z "${golden_timestamp}" ]; then | ||
echo "golden timestamp is not set, skip live patching" | ||
exit 0 | ||
fi | ||
echo "golden timestamp is: ${golden_timestamp}" | ||
|
||
current_timestamp=$($KUBECTL get node ${node_name} -o jsonpath="{.metadata.annotations['kubernetes\.azure\.com/live-patching-current-timestamp']}") | ||
if [ -n "${current_timestamp}" ]; then | ||
echo "current timestamp is: ${current_timestamp}" | ||
|
||
if [[ "${golden_timestamp}" == "${current_timestamp}" ]]; then | ||
echo "golden and current timestamp is the same, nothing to patch" | ||
exit 0 | ||
fi | ||
fi | ||
|
||
if ! dnf_update; then | ||
echo "dnf_update failed" | ||
exit 1 | ||
fi | ||
|
||
# update current timestamp | ||
$KUBECTL annotate --overwrite node ${node_name} kubernetes.azure.com/live-patching-current-timestamp=${golden_timestamp} | ||
|
||
echo "package update completed successfully" |
6 changes: 6 additions & 0 deletions
6
parts/linux/cloud-init/artifacts/mariner/package-update.service
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,6 @@ | ||
[Unit] | ||
Description=Package Update Service | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/opt/azure/containers/mariner-package-update.sh |
2 changes: 1 addition & 1 deletion
2
...t/testdata/CustomizedImageKata/line135.sh → ...it/artifacts/mariner/package-update.timer
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.