Skip to content
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

⚠️ Remove InstanceID from machine spec #1961

Closed
wants to merge 4 commits into from

Conversation

mdbooth
Copy link
Contributor

@mdbooth mdbooth commented Mar 20, 2024

This is a status field and should not be included in the spec. ProviderID is the same, but cannot be removed as it is required by Cluster API.

While we're changing it, we change the default printcolumns for OpenStackMachine to report server ID instead of provider ID. We don't need to report provider ID here because we already know everything is an openstack server. New output example:

> kc get openstackmachine
NAME             CLUSTER    SERVERID                               INSTANCESTATE   READY   MACHINE          AGE
test-foo-fbvcg   test-foo   b4547d60-0f7e-44ea-b77a-30e951556fe3   ACTIVE          true    test-foo-fbvcg   5m52s

/hold

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 20, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mdbooth

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 20, 2024
Copy link

netlify bot commented Mar 20, 2024

Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!

Name Link
🔨 Latest commit a3c6d59
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-openstack/deploys/6606e14fd08a6500089cc8c9
😎 Deploy Preview https://deploy-preview-1961--kubernetes-sigs-cluster-api-openstack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mdbooth
Copy link
Contributor Author

mdbooth commented Mar 20, 2024

This needs a docs update, and also an update to the machine printcolumns.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 20, 2024
@mdbooth
Copy link
Contributor Author

mdbooth commented Mar 20, 2024

Should be good to go now.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 21, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 21, 2024
@mdbooth
Copy link
Contributor Author

mdbooth commented Mar 21, 2024

/test pull-cluster-api-provider-openstack-e2e-full-test

openStackCluster.Status.Bastion.Name = is.Name()
openStackCluster.Status.Bastion.SSHKeyName = is.SSHKeyName()
Copy link
Contributor

Choose a reason for hiding this comment

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

with SSHKeyName being removed, the function at line 91 can also be removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, it's worth documenting that these fields are being removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both addressed. Also noticed that we weren't using AvailabilityZone() any more and removed that, too.

@mdbooth mdbooth force-pushed the instanceidstatus branch 2 times, most recently from 6b9c47b to 5275848 Compare March 22, 2024 13:40
@mdbooth
Copy link
Contributor Author

mdbooth commented Mar 22, 2024

/test pull-cluster-api-provider-openstack-e2e-full-test

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 22, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 22, 2024
@@ -342,7 +385,16 @@ func Convert_v1beta1_OpenStackMachineSpec_To_v1alpha6_OpenStackMachineSpec(in *i

/* OpenStackMachineStatus */

func restorev1alpha6MachineStatus(previous *OpenStackMachineStatus, dst *OpenStackMachineStatus) {
if dst.InstanceState == nil || *dst.InstanceState == "" {
dst.InstanceState = previous.InstanceState
Copy link
Contributor

Choose a reason for hiding this comment

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

the other restore functions skip the setting of previous into dst when the resource is empty/nil. Should we follow the same pattern here?

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've been adding that incrementally. As this is a new function I should have added it here.

@@ -157,6 +158,10 @@ spec:
name: "MyOpenStackFloatingIPPool"
```

#### Removal of instanceID from spec

The OpenStackMachine controller previously set `instanceID` in the machine spec, in addition to `providerID`. `providerID` remains unchanged as it is required by Cluster API, but `instanceID` is no longer set. If still required, it is now available in the status in `dependentResources`.
Copy link
Contributor

Choose a reason for hiding this comment

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

dependentResources should be renamed to resources

@@ -164,9 +159,9 @@ type OpenStackMachineStatus struct {
// +kubebuilder:resource:path=openstackmachines,scope=Namespaced,categories=cluster-api,shortName=osm
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this OpenStackMachine belongs"
// +kubebuilder:printcolumn:name="InstanceState",type="string",JSONPath=".status.instanceState",description="OpenStack instance state"
// +kubebuilder:printcolumn:name="ServerID",type="string",JSONPath=".status.dependentResources.server.id",description="OpenStack instance ID"
Copy link
Contributor

Choose a reason for hiding this comment

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

dependentResources should now be resources?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated and re-tested on a running cluster:

> kc get openstackmachine
NAME             CLUSTER    SERVERID                               INSTANCESTATE   READY   MACHINE          AGE
test-foo-c4wdz   test-foo   a5500a2d-d1f8-4b8e-a7bb-2b94977eb893   BUILD                   test-foo-c4wdz   4m26s

@@ -164,9 +159,9 @@ type OpenStackMachineStatus struct {
// +kubebuilder:resource:path=openstackmachines,scope=Namespaced,categories=cluster-api,shortName=osm
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this OpenStackMachine belongs"
// +kubebuilder:printcolumn:name="InstanceState",type="string",JSONPath=".status.instanceState",description="OpenStack instance state"
// +kubebuilder:printcolumn:name="ServerID",type="string",JSONPath=".status.dependentResources.server.id",description="OpenStack instance ID"
// +kubebuilder:printcolumn:name="InstanceState",type="string",JSONPath=".status.dependentResources.server.state",description="OpenStack instance state"
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

}

func Convert_v1alpha7_OpenStackMachineStatus_To_v1beta1_OpenStackMachineStatus(in *OpenStackMachineStatus, out *infrav1.OpenStackMachineStatus, s apiconversion.Scope) error {
// ReferencedResources have no equivalent in v1beta1
Copy link
Contributor

Choose a reason for hiding this comment

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

we probably want to replace ReferencedResources for Resolved

@mdbooth
Copy link
Contributor Author

mdbooth commented Mar 22, 2024

/test pull-cluster-api-provider-openstack-e2e-full-test

@MaysaMacedo
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 25, 2024
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 25, 2024
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@@ -358,14 +358,15 @@ type AddressPair struct {
}

type BastionStatus struct {
ID string `json:"id,omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should probably put bastion ID and State back, too.

Copy link
Contributor

Choose a reason for hiding this comment

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

It was the idea that State and ID goes into Server to mimic what's on OpenStackMachineStatus. No strong opinion from my side here.

Comment on lines +366 to +376

// Server describes the OpenStack server created for the bastion
// +optional
Server *ServerStatus `json:"server,omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we still need this?

This is a status field and should not be included in the spec.
ProviderID is the same, but cannot be removed as it is required by
Cluster API.
@dulek
Copy link
Contributor

dulek commented Mar 29, 2024

Okay, I think I found the issue.

@k8s-ci-robot
Copy link
Contributor

@mdbooth: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-provider-openstack-e2e-test a3c6d59 link true /test pull-cluster-api-provider-openstack-e2e-test

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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 29, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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.

@mdbooth
Copy link
Contributor Author

mdbooth commented Apr 1, 2024

I've decided to replace this with #1988, which has a smaller scope.

@mdbooth mdbooth closed this Apr 1, 2024
@mdbooth mdbooth deleted the instanceidstatus branch April 1, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants