Skip to content

Commit

Permalink
Merge pull request #1185 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…1154-to-release-4.12

[release-4.12] OCPBUGS-27776: [4.13] Remove z-upgrades from UpgradeBackupController
  • Loading branch information
openshift-merge-bot[bot] committed Feb 5, 2024
2 parents 909474c + 42a5320 commit ea5555a
Show file tree
Hide file tree
Showing 17 changed files with 14 additions and 934 deletions.
5 changes: 5 additions & 0 deletions bindata/etcd/cluster-backup-pod.yaml
Expand Up @@ -34,6 +34,11 @@ 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}/*"
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-20230330150608-05635858d40f
github.com/openshift/build-machinery-go v0.0.0-20220913142420-e25cf57ea46d
github.com/openshift/client-go v0.0.0-20230120202327-72f107311084
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Expand Up @@ -391,8 +391,6 @@ github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/matttproud/golang_protobuf_extensions v1.0.2 h1:hAHbPm5IJGijwng3PWk09JkG9WeqChjprR5s9bBZ+OM=
github.com/matttproud/golang_protobuf_extensions v1.0.2/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/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down
5 changes: 5 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 @@ -30,8 +30,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 @@ -41,13 +39,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 @@ -288,6 +289,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 @@ -308,10 +310,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 @@ -337,40 +335,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.

0 comments on commit ea5555a

Please sign in to comment.