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

OCPBUGS-22477: Remove z-upgrades from UpgradeBackupController #1140

Merged
merged 1 commit into from Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions bindata/etcd/cluster-backup-pod.yaml
Expand Up @@ -34,6 +34,12 @@ spec:
- |
#!/bin/sh
set -exuo pipefail

if [ -n "${DELETE_BACKUP_DIR}" ]; then
echo "removing all backups in ${DELETE_BACKUP_DIR}"
rm -rf "${DELETE_BACKUP_DIR}"
mkdir -p "${DELETE_BACKUP_DIR}"
fi

/usr/local/bin/cluster-backup.sh --force ${CLUSTER_BACKUP_PATH}

Expand Down
1 change: 0 additions & 1 deletion go.mod
Expand Up @@ -9,7 +9,6 @@ require (
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2
github.com/openshift/api v0.0.0-20231010075512-1ccc6058c62d
github.com/openshift/build-machinery-go v0.0.0-20220913142420-e25cf57ea46d
github.com/openshift/client-go v0.0.0-20230926161409-848405da69e1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Expand Up @@ -242,8 +242,6 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2 h1:YocNLcTBdEdvY3iDK6jfWXvEaM5OCKkjxPKoJRdB3Gg=
github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2/go.mod h1:76rfSfYPWj01Z85hUf/ituArm797mNKcvINh1OlsZKo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down
6 changes: 6 additions & 0 deletions pkg/operator/etcd_assets/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 4 additions & 43 deletions pkg/operator/upgradebackupcontroller/upgradebackupcontroller.go
Expand Up @@ -32,8 +32,6 @@ import (
coreclientv1 "k8s.io/client-go/kubernetes/typed/core/v1"
corev1listers "k8s.io/client-go/listers/core/v1"
"k8s.io/klog/v2"

"github.com/mcuadros/go-version"
)

// UpgradeBackupController responds to an upgrade request to 4.9 by attempting
Expand All @@ -43,13 +41,16 @@ import (
// proceed without a recent backup to restore a cluster that is not healthy after
// upgrade to 4.9.

// This controller is removed from 4.15 on.

const (
backupConditionType = "RecentBackup"
backupSuccess = "UpgradeBackupSuccessful"
clusterBackupPodName = "cluster-backup"
recentBackupPath = "/etc/kubernetes/cluster-backup"
failedPodBackoffDuration = 30 * time.Second
backupDirEnvName = "CLUSTER_BACKUP_PATH"
deleteBackupDirEnvName = "DELETE_BACKUP_DIR"
)

type UpgradeBackupController struct {
Expand Down Expand Up @@ -295,6 +296,7 @@ func createBackupPod(ctx context.Context, nodeName, recentBackupName, operatorIm
pod.Spec.Containers[0].Image = targetImagePullSpec
pod.Spec.Containers[0].Env = []corev1.EnvVar{
{Name: backupDirEnvName, Value: fmt.Sprintf("%s/%s", recentBackupPath, recentBackupName)},
{Name: deleteBackupDirEnvName, Value: recentBackupPath},
}
_, _, err := resourceapply.ApplyPod(ctx, client, recorder, pod)
if err != nil {
Expand All @@ -315,10 +317,6 @@ func isRequireRecentBackup(config *configv1.ClusterVersion, clusterOperatorStatu
}
}

// consecutive upgrades case
if backupRequired, err := isNewBackupRequired(config, clusterOperatorStatus); err == nil && backupRequired {
return true
}
return false
}

Expand All @@ -344,40 +342,3 @@ func isBackupConditionExist(conditions []configv1.ClusterOperatorStatusCondition
}
return false
}

func isNewBackupRequired(config *configv1.ClusterVersion, clusterOperatorStatus *configv1.ClusterOperatorStatus) (bool, error) {
currentVersion := status.VersionForOperatorFromEnv()
if currentVersion == "" {
return false, nil
}
// check in ClusterVersion update history for update in progress (i.e. state: Partial)
// then check the condition of etcd operator
// if backup for current cluster version was taken, return false
// otherwise, if the update version greater than current version, return true
for _, update := range config.Status.History {
if update.State == configv1.PartialUpdate {
klog.V(4).Infof("in progress update is detected, cluster current version is %v, progressing towards cluster version %v", currentVersion, update.Version)
currentBackupVersion := getCurrentBackupVersion(clusterOperatorStatus)
if currentBackupVersion == currentVersion {
return false, nil
}
if cmp := version.CompareSimple(update.Version, currentVersion); cmp > 0 {
return true, nil
}
}
}

return false, nil
}

func getCurrentBackupVersion(clusterOperatorStatus *configv1.ClusterOperatorStatus) string {
backupCondition := configv1helpers.FindStatusCondition(clusterOperatorStatus.Conditions, backupConditionType)
if backupCondition == nil {
return ""
}
if backupCondition.Reason == backupSuccess {
backupVersion := strings.Fields(backupCondition.Message)[2]
return backupVersion
}
return ""
}
22 changes: 0 additions & 22 deletions vendor/github.com/mcuadros/go-version/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion vendor/github.com/mcuadros/go-version/.travis.yml

This file was deleted.

19 changes: 0 additions & 19 deletions vendor/github.com/mcuadros/go-version/LICENSE

This file was deleted.

80 changes: 0 additions & 80 deletions vendor/github.com/mcuadros/go-version/README.md

This file was deleted.