Skip to content

Commit 9252f66

Browse files
committed
Addressing comments regarding documentation, missing docstring, unnecessary conversions
1 parent f1ff3e3 commit 9252f66

File tree

7 files changed

+24
-8
lines changed

7 files changed

+24
-8
lines changed

api/v1alpha7/conversion_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ func TestFuzzyConversion(t *testing.T) {
6464
func(v1alpha8OpenStackMachine *infrav1.OpenStackMachine, c fuzz.Continue) {
6565
c.FuzzNoCustom(v1alpha8OpenStackMachine)
6666

67-
// None of the following fields have ever been set in v1alpha7
6867
v1alpha8OpenStackMachine.Status.ReferencedResources = infrav1.ReferencedMachineResources{}
6968
},
7069

api/v1alpha8/types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,10 @@ type APIServerLoadBalancer struct {
363363
Provider string `json:"provider,omitempty"`
364364
}
365365

366-
// ReferencedMachineResources contains resolved references to resources required by a machine.
366+
// ReferencedMachineResources contains resolved references to resources required by the machine.
367367
type ReferencedMachineResources struct {
368+
// ServerGroupID is the ID of the server group the machine should be added to and is calculated based on ServerGroupFilter.
369+
// +optional
368370
ServerGroupID string `json:"serverGroupID,omitempty"`
369371
}
370372

docs/book/src/development/development.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,3 +341,13 @@ $ sudo ln -s /run/user/$(id -u)/podman/podman.sock /var/run/docker.sock
341341
[hack-ci-create-devstack]: https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/main/hack/ci/create_devstack.sh
342342
[hack-ci-gce-project]: https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/main/hack/ci/gce-project.sh
343343
[hack-ci-openstack]: https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/main/hack/ci/openstack.sh
344+
345+
## API concepts
346+
347+
This sections goal is to gather various insights into the API design that can serve as a reference to explain various choices made without need to analyze discussions in individual PRs.
348+
349+
### `referencedResources`
350+
351+
Starting from v1alpha8 both `OpenStackMachineStatus` and `BastionsStatus` feature a field named `referencedResources` which aims to include fields that list individual IDs of the resources associated with the machine or bastion. These IDs are calculated on machine or bastion creation and are not intended to be changed during the object lifecycle.
352+
353+
Having all the IDs of related resources saved in the statuses allows CAPO to make easy decisions about deleting the related resources when deleting the VM corresponding to the machine or bastion.

docs/book/src/topics/crd-changes/v1alpha7-to-v1alpha8.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ This only documents backwards incompatible changes. Fields that were added to v1
2323

2424
### `OpenStackMachine`
2525

26-
#### Change to `serverGroupID`
26+
#### ⚠️ Change to `serverGroupID`
2727

28-
The `spec`'s field `serverGroupID` has been renamed to `serverGroup` and isn't a string anymore but a reference to a `ServerGroupFilter` object.
28+
The field `serverGroupID` has been renamed to `serverGroup` and is now a `ServerGroupFilter` object rather than a string ID.
29+
30+
The `ServerGroupFilter` object allows selection of a server group by name or by ID.
2931

3032
```yaml
3133
serverGroupID: "e60f19e7-cb37-49f9-a2ee-0a1281f6e03e"
@@ -38,7 +40,7 @@ serverGroup:
3840
id: "e60f19e7-cb37-49f9-a2ee-0a1281f6e03e"
3941
```
4042
41-
It is now possible to specify a `ServerGroupFilter` object to select the external network to use for the cluster. The `ServerGroupFilter` object allows to select the server group by name or by ID.
43+
To select a server group by name instead of ID:
4244
4345
```yaml
4446
serverGroup:

pkg/cloud/services/compute/referenced_resources.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import (
2121
"sigs.k8s.io/cluster-api-provider-openstack/pkg/scope"
2222
)
2323

24+
// ResolveReferencedMachineResources is responsible for populating ReferencedMachineResources with IDs of
25+
// the resources referenced in the OpenStackMachineSpec by querying the OpenStack APIs. It'll return error
26+
// if resources cannot be found or their filters are ambiguous.
2427
func ResolveReferencedMachineResources(scope scope.Scope, spec *infrav1.OpenStackMachineSpec, resources *infrav1.ReferencedMachineResources) error {
2528
compute, err := NewService(scope)
2629
if err != nil {

pkg/cloud/services/compute/referenced_resources_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2018 The Kubernetes Authors.
2+
Copyright 2024 The Kubernetes Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@ func Test_ResolveReferencedMachineResources(t *testing.T) {
6262
wantErr: false,
6363
},
6464
{
65-
testName: "Server group ID not found",
65+
testName: "Server group by Name not found",
6666
serverGroupFilter: &infrav1.ServerGroupFilter{Name: "test-server-group"},
6767
expect: func(m *mock.MockComputeClientMockRecorder) {
6868
m.ListServerGroups().Return(

pkg/cloud/services/compute/servergroup_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2018 The Kubernetes Authors.
2+
Copyright 2024 The Kubernetes Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)