-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VAULT-27917] fix(enos): handle SLES guestregister.service unreliabil…
…ity (#27380) * [VAULT-27917] fix(enos): handle SLES guestregister.service unreliability The SLES provided `guestregister.service` systemd unit is unreliable enough that it will fail ~ 1/9 times when provisioning SLES instances. When this happens the machine will never successfully exec SUSEConnect to enroll and we'll get no access to the SLES repositories and subsequently break our scenarios. I resolved this by restructuring our `install_packages` module to to separate repository synchronization, repository addition, and package installation into different scripts and resources and by adding special case handling for SLES and the `guestregister.service`. I also make a distinction between `dnf` and `yum` because while they are sort of the same thing on RHEL, it is not the case with Amazon2. I also shimmed out the rest of the support for Apt in case we ever need to add repos there. * Revert "Temporarily remove SLES from samples (#27378)" This reverts commit 490cdd9. Signed-off-by: Ryan Cragun <[email protected]>
- Loading branch information
1 parent
fa7fa61
commit a164b8c
Showing
5 changed files
with
279 additions
and
88 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
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,83 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
|
||
set -e | ||
|
||
fail() { | ||
echo "$1" 1>&2 | ||
exit 1 | ||
} | ||
|
||
[[ -z "${PACKAGE_MANAGER}" ]] && fail "PACKAGE_MANAGER env variable has not been set" | ||
[[ -z "${RETRY_INTERVAL}" ]] && fail "RETRY_INTERVAL env variable has not been set" | ||
[[ -z "${TIMEOUT_SECONDS}" ]] && fail "TIMEOUT_SECONDS env variable has not been set" | ||
|
||
# Add any repositories that have have been passed in | ||
add_repos() { | ||
# If we don't have any repos on the list for this distro, no action needed. | ||
if [ ${#DISTRO_REPOS[@]} -lt 1 ]; then | ||
echo "DISTRO_REPOS is empty; No repos required for the packages for this Linux distro." | ||
return 0 | ||
fi | ||
|
||
case $PACKAGE_MANAGER in | ||
apt) | ||
# NOTE: We do not currently add any apt repositories in our scenarios. I suspect if that time | ||
# comes we'll need to add support for apt-key here. | ||
for repo in ${DISTRO_REPOS}; do | ||
if [ "$repo" == "__none" ]; then | ||
continue | ||
fi | ||
sudo add-apt-repository "${repo}" | ||
done | ||
;; | ||
dnf) | ||
for repo in ${DISTRO_REPOS}; do | ||
if [ "$repo" == "__none" ]; then | ||
continue | ||
fi | ||
sudo dnf install -y "${repo}" | ||
sudo dnf makecache -y | ||
done | ||
;; | ||
yum) | ||
for repo in ${DISTRO_REPOS}; do | ||
if [ "$repo" == "__none" ]; then | ||
continue | ||
fi | ||
sudo yum install -y "${repo}" | ||
sudo yum makecache -y | ||
done | ||
;; | ||
zypper) | ||
# Add each repo | ||
for repo in ${DISTRO_REPOS}; do | ||
if [ "$repo" == "__none" ]; then | ||
continue | ||
fi | ||
if sudo zypper lr "${repo}"; then | ||
echo "A repo named ${repo} already exists, skipping..." | ||
continue | ||
fi | ||
sudo zypper --gpg-auto-import-keys --non-interactive addrepo "${repo}" | ||
done | ||
sudo zypper --gpg-auto-import-keys ref | ||
sudo zypper --gpg-auto-import-keys refs | ||
;; | ||
*) | ||
fail "Unsupported package manager: ${PACKAGE_MANAGER}" | ||
esac | ||
} | ||
|
||
begin_time=$(date +%s) | ||
end_time=$((begin_time + TIMEOUT_SECONDS)) | ||
while [ "$(date +%s)" -lt "$end_time" ]; do | ||
if add_repos; then | ||
exit 0 | ||
fi | ||
|
||
sleep "$RETRY_INTERVAL" | ||
done | ||
|
||
fail "Timed out waiting for distro repos to be set up" |
57 changes: 0 additions & 57 deletions
57
enos/modules/install_packages/scripts/distro-repo-setup.sh
This file was deleted.
Oops, something went wrong.
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.