Skip to content

Commit d08a59d

Browse files
authored
Merge pull request #12939 from fabriziopandini/add-updating-to-machine-ready
🌱 Consider updating condition when computing Machine's ready condition
2 parents 6c59755 + 372aee0 commit d08a59d

File tree

4 files changed

+83
-4
lines changed

4 files changed

+83
-4
lines changed

api/core/v1beta2/machine_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ const (
120120
// Machine's Ready condition and corresponding reasons.
121121
const (
122122
// MachineReadyCondition is true if the Machine's deletionTimestamp is not set, Machine's BootstrapConfigReady, InfrastructureReady,
123-
// NodeHealthy and HealthCheckSucceeded (if present) conditions are true; if other conditions are defined in spec.readinessGates,
123+
// NodeHealthy and HealthCheckSucceeded (if present) conditions are true, Updating condition is false; if other conditions are defined in spec.readinessGates,
124124
// these conditions must be true as well.
125125
// Note:
126126
// - When summarizing the Deleting condition:

internal/controllers/machine/machine_controller_status.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,12 +657,13 @@ func setReadyCondition(ctx context.Context, machine *clusterv1.Machine) {
657657

658658
forConditionTypes := conditions.ForConditionTypes{
659659
clusterv1.MachineDeletingCondition,
660+
clusterv1.MachineUpdatingCondition,
660661
clusterv1.MachineBootstrapConfigReadyCondition,
661662
clusterv1.MachineInfrastructureReadyCondition,
662663
clusterv1.MachineNodeHealthyCondition,
663664
clusterv1.MachineHealthCheckSucceededCondition,
664665
}
665-
negativePolarityConditionTypes := []string{clusterv1.MachineDeletingCondition}
666+
negativePolarityConditionTypes := []string{clusterv1.MachineDeletingCondition, clusterv1.MachineUpdatingCondition}
666667
for _, g := range machine.Spec.ReadinessGates {
667668
forConditionTypes = append(forConditionTypes, g.ConditionType)
668669
if g.Polarity == clusterv1.NegativePolarityCondition {
@@ -685,9 +686,10 @@ func setReadyCondition(ctx context.Context, machine *clusterv1.Machine) {
685686
negativePolarityConditionTypes: negativePolarityConditionTypes,
686687
},
687688
},
688-
// Instruct summary to consider Deleting condition with negative polarity.
689+
// Instruct summary to consider Deleting and updating condition with negative polarity.
689690
conditions.NegativePolarityConditionTypes{
690691
clusterv1.MachineDeletingCondition,
692+
clusterv1.MachineUpdatingCondition,
691693
},
692694
}
693695

internal/controllers/machine/machine_controller_status_test.go

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
"sigs.k8s.io/cluster-api/util/conditions"
3636
v1beta1conditions "sigs.k8s.io/cluster-api/util/conditions/deprecated/v1beta1"
3737
"sigs.k8s.io/cluster-api/util/kubeconfig"
38-
builder "sigs.k8s.io/cluster-api/util/test/builder"
38+
"sigs.k8s.io/cluster-api/util/test/builder"
3939
)
4040

4141
func TestSetBootstrapReadyCondition(t *testing.T) {
@@ -1439,6 +1439,11 @@ func TestSetReadyCondition(t *testing.T) {
14391439
Status: metav1.ConditionFalse,
14401440
Reason: clusterv1.MachineNotDeletingReason,
14411441
},
1442+
{
1443+
Type: clusterv1.MachineUpdatingCondition,
1444+
Status: metav1.ConditionFalse,
1445+
Reason: clusterv1.MachineNotUpdatingReason,
1446+
},
14421447
},
14431448
},
14441449
},
@@ -1479,6 +1484,11 @@ func TestSetReadyCondition(t *testing.T) {
14791484
Reason: clusterv1.MachineDeletingWaitingForPreDrainHookReason,
14801485
Message: "Waiting for pre-drain hooks to succeed (hooks: test-hook)",
14811486
},
1487+
{
1488+
Type: clusterv1.MachineUpdatingCondition,
1489+
Status: metav1.ConditionFalse,
1490+
Reason: clusterv1.MachineNotUpdatingReason,
1491+
},
14821492
},
14831493
},
14841494
},
@@ -1489,6 +1499,51 @@ func TestSetReadyCondition(t *testing.T) {
14891499
Message: "* Deleting: Machine deletion in progress, stage: WaitingForPreDrainHook",
14901500
},
14911501
},
1502+
{
1503+
name: "Aggregates Ready condition correctly while the machine is updating",
1504+
machine: &clusterv1.Machine{
1505+
ObjectMeta: metav1.ObjectMeta{
1506+
Name: "machine-test",
1507+
Namespace: metav1.NamespaceDefault,
1508+
},
1509+
Status: clusterv1.MachineStatus{
1510+
Conditions: []metav1.Condition{
1511+
{
1512+
Type: clusterv1.MachineBootstrapConfigReadyCondition,
1513+
Status: metav1.ConditionTrue,
1514+
Reason: "Foo",
1515+
},
1516+
{
1517+
Type: clusterv1.InfrastructureReadyCondition,
1518+
Status: metav1.ConditionTrue,
1519+
Reason: "Foo",
1520+
},
1521+
{
1522+
Type: clusterv1.MachineNodeHealthyCondition,
1523+
Status: metav1.ConditionTrue,
1524+
Reason: "Foo",
1525+
},
1526+
{
1527+
Type: clusterv1.MachineDeletingCondition,
1528+
Status: metav1.ConditionFalse,
1529+
Reason: clusterv1.MachineNotDeletingReason,
1530+
},
1531+
{
1532+
Type: clusterv1.MachineUpdatingCondition,
1533+
Status: metav1.ConditionTrue,
1534+
Reason: clusterv1.MachineInPlaceUpdatingReason,
1535+
Message: "In place update in progress",
1536+
},
1537+
},
1538+
},
1539+
},
1540+
expectCondition: metav1.Condition{
1541+
Type: clusterv1.MachineReadyCondition,
1542+
Status: metav1.ConditionFalse,
1543+
Reason: clusterv1.MachineNotReadyReason,
1544+
Message: "* Updating: In place update in progress",
1545+
},
1546+
},
14921547
{
14931548
name: "Aggregates Ready condition correctly while the machine is deleting (waiting for Node drain)",
14941549
machine: &clusterv1.Machine{
@@ -1528,6 +1583,11 @@ func TestSetReadyCondition(t *testing.T) {
15281583
* some other error 4: pod-9-to-trigger-eviction-some-other-error
15291584
* ... (1 more error applying to 1 Pod)`,
15301585
},
1586+
{
1587+
Type: clusterv1.MachineUpdatingCondition,
1588+
Status: metav1.ConditionFalse,
1589+
Reason: clusterv1.MachineNotUpdatingReason,
1590+
},
15311591
},
15321592
},
15331593
},
@@ -1573,6 +1633,11 @@ func TestSetReadyCondition(t *testing.T) {
15731633
Status: metav1.ConditionFalse,
15741634
Reason: clusterv1.MachineNotDeletingReason,
15751635
},
1636+
{
1637+
Type: clusterv1.MachineUpdatingCondition,
1638+
Status: metav1.ConditionFalse,
1639+
Reason: clusterv1.MachineNotUpdatingReason,
1640+
},
15761641
},
15771642
},
15781643
},
@@ -1640,6 +1705,11 @@ func TestSetReadyCondition(t *testing.T) {
16401705
Status: metav1.ConditionFalse,
16411706
Reason: clusterv1.MachineNotDeletingReason,
16421707
},
1708+
{
1709+
Type: clusterv1.MachineUpdatingCondition,
1710+
Status: metav1.ConditionFalse,
1711+
Reason: clusterv1.MachineNotUpdatingReason,
1712+
},
16431713
},
16441714
},
16451715
},
@@ -1710,6 +1780,11 @@ func TestSetReadyCondition(t *testing.T) {
17101780
Status: metav1.ConditionFalse,
17111781
Reason: clusterv1.MachineNotDeletingReason,
17121782
},
1783+
{
1784+
Type: clusterv1.MachineUpdatingCondition,
1785+
Status: metav1.ConditionFalse,
1786+
Reason: clusterv1.MachineNotUpdatingReason,
1787+
},
17131788
},
17141789
},
17151790
},

util/conditions/sort.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func defaultSortLessFunc(i, j metav1.Condition) bool {
7676
// | OwnerRemediated | | | | | | x |
7777
// | -- Operations -- | | | | | | |
7878
// | TopologyReconciled | x | | | | | |
79+
// | Updating | | | | | | x |
7980
// | RollingOut | x | x | x | | x | |
8081
// | Remediating | x | x | x | x | x | |
8182
// | ScalingDown | x | x | x | x | x | |
@@ -117,6 +118,7 @@ var order = []string{
117118
clusterv1.MachineHealthCheckSucceededCondition,
118119
clusterv1.MachineOwnerRemediatedCondition,
119120
clusterv1.ClusterTopologyReconciledCondition,
121+
clusterv1.MachineUpdatingCondition,
120122
clusterv1.RollingOutCondition,
121123
clusterv1.RemediatingCondition,
122124
clusterv1.ScalingDownCondition,

0 commit comments

Comments
 (0)