Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ jobs:
with:
enable_workaround_docker_io: 'false'
branch: ${{ matrix.openstack_version }}
enabled_services: "openstack-cli-server"
enabled_services: "openstack-cli-server,neutron-uplink-status-propagation"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Interesting, the dalmatian job still failed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep. I don't know the why, but there is two extensions - one for enable the field, and one for make it mutable. In dalmatian, the devstack configuration enable just the first one, so the jobs are failing on port-update test.

For reference, compare these two [1][2]

Since we're making this field immutable, this wouldn't be a problem for now.

[1] https://github.com/openstack/neutron/blob/master/devstack/lib/uplink_status_propagation
[2] https://github.com/openstack/neutron/blob/stable/2024.2/devstack/lib/uplink_status_propagation

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Gotcha, thanks for the explanation.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

So according to the commit in neutron, openstack/neutron@498be54 we'll need neutron-lib >= v3.16.0, which we don't have in Dalmatian. I believe we'll have to make the field immutable until we drop support for Dalmatian.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Gazpacho will be released in the end of march, so will take a little long to remove Dalmatian from the CI, it worth to merge this with this field as immutable indeed.

I'll re-changed things.

conf_overrides: |
enable_plugin neutron https://opendev.org/openstack/neutron.git ${{ matrix.openstack_version }}

- name: Deploy a Kind Cluster
uses: helm/kind-action@92086f6be054225fa813e0a4b13787fc9088faab
Expand Down
7 changes: 6 additions & 1 deletion api/v1alpha1/port_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ type PortResourceSpec struct {
// +kubebuilder:validation:MaxLength=36
// +optional
HostID string `json:"hostID,omitempty"`

// propagateUplinkStatus represents the uplink status propagation of
// the port.
// +optional
PropagateUplinkStatus *bool `json:"propagateUplinkStatus,omitempty"`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We've discussed this privately already, after you brought the issue to my attention: gophercloud implements the PropagateUplinkStatus in the response Port structure as a bool while it should really be a *bool with omitempty, and because of this we can't reliably know the status for PropagateUplinkStatus. I suggest that until the issue if fixed in gophercloud, we make that field immutable.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's been a while and I don't remember all of the discussion. From reading the PR comments again, I believe we're past the gophercloud limitation (thanks to custom unmarshalling) but we still need to make the field immutable because dalmatien doesn't support updating the field. If that's effectively the case, we should add that as a comment so we know when we can change that behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're absolutely right. I'll add this comment.

}

type PortResourceStatus struct {
Expand Down Expand Up @@ -266,7 +271,7 @@ type PortResourceStatus struct {
// propagateUplinkStatus represents the uplink status propagation of
// the port.
// +optional
PropagateUplinkStatus *bool `json:"propagateUplinkStatus,omitempty"`
PropagateUplinkStatus bool `json:"propagateUplinkStatus,omitempty"`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I believe we want to keep the pointer, don't we? This signifies that neutron doesn't have enable the uplink-status-propagation extension.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, we do. I'll change it together with making the field immutable.


// vnicType is the type of vNIC which this port is attached to.
// +kubebuilder:validation:MaxLength:=64
Expand Down
10 changes: 5 additions & 5 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions cmd/models-schema/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions config/crd/bases/openstack.k-orc.cloud_ports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ spec:
x-kubernetes-validations:
- message: projectRef is immutable
rule: self == oldSelf
propagateUplinkStatus:
description: |-
propagateUplinkStatus represents the uplink status propagation of
the port.
type: boolean
securityGroupRefs:
description: |-
securityGroupRefs are the names of the security groups associated
Expand Down
24 changes: 18 additions & 6 deletions internal/controllers/port/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,13 @@ func (actuator portActuator) CreateResource(ctx context.Context, obj *orcv1alpha
}

createOpts := ports.CreateOpts{
NetworkID: *network.Status.ID,
Name: getResourceName(obj),
Description: string(ptr.Deref(resource.Description, "")),
ProjectID: projectID,
AdminStateUp: resource.AdminStateUp,
MACAddress: resource.MACAddress,
NetworkID: *network.Status.ID,
Name: getResourceName(obj),
Description: string(ptr.Deref(resource.Description, "")),
ProjectID: projectID,
AdminStateUp: resource.AdminStateUp,
MACAddress: resource.MACAddress,
PropagateUplinkStatus: resource.PropagateUplinkStatus,
}

if len(resource.AllowedAddressPairs) > 0 {
Expand Down Expand Up @@ -345,6 +346,7 @@ func (actuator portActuator) updateResource(ctx context.Context, obj orcObjectPT
handleAllowedAddressPairsUpdate(baseUpdateOpts, resource, osResource)
handleSecurityGroupRefsUpdate(baseUpdateOpts, resource, osResource, secGroupMap)
handleAdminStateUpUpdate(baseUpdateOpts, resource, osResource)
handlePropagateUplinkStatusUpdate(baseUpdateOpts, resource, osResource)
updateOpts = baseUpdateOpts
}

Expand Down Expand Up @@ -530,6 +532,16 @@ func handleAdminStateUpUpdate(updateOpts *ports.UpdateOpts, resource *resourceSp
}
}

func handlePropagateUplinkStatusUpdate(updateOpts *ports.UpdateOpts, resource *resourceSpecT, osResource *osResourceT) {
// When this field is not defined, let's set this as `false` to
// avoid errors in environments where uplink-propagation-status
// extension isn't enabled.
propagateUplinkStatus := ptr.Deref(resource.PropagateUplinkStatus, false)
if propagateUplinkStatus != osResource.PropagateUplinkStatus {
updateOpts.PropagateUplinkStatus = &propagateUplinkStatus
}
}

type portHelperFactory struct{}

var _ helperFactory = portHelperFactory{}
Expand Down
28 changes: 28 additions & 0 deletions internal/controllers/port/actuator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,3 +435,31 @@ func TestHandleAdminStateUpUpdate(t *testing.T) {
})
}
}

func TestHandlePropagateUplinkStatusUpdate(t *testing.T) {
testCases := []struct {
name string
newValue *bool
existingValue bool
expectChange bool
}{
{name: "Set the same value as the existing one", newValue: ptr.To(true), existingValue: true, expectChange: false},
{name: "Enabled when was disabled", newValue: ptr.To(true), existingValue: false, expectChange: true},
{name: "Disable if it is not defined on spec", newValue: nil, existingValue: true, expectChange: true},
}

for _, tt := range testCases {
t.Run(tt.name, func(t *testing.T) {
resource := &orcv1alpha1.PortResourceSpec{PropagateUplinkStatus: tt.newValue}
osResource := &osclients.PortExt{Port: ports.Port{PropagateUplinkStatus: tt.existingValue}}
updateOpts := &ports.UpdateOpts{}

handlePropagateUplinkStatusUpdate(updateOpts, resource, osResource)

got, _ := needsUpdate(updateOpts)
if got != tt.expectChange {
t.Errorf("expected needsUpdate=%v, got %v", tt.expectChange, got)
}
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ status:
vnicType: macvtap
macAddress: fa:16:3e:23:fd:d7
hostID: devstack
propagateUplinkStatus: true
tags:
- tag1
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ spec:
projectRef: port-create-full
macAddress: fa:16:3e:23:fd:d7
hostID: devstack
propagateUplinkStatus: true
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ status:
adminStateUp: true
portSecurityEnabled: true
propagateUplinkStatus: false
revisionNumber: 1
revisionNumber: 2
status: DOWN
vnicType: normal
---
Expand Down
6 changes: 4 additions & 2 deletions internal/controllers/port/tests/port-update/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ status:
adminStateUp: true
portSecurityEnabled: false
propagateUplinkStatus: false
revisionNumber: 1
# The revisionNumber has increased to enforce `propagateUplinkStatus` default
# value.
revisionNumber: 2
status: DOWN
vnicType: normal
conditions:
Expand All @@ -54,7 +56,7 @@ status:
adminStateUp: true
portSecurityEnabled: true
propagateUplinkStatus: false
revisionNumber: 1
revisionNumber: 2
status: DOWN
vnicType: normal
conditions:
Expand Down
4 changes: 2 additions & 2 deletions internal/controllers/port/tests/port-update/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ status:
description: port-update-updated
adminStateUp: true
portSecurityEnabled: true
propagateUplinkStatus: false
propagateUplinkStatus: true
status: DOWN
vnicType: direct
allowedAddressPairs:
Expand Down Expand Up @@ -63,4 +63,4 @@ status:
reason: Success
- type: Progressing
status: "False"
reason: Success
reason: Success
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
- tag1
vnicType: direct
portSecurity: Enabled
propagateUplinkStatus: true
---
apiVersion: openstack.k-orc.cloud/v1alpha1
kind: Port
Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/port/tests/port-update/02-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ status:
- type: Progressing
message: OpenStack resource is up to date
status: "False"
reason: Success
reason: Success
35 changes: 22 additions & 13 deletions pkg/clients/applyconfiguration/api/v1alpha1/portresourcespec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/clients/applyconfiguration/internal/internal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions website/docs/crd-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2172,6 +2172,7 @@ _Appears in:_
| `projectRef` _[KubernetesNameRef](#kubernetesnameref)_ | projectRef is a reference to the ORC Project this resource is associated with.<br />Typically, only used by admin. | | MaxLength: 253 <br />MinLength: 1 <br /> |
| `macAddress` _string_ | macAddress is the MAC address of the port. | | MaxLength: 32 <br /> |
| `hostID` _string_ | hostID is the ID of host where the port resides. | | MaxLength: 36 <br /> |
| `propagateUplinkStatus` _boolean_ | propagateUplinkStatus represents the uplink status propagation of<br />the port. | | |


#### PortResourceStatus
Expand Down
Loading