-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
✨ Adds AvailableCondition
and ReadyCondition
Conditions to MachineDeployment
#4625
✨ Adds AvailableCondition
and ReadyCondition
Conditions to MachineDeployment
#4625
Conversation
Hi @Arvinderpal. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
return nil | ||
} | ||
|
||
// FIXME(awander): This func is removed after running `make generate`. I assume b/c there is no Conditions fields in v1alpha3 for MachineDeploymentStatus. What is the correct way to handle this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can someone help me here. What is the correct way to handle this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I got this right you should make sure to get roundtrip conversion by using marshal and unamarshal to in an annotation like we already have for spec.Strategy
in
cluster-api/api/v1alpha3/conversion.go
Lines 119 to 159 in 440a003
func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error { | |
dst := dstRaw.(*v1alpha4.MachineDeployment) | |
if err := Convert_v1alpha3_MachineDeployment_To_v1alpha4_MachineDeployment(src, dst, nil); err != nil { | |
return err | |
} | |
// Manually restore data. | |
restored := &v1alpha4.MachineDeployment{} | |
if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { | |
return err | |
} | |
if restored.Spec.Strategy != nil && restored.Spec.Strategy.RollingUpdate != nil { | |
if dst.Spec.Strategy == nil { | |
dst.Spec.Strategy = &v1alpha4.MachineDeploymentStrategy{} | |
} | |
if dst.Spec.Strategy.RollingUpdate == nil { | |
dst.Spec.Strategy.RollingUpdate = &v1alpha4.MachineRollingUpdateDeployment{} | |
} | |
dst.Spec.Strategy.RollingUpdate.DeletePolicy = restored.Spec.Strategy.RollingUpdate.DeletePolicy | |
} | |
return nil | |
} | |
func (dst *MachineDeployment) ConvertFrom(srcRaw conversion.Hub) error { | |
src := srcRaw.(*v1alpha4.MachineDeployment) | |
if err := Convert_v1alpha4_MachineDeployment_To_v1alpha3_MachineDeployment(src, dst, nil); err != nil { | |
return err | |
} | |
// Preserve Hub data on down-conversion except for metadata | |
if err := utilconversion.MarshalData(src, dst); err != nil { | |
return err | |
} | |
return nil | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay. Made the change. PTAL.
@@ -349,6 +350,14 @@ func (r *MachineDeploymentReconciler) scale(ctx context.Context, deployment *clu | |||
// syncDeploymentStatus checks if the status is up-to-date and sync it if necessary. | |||
func (r *MachineDeploymentReconciler) syncDeploymentStatus(allMSs []*clusterv1.MachineSet, newMS *clusterv1.MachineSet, d *clusterv1.MachineDeployment) error { | |||
d.Status = calculateStatus(allMSs, newMS, d) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be add a comment here that minReplicasNeeded
will be equal to d.Spec.Replicas
when the strategy is not RollingUpdateMachineDeploymentStrategyType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the only other strategy I see implemented today is OnDeleteMachineDeploymentStrategyType
. Would the comment become stale if we implement other strategies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Rolling update config params. Present only if
// MachineDeploymentStrategyType = RollingUpdate.
// +optional
RollingUpdate *MachineRollingUpdateDeployment `json:"rollingUpdate,omitempty"`
As today maxUnavailable and MaxSurge are only applicable when // MachineDeploymentStrategyType = RollingUpdate.
I think reinforcing this would make it easier for new folks to ramp up and avoid confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Added the comment.
api/v1alpha4/condition_consts.go
Outdated
// machines required are up and running for at least minReadySeconds. | ||
AvailableCondition ConditionType = "Available" | ||
|
||
// MinimumMachinesAvailableReason reflects the minimum availability of machines for a machinedeployment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having a hard time to read this, "reflects the minimum availability of machines for a machinedeployment." doesn't seem right to me, since this variable is just meant to be the reason for Available=false. Also shouldn't it be NotMinimumMachinesAvailable
as that's the reason for Available=false
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to NotMinimumMachinesAvailableReason
and updated the comment.
/ok-to-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@enxebre Thank you for the quick feedback. I will work on adding a unit test for the negative case.
@@ -349,6 +350,14 @@ func (r *MachineDeploymentReconciler) scale(ctx context.Context, deployment *clu | |||
// syncDeploymentStatus checks if the status is up-to-date and sync it if necessary. | |||
func (r *MachineDeploymentReconciler) syncDeploymentStatus(allMSs []*clusterv1.MachineSet, newMS *clusterv1.MachineSet, d *clusterv1.MachineDeployment) error { | |||
d.Status = calculateStatus(allMSs, newMS, d) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the only other strategy I see implemented today is OnDeleteMachineDeploymentStrategyType
. Would the comment become stale if we implement other strategies?
return nil | ||
} | ||
|
||
// FIXME(awander): This func is removed after running `make generate`. I assume b/c there is no Conditions fields in v1alpha3 for MachineDeploymentStatus. What is the correct way to handle this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I got this right you should make sure to get roundtrip conversion by using marshal and unamarshal to in an annotation like we already have for spec.Strategy
in
cluster-api/api/v1alpha3/conversion.go
Lines 119 to 159 in 440a003
func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error { | |
dst := dstRaw.(*v1alpha4.MachineDeployment) | |
if err := Convert_v1alpha3_MachineDeployment_To_v1alpha4_MachineDeployment(src, dst, nil); err != nil { | |
return err | |
} | |
// Manually restore data. | |
restored := &v1alpha4.MachineDeployment{} | |
if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { | |
return err | |
} | |
if restored.Spec.Strategy != nil && restored.Spec.Strategy.RollingUpdate != nil { | |
if dst.Spec.Strategy == nil { | |
dst.Spec.Strategy = &v1alpha4.MachineDeploymentStrategy{} | |
} | |
if dst.Spec.Strategy.RollingUpdate == nil { | |
dst.Spec.Strategy.RollingUpdate = &v1alpha4.MachineRollingUpdateDeployment{} | |
} | |
dst.Spec.Strategy.RollingUpdate.DeletePolicy = restored.Spec.Strategy.RollingUpdate.DeletePolicy | |
} | |
return nil | |
} | |
func (dst *MachineDeployment) ConvertFrom(srcRaw conversion.Hub) error { | |
src := srcRaw.(*v1alpha4.MachineDeployment) | |
if err := Convert_v1alpha4_MachineDeployment_To_v1alpha3_MachineDeployment(src, dst, nil); err != nil { | |
return err | |
} | |
// Preserve Hub data on down-conversion except for metadata | |
if err := utilconversion.MarshalData(src, dst); err != nil { | |
return err | |
} | |
return nil | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabriziopandini I have addressed all the comments. PTAL
return nil | ||
} | ||
|
||
// FIXME(awander): This func is removed after running `make generate`. I assume b/c there is no Conditions fields in v1alpha3 for MachineDeploymentStatus. What is the correct way to handle this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay. Made the change. PTAL.
6d16a47
to
bbbdcf4
Compare
/retest |
bbbdcf4
to
5019ec0
Compare
Can anyone help me with why
Is it possibly related to this line in build logs? I did add a new test at line 393, but I don't quite understand why that would be the issue:
|
@Arvinderpal We are in the process of dropping ginkgo from the unit/integration tests. If you get the latest changes i.e |
5019ec0
to
b00bf38
Compare
57eefbd
to
53edcbc
Compare
@enxebre I have addressed the last comment. |
Now that v1alpha4 is out, can we merge this? |
/hold cancel |
@fabriziopandini @srm09 This has been sitting for a while. If we can merge this, then I can follow up with additional Conditions. 🙏 |
/lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CecileRobertMichon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
? |
@CecileRobertMichon Can't seem to make out from the logs why this is happening. It could just be flaky so I'll try retest again but if that fails, I can try to rebase my branch. This will remove all the lgtms and approves... |
/retest-required |
53edcbc
to
377cd74
Compare
`AvailableCondition` and `ReadyCondition`.
377cd74
to
c0caa60
Compare
@Arvinderpal: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@CecileRobertMichon @enxebre @srm09 Please lgtm and approve again. I had to rebase with master in order for all CI jobs to pass. 🙏 |
/lgtm |
What this PR does / why we need it:
Following the model of KCP and Machine Conditions, this PR adds an
AvailableCondition
to MachineDeployment. The condition is true when Nodes of the underlying MachineSet(s) are available to take on workloads. It also adds the summaryReadyCondition
.Tracking issue: #3486