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 agent changes #564

Merged
merged 19 commits into from
Jun 7, 2022
Prev Previous commit
Next Next commit
host agent changes
khannakshat7 committed May 26, 2022
commit 875f23ed3eaec6a5e65f059cb8d5a2f7303e9e90
13 changes: 8 additions & 5 deletions agent/reconciler/host_reconciler.go
Original file line number Diff line number Diff line change
@@ -104,10 +104,10 @@ func (r *HostReconciler) reconcileNormal(ctx context.Context, byoHost *infrastru
return ctrl.Result{}, nil
}

if r.UseInstallerController {
if r.UseInstallerController && !conditions.IsTrue(byoHost, infrastructurev1beta1.K8sComponentsInstallationSucceeded) {
khannakshat7 marked this conversation as resolved.
Show resolved Hide resolved
if byoHost.Spec.InstallationSecret == nil {
logger.Info("InstallationSecret not ready")
conditions.MarkFalse(byoHost, infrastructurev1beta1.K8sNodeBootstrapSucceeded, infrastructurev1beta1.K8sInstallationSecretUnavailableReason, clusterv1.ConditionSeverityInfo, "")
conditions.MarkFalse(byoHost, infrastructurev1beta1.K8sComponentsInstallationSucceeded, infrastructurev1beta1.K8sInstallationSecretUnavailableReason, clusterv1.ConditionSeverityInfo, "")
return ctrl.Result{}, nil
}
installScript, _, err := r.getInstallationScript(ctx, byoHost.Spec.InstallationSecret.Name, byoHost.Spec.InstallationSecret.Namespace)
@@ -124,6 +124,7 @@ func (r *HostReconciler) reconcileNormal(ctx context.Context, byoHost *infrastru
logger.Error(err, "error execting installation script")
return ctrl.Result{}, err
}
conditions.MarkTrue(byoHost, infrastructurev1beta1.K8sComponentsInstallationSucceeded)
}

if byoHost.Spec.BootstrapSecret == nil {
@@ -275,9 +276,7 @@ func (r *HostReconciler) hostCleanUp(ctx context.Context, byoHost *infrastructur
if err != nil {
return err
}
if r.SkipK8sInstallation {
logger.Info("Skipping uninstallation of k8s components")
} else if r.UseInstallerController {
if r.UseInstallerController {
_, uninstallScript, err := r.getInstallationScript(ctx, byoHost.Spec.InstallationSecret.Name, byoHost.Spec.InstallationSecret.Namespace)
if err != nil {
logger.Error(err, "error getting Uninstallation script")
@@ -293,6 +292,8 @@ func (r *HostReconciler) hostCleanUp(ctx context.Context, byoHost *infrastructur
logger.Error(err, "error execting Uninstallation script")
return err
}
} else if r.SkipK8sInstallation {
khannakshat7 marked this conversation as resolved.
Show resolved Hide resolved
logger.Info("Skipping uninstallation of k8s components")
} else {
err = r.uninstallk8sComponents(ctx, byoHost)
if err != nil {
@@ -314,6 +315,8 @@ func (r *HostReconciler) hostCleanUp(ctx context.Context, byoHost *infrastructur
return err
}

byoHost.Spec.InstallationSecret = nil

r.removeAnnotations(ctx, byoHost)
conditions.MarkFalse(byoHost, infrastructurev1beta1.K8sNodeBootstrapSucceeded, infrastructurev1beta1.K8sNodeAbsentReason, clusterv1.ConditionSeverityInfo, "")
return nil
19 changes: 15 additions & 4 deletions common/installer/internal/algo/ubuntu20_4k8s.go
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ func (s *Ubuntu20_04Installer) Uninstall() string {
// contains the installation and uninstallation steps for the supported os and k8s
var (
DoUbuntu20_4K8s1_22 = `
set -euo pipefail
set -euox pipefail

BUNDLE_DOWNLOAD_PATH={{.BundleDownloadPath}}
BUNDLE_ADDR={{.BundleAddrs}}
@@ -77,8 +77,19 @@ BUNDLE_PATH=$BUNDLE_DOWNLOAD_PATH/$BUNDLE_ADDR


if ! command -v imgpkg >>/dev/null; then
echo "installing imgpkg"
wget -nv -O- github.com/vmware-tanzu/carvel-imgpkg/releases/download/$IMGPKG_VERSION/imgpkg-linux-$ARCH > /tmp/imgpkg
echo "installing imgpkg"

if command -v wget >>/dev/null; then
dl_bin="wget -nv -O-"
elif command -v curl >>/dev/null; then
dl_bin="curl -s -L"
else
echo "installing curl"
apt-get install -y curl
dl_bin="curl -s -L"
fi

$dl_bin github.com/vmware-tanzu/carvel-imgpkg/releases/download/$IMGPKG_VERSION/imgpkg-linux-$ARCH > /tmp/imgpkg
mv /tmp/imgpkg /usr/local/bin/imgpkg
chmod +x /usr/local/bin/imgpkg
fi
@@ -114,7 +125,7 @@ tar -C / -xvf "$BUNDLE_PATH/containerd.tar"
systemctl daemon-reload && systemctl enable containerd && systemctl start containerd`

UndoUbuntu20_4K8s1_22 = `
set -euo pipefail
set -euox pipefail

BUNDLE_DOWNLOAD_PATH={{.BundleDownloadPath}}
BUNDLE_ADDR={{.BundleAddrs}}