Skip to content

Commit 5077a89

Browse files
committed
Drop revisionHistory in MachineDeployment
1 parent 19d5987 commit 5077a89

26 files changed

+36
-658
lines changed

api/core/v1beta1/conversion_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ func spokeMachineDeploymentSpec(in *MachineDeploymentSpec, c fuzz.Continue) {
326326

327327
// Drop ProgressDeadlineSeconds as we intentionally don't preserve it.
328328
in.ProgressDeadlineSeconds = nil
329+
330+
// Drop RevisionHistoryLimit as we intentionally don't preserve it.
331+
in.RevisionHistoryLimit = nil
329332
}
330333

331334
func spokeMachineDeploymentStatus(in *MachineDeploymentStatus, c fuzz.Continue) {

api/core/v1beta1/zz_generated.conversion.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/core/v1beta2/machinedeployment_types.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ const (
4545
// RevisionAnnotation is the revision annotation of a machine deployment's machine sets which records its rollout sequence.
4646
RevisionAnnotation = "machinedeployment.clusters.x-k8s.io/revision"
4747

48-
// RevisionHistoryAnnotation maintains the history of all old revisions that a machine set has served for a machine deployment.
49-
//
50-
// Deprecated: This annotation is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/issues/10479 for more details.
51-
RevisionHistoryAnnotation = "machinedeployment.clusters.x-k8s.io/revision-history"
52-
5348
// DesiredReplicasAnnotation is the desired replicas for a machine deployment recorded as an annotation
5449
// in its machine sets. Helps in separating scaling events from the rollout process and for
5550
// determining if the new machine set for a deployment is really saturated.
@@ -295,15 +290,6 @@ type MachineDeploymentSpec struct {
295290
// +optional
296291
MachineNamingStrategy *MachineNamingStrategy `json:"machineNamingStrategy,omitempty"`
297292

298-
// revisionHistoryLimit is the number of old MachineSets to retain to allow rollback.
299-
// This is a pointer to distinguish between explicit zero and not specified.
300-
// Defaults to 1.
301-
//
302-
// Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/issues/10479 for more details.
303-
//
304-
// +optional
305-
RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty"`
306-
307293
// paused indicates that the deployment is paused.
308294
// +optional
309295
Paused bool `json:"paused,omitempty"`

api/core/v1beta2/zz_generated.deepcopy.go

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/core/v1beta2/zz_generated.openapi.go

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/clusterctl/client/alpha/machinedeployment.go

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,14 @@ package alpha
1919
import (
2020
"context"
2121
"fmt"
22-
"strconv"
2322
"time"
2423

2524
"github.com/pkg/errors"
26-
"k8s.io/apimachinery/pkg/api/meta"
27-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28-
"k8s.io/apimachinery/pkg/labels"
29-
"k8s.io/apimachinery/pkg/runtime"
3025
"k8s.io/apimachinery/pkg/types"
31-
"k8s.io/klog/v2"
3226
"sigs.k8s.io/controller-runtime/pkg/client"
3327

3428
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3529
"sigs.k8s.io/cluster-api/cmd/clusterctl/client/cluster"
36-
logf "sigs.k8s.io/cluster-api/cmd/clusterctl/log"
3730
)
3831

3932
// getMachineDeployment retrieves the MachineDeployment object corresponding to the name and namespace specified.
@@ -80,99 +73,3 @@ func patchMachineDeployment(ctx context.Context, proxy cluster.Proxy, name, name
8073
}
8174
return nil
8275
}
83-
84-
// findMachineDeploymentRevision finds the specific revision in the machine sets.
85-
func findMachineDeploymentRevision(toRevision int64, allMSs []*clusterv1.MachineSet) (*clusterv1.MachineSet, error) {
86-
var (
87-
latestMachineSet *clusterv1.MachineSet
88-
latestRevision = int64(-1)
89-
previousMachineSet *clusterv1.MachineSet
90-
previousRevision = int64(-1)
91-
)
92-
for _, ms := range allMSs {
93-
if v, err := revision(ms); err == nil {
94-
switch toRevision {
95-
case 0:
96-
if latestRevision < v {
97-
// newest one we've seen so far
98-
previousRevision = latestRevision
99-
previousMachineSet = latestMachineSet
100-
latestRevision = v
101-
latestMachineSet = ms
102-
} else if previousRevision < v {
103-
// second newest one we've seen so far
104-
previousRevision = v
105-
previousMachineSet = ms
106-
}
107-
case v:
108-
return ms, nil
109-
}
110-
}
111-
}
112-
113-
if toRevision > 0 {
114-
return nil, errors.Errorf("unable to find specified MachineDeployment revision: %v", toRevision)
115-
}
116-
117-
if previousMachineSet == nil {
118-
return nil, errors.Errorf("no rollout history found for MachineDeployment")
119-
}
120-
return previousMachineSet, nil
121-
}
122-
123-
// getMachineSetsForDeployment returns a list of MachineSets associated with a MachineDeployment.
124-
func getMachineSetsForDeployment(ctx context.Context, proxy cluster.Proxy, md *clusterv1.MachineDeployment) ([]*clusterv1.MachineSet, error) {
125-
log := logf.Log
126-
c, err := proxy.NewClient(ctx)
127-
if err != nil {
128-
return nil, err
129-
}
130-
// List all MachineSets to find those we own but that no longer match our selector.
131-
machineSets := &clusterv1.MachineSetList{}
132-
if err := c.List(ctx, machineSets, client.InNamespace(md.Namespace)); err != nil {
133-
return nil, err
134-
}
135-
136-
filtered := make([]*clusterv1.MachineSet, 0, len(machineSets.Items))
137-
for idx := range machineSets.Items {
138-
ms := &machineSets.Items[idx]
139-
log := log.WithValues("MachineSet", klog.KObj(ms))
140-
141-
// Skip this MachineSet if its controller ref is not pointing to this MachineDeployment
142-
if !metav1.IsControlledBy(ms, md) {
143-
log.V(5).Info("Skipping MachineSet, controller ref does not match MachineDeployment")
144-
continue
145-
}
146-
147-
selector, err := metav1.LabelSelectorAsSelector(&md.Spec.Selector)
148-
if err != nil {
149-
log.V(5).Info("Skipping MachineSet, failed to get label selector from spec selector")
150-
continue
151-
}
152-
// If a MachineDeployment with a nil or empty selector creeps in, it should match nothing, not everything.
153-
if selector.Empty() {
154-
log.V(5).Info("Skipping MachineSet as the selector is empty")
155-
continue
156-
}
157-
// Skip this MachineSet if selector does not match
158-
if !selector.Matches(labels.Set(ms.Labels)) {
159-
log.V(5).Info("Skipping MachineSet, label mismatch")
160-
continue
161-
}
162-
filtered = append(filtered, ms)
163-
}
164-
165-
return filtered, nil
166-
}
167-
168-
func revision(obj runtime.Object) (int64, error) {
169-
acc, err := meta.Accessor(obj)
170-
if err != nil {
171-
return 0, err
172-
}
173-
v, ok := acc.GetAnnotations()[clusterv1.RevisionAnnotation]
174-
if !ok {
175-
return 0, nil
176-
}
177-
return strconv.ParseInt(v, 10, 64)
178-
}

cmd/clusterctl/client/alpha/rollout.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,11 @@ var validResourceTypes = []string{
3636
KubeadmControlPlane,
3737
}
3838

39-
var validRollbackResourceTypes = []string{
40-
MachineDeployment,
41-
}
42-
4339
// Rollout defines the behavior of a rollout implementation.
4440
type Rollout interface {
4541
ObjectRestarter(context.Context, cluster.Proxy, corev1.ObjectReference) error
4642
ObjectPauser(context.Context, cluster.Proxy, corev1.ObjectReference) error
4743
ObjectResumer(context.Context, cluster.Proxy, corev1.ObjectReference) error
48-
ObjectRollbacker(context.Context, cluster.Proxy, corev1.ObjectReference, int64) error
4944
}
5045

5146
var _ Rollout = &rollout{}

cmd/clusterctl/client/alpha/rollout_rollbacker.go

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)