Skip to content

✨ Add v1beta2 conditions infrastructure to AWSCluster#5854

Open
Arpit529Srivastava wants to merge 7 commits intokubernetes-sigs:mainfrom
Arpit529Srivastava:feat-awscluster-v1beta2-conditions
Open

✨ Add v1beta2 conditions infrastructure to AWSCluster#5854
Arpit529Srivastava wants to merge 7 commits intokubernetes-sigs:mainfrom
Arpit529Srivastava:feat-awscluster-v1beta2-conditions

Conversation

@Arpit529Srivastava
Copy link
Contributor

@Arpit529Srivastava Arpit529Srivastava commented Jan 29, 2026

What type of PR is this?
/kind api-change
/kind feature

What this PR does / why we need it:

This pr prepares AWSCluster for migrating conditions to the new metav1.Condition format, following the same explicit dual-write pattern used in CAPI.

it adds a new V1Beta2 field to AWSClusterStatus to hold the next-generation condition set alongside the existing one, and implements GetV1Beta2Conditions and SetV1Beta2Conditions on AWSCluster. the conversion logic is updated so the V1Beta2 field is preserved across version conversions (v1beta2 ↔ v1beta1).

like capi, this keeps the dual-write logic explicit rather than introducing helper abstractions. that way, deprecated v1beta1 logic stays clearly separated from the newer v1beta2+ logic, making it easier to remove the legacy path later.

the actual v1beta2 condition constants will be introduced in a follow-up pr alongside the controller changes that will consume them.

Which issue(s) this PR fixes:

related : #5835

Special notes for your reviewer:

PR only includes API/Status changes and constants. No controller logic is changed in this PR. The controller implementation (dual-writing) will be handled in a follow-up PR.
Checklist:

  • squashed commits
  • includes documentation
  • includes emoji in title
  • adds unit tests
  • adds or updates e2e tests

Release note:

 Added v1beta2 conditions infrastructure (Status field and Constants) to `AWSCluster` to support future migration.

Signed-off-by: arpit529srivastava <arpitsrivastava529@gmail.com>
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. needs-priority cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 29, 2026
@k8s-ci-robot k8s-ci-robot requested review from AndiDog and damdo January 29, 2026 21:21
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 29, 2026
@k8s-ci-robot
Copy link
Contributor

Hi @Arpit529Srivastava. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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-sigs/prow repository.

@nrb
Copy link
Contributor

nrb commented Jan 29, 2026

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 29, 2026
Signed-off-by: arpit529srivastava <arpitsrivastava529@gmail.com>
Signed-off-by: arpit529srivastava <arpitsrivastava529@gmail.com>
@Arpit529Srivastava
Copy link
Contributor Author

@damdo a gentle ping, thanks :)

Copy link
Member

@damdo damdo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Arpit529Srivastava thanks a lot for your PR!
This is a good start :)

Left some comments

@@ -150,6 +150,9 @@ func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error {
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should touch v1beta1 types at all.
Only v1beta2 ones

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damdo just to make sure i’m understanding correctly about the v1beta1 conversion changes, should i remove the V1Beta3 restoration logic from awscluster_conversion.go? i followed the same pattern used for existing fields like ControlPlaneLoadBalancer, but i’m totally fine removing it if that’s not the direction we want to take.
wanted to confirm this part before i move on to the rest of the feedback. thanks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are adding new fields in v1beta2 then we need to preserve roundtrip compatibility. So it will require that you update the conversions in v1beta1 like you have done here to restore the value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of people make the mistake of adding the new field to old api versions as well to make the conversions work. But restoring the value from the saved state is the correct way (like you are doing).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are adding new fields in v1beta2 then we need to preserve roundtrip compatibility. So it will require that you update the conversions in v1beta1 like you have done here to restore the value.

Good point! Hadn't thought about that!

// AWSClusterV1Beta3Status groups all the fields that will be added or modified in AWSClusterStatus with the V1Beta3 version.
// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.
type AWSClusterV1Beta3Status struct {
// conditions represents the observations of an AWSCluster's current state.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// conditions represents the observations of an AWSCluster's current state.
// Conditions represents the observations of an AWSCluster's current state.

DedicatedHostReleaseFailedReason = "DedicatedHostReleaseFailed"
)

// AWSCluster's v1beta2 conditions and corresponding reasons.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// AWSCluster's v1beta2 conditions and corresponding reasons.
// AWSCluster's v1beta3 conditions and corresponding reasons.

DedicatedHostReleaseFailedReason = "DedicatedHostReleaseFailed"
)

// AWSCluster's v1beta2 conditions and corresponding reasons.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we should probably move these to a different place, how are other CAPI providers doing this during their transition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i took another look and separating them does seem like the cleaner approach. i’ll move the new v1beta3 constants into a separate file (api/v1beta2/conditions_consts_v1beta3.go).

)

// AWSCluster's v1beta2 conditions and corresponding reasons.
// These will be used with the V1Beta2 API version.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be or, are for CAPA v1beta2?

// AWSCluster's v1beta2 conditions and corresponding reasons.
// These will be used with the V1Beta2 API version.

// AWSCluster's Ready condition and corresponding reasons that will be used in v1Beta2 API version.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

// +listType=map
// +listMapKey=type
// +kubebuilder:validation:MaxItems=32
Conditions []metav1.Condition `json:"conditions,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we only dealing with AWSCluster and Conditions here?
If we do it this granular we'll potentially end up with (number of API types) x (number of fields to add) PRs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, i was initially planning to split these into separate prs to keep things smaller,. i agree it’s better to avoid creating too many prs for closely related changes.

Copy link
Contributor Author

@Arpit529Srivastava Arpit529Srivastava Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rethinking again, once we settle on the approach for v1beta1 conversions, #5854 (comment) i’ll add the same V1Beta3 status field to the other types as well (AWSMachine, AWSMachinePool, AWSManagedMachinePool, etc ...) in this same pr. just wanted to make sure we’re aligned on the pattern with AWSCluster first before rolling it out everywhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy either way. Smaller PRs always helps with review though.

@Arpit529Srivastava
Copy link
Contributor Author

Hey @Arpit529Srivastava thanks a lot for your PR!
This is a good start :)

Left some comments

thanks for the review 😃, taking a look.

@damdo
Copy link
Member

damdo commented Feb 4, 2026

/assign @nrb @damdo @richardcase @clebs

Signed-off-by: arpit529srivastava <arpitsrivastava529@gmail.com>
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from damdo. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Arpit529Srivastava
Copy link
Contributor Author

@clebs, can you please take a look.
Thanks

@@ -0,0 +1,114 @@
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these constants introduced? They are not being used anywhere and most values are duplicating existing constants.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, make sense.. i initially added these constants as groundwork for the next step, where the AWSClusterController will dual-write conditions into both status.conditions and status.v1beta3.conditions. however, rightg now since nothing in this pr actually consumes them yet, ill remove them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will introduce them together with the controller changes in the follow-up pr where they’ll actually be used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great thanks! Makes sense to introduce them in the next step. Also only introducing what is necessary.

Copy link
Contributor Author

@Arpit529Srivastava Arpit529Srivastava Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also @clebs, could you please advise me on this comment? I’m a little stuck here. Thanks, I really appreciate your help.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the initial comment from @damdo, he is saying you should not update files under api/v1beta1. Only files under api/v1beta2.

The comment is not asking to change CAPI conversion, just to not include it in the older CAPA v1beta1 API.

Please bear in mind that CAPI v1beta1 and CAPA v1beta1 are 2 different things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @clebs for the review will keep this in mind.

Signed-off-by: arpit529srivastava <arpitsrivastava529@gmail.com>
@@ -150,6 +150,9 @@ func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error {
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are adding new fields in v1beta2 then we need to preserve roundtrip compatibility. So it will require that you update the conversions in v1beta1 like you have done here to restore the value.

@@ -150,6 +150,9 @@ func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error {
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of people make the mistake of adding the new field to old api versions as well to make the conversions work. But restoring the value from the saved state is the correct way (like you are doing).

// +listType=map
// +listMapKey=type
// +kubebuilder:validation:MaxItems=32
Conditions []metav1.Condition `json:"conditions,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy either way. Smaller PRs always helps with review though.

}

// GetV1Beta3Conditions returns the set of conditions for this object.
func (r *AWSCluster) GetV1Beta3Conditions() []metav1.Condition {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the naming of things is going to get weird 😉

We need to adopt paused.EnsurePausedCondition in our controllers. This means that AWSCluster (and our other resource types) need to implement the v1beta2conditions.Setter/Getter interfaces . So these methods need to be named:

	// SetV1Beta2Conditions sets conditions for an API object.
	// Note: SetV1Beta2Conditions will be renamed to SetConditions in a later stage of the transition to V1Beta2.
	SetV1Beta2Conditions([]metav1.Condition)

	// GetV1Beta2Conditions returns the list of conditions for a cluster API object.
	// Note: GetV1Beta2Conditions will be renamed to GetConditions in a later stage of the transition to V1Beta2.
	GetV1Beta2Conditions() []metav1.Condition

Or we need additional functions.

It will be very messy/weird until we drop the old fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for clarifying 😄
i’ve updated the implementation to use GetV1Beta2Conditions() and SetV1Beta2Conditions() along with the Note: comments you mentioned.

it does feel a bit awkward during the transition, but i agree it’s better to align exactly with capi’s interface expectations.

Signed-off-by: arpit529srivastava <arpitsrivastava529@gmail.com>
@Arpit529Srivastava
Copy link
Contributor Author

@richardcase @damdo made all corrections, PTAL .
thanks :)

Copy link
Member

@richardcase richardcase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good @Arpit529Srivastava . I made some suggestions around the comments to make it obvious that we are talking about "CAPI contract" v1beta2 and not CAPA v1beta2.

Would you now plan to add the same changes for the other resource kinds?

V1Beta2 *AWSClusterV1Beta2Status `json:"v1beta2,omitempty"`
}

// AWSClusterV1Beta2Status groups all the fields that will be added or modified in AWSCluster with the V1Beta2 version.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// AWSClusterV1Beta2Status groups all the fields that will be added or modified in AWSCluster with the V1Beta2 version.
// AWSClusterV1Beta2Status groups all the fields that will be added or modified in AWSCluster with the V1Beta2 CAPI contract version.

Bastion *Instance `json:"bastion,omitempty"`
Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"`

// v1beta2 groups all the fields that will be added or modified in AWSCluster's status with the V1Beta2 version.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// v1beta2 groups all the fields that will be added or modified in AWSCluster's status with the V1Beta2 version.
// v1beta2 groups all the fields that will be added or modified in AWSCluster's status with the V1Beta2 CAPI contract version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

}

// GetV1Beta2Conditions returns the set of conditions for this object.
// Note: GetV1Beta2Conditions will be renamed to GetConditions in a later stage of the transition to V1Beta2.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Note: GetV1Beta2Conditions will be renamed to GetConditions in a later stage of the transition to V1Beta2.
// Note: GetV1Beta2Conditions will be renamed to GetConditions in a later stage of the transition to CAPI contract V1Beta2.

}

// SetV1Beta2Conditions sets conditions for an API object.
// Note: SetV1Beta2Conditions will be renamed to SetConditions in a later stage of the transition to V1Beta2.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Note: SetV1Beta2Conditions will be renamed to SetConditions in a later stage of the transition to V1Beta2.
// Note: SetV1Beta2Conditions will be renamed to SetConditions in a later stage of the transition to CAP contract V1Beta2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Signed-off-by: arpit529srivastava <arpitsrivastava529@gmail.com>
@Arpit529Srivastava
Copy link
Contributor Author

Looking good @Arpit529Srivastava . I made some suggestions around the comments to make it obvious that we are talking about "CAPI contract" v1beta2 and not CAPA v1beta2.

Would you now plan to add the same changes for the other resource kinds?

for the other resource kinds - yes, i’m planning to add them as well. since you mentioned that smaller prs are easier to review, i started with AWSCluster first and will follow up with separate prs for the remaining types.

is there anything specific i should watch out for when applying the same pattern to the other resources? any heads-up before i proceed?
thanks for reviewing :)

@richardcase
Copy link
Member

@Arpit529Srivastava - it might be nice to add a task list to #5835 so that progress can be tracked and people can help out. Once the conditions are added to the types, i'm guessing that the next stage is to then dual right conditions to the new fields?

@Arpit529Srivastava
Copy link
Contributor Author

Arpit529Srivastava commented Feb 12, 2026

sure that is much better way, added a task list to #5835 for tracking. thanks
if everything looks good, we can proceed with merging. awaiting your review. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. needs-priority ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants