Skip to content
Open
Show file tree
Hide file tree
Changes from all 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"
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
6 changes: 6 additions & 0 deletions api/v1alpha1/port_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ type PortResourceSpec struct {
// +kubebuilder:validation:MaxLength=36
// +optional
HostID string `json:"hostID,omitempty"`

// propagateUplinkStatus represents the uplink status propagation of
// the port.
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="propagateUplinkStatus is immutable"
PropagateUplinkStatus *bool `json:"propagateUplinkStatus,omitempty"`
Copy link
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.

}

type PortResourceStatus struct {
Expand Down
5 changes: 5 additions & 0 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.

8 changes: 8 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,14 @@ spec:
x-kubernetes-validations:
- message: projectRef is immutable
rule: self == oldSelf
propagateUplinkStatus:
description: |-
propagateUplinkStatus represents the uplink status propagation of
the port.
type: boolean
x-kubernetes-validations:
- message: propagateUplinkStatus is immutable
rule: self == oldSelf
securityGroupRefs:
description: |-
securityGroupRefs are the names of the security groups associated
Expand Down
13 changes: 7 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
5 changes: 4 additions & 1 deletion internal/controllers/port/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func (portStatusWriter) ApplyResourceStatus(log logr.Logger, osResource *osResou
WithNetworkID(osResource.NetworkID).
WithTags(osResource.Tags...).
WithSecurityGroups(osResource.SecurityGroups...).
WithPropagateUplinkStatus(osResource.PropagateUplinkStatus).
WithVNICType(osResource.VNICType).
WithPortSecurityEnabled(osResource.PortSecurityEnabled).
WithRevisionNumber(int64(osResource.RevisionNumber)).
Expand Down Expand Up @@ -104,5 +103,9 @@ func (portStatusWriter) ApplyResourceStatus(log logr.Logger, osResource *osResou
resourceStatus.WithFixedIPs(fixedIPs...)
}

if osResource.PropagateUplinkStatusPtr != nil {
resourceStatus.WithPropagateUplinkStatus(*osResource.PropagateUplinkStatusPtr)
}

statusApply.WithResource(resourceStatus)
}
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: false
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
name: port-create-minimal
adminStateUp: true
portSecurityEnabled: true
propagateUplinkStatus: false
propagateUplinkStatus: true
revisionNumber: 1
status: DOWN
vnicType: normal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ status:
description: Port from "create sriov" test
adminStateUp: true
portSecurityEnabled: false
propagateUplinkStatus: false
propagateUplinkStatus: true
status: DOWN
vnicType: direct
tags:
Expand All @@ -35,4 +35,4 @@ assertAll:
- celExpr: "port.status.resource.fixedIPs[0].subnetID == subnet.status.id"
- celExpr: "port.status.resource.fixedIPs[0].ip == '192.168.155.122'"
- celExpr: "!has(port.status.resource.allowedAddressPairs)"
- celExpr: "!has(port.status.resource.securityGroups)"
- celExpr: "!has(port.status.resource.securityGroups)"
4 changes: 2 additions & 2 deletions internal/controllers/port/tests/port-update/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ status:
name: port-update
adminStateUp: true
portSecurityEnabled: false
propagateUplinkStatus: false
propagateUplinkStatus: true
revisionNumber: 1
status: DOWN
vnicType: normal
Expand All @@ -53,7 +53,7 @@ status:
name: port-update-admin
adminStateUp: true
portSecurityEnabled: true
propagateUplinkStatus: false
propagateUplinkStatus: true
revisionNumber: 1
status: DOWN
vnicType: normal
Expand Down
3 changes: 1 addition & 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,6 @@ status:
description: port-update-updated
adminStateUp: true
portSecurityEnabled: true
propagateUplinkStatus: false
status: DOWN
vnicType: direct
allowedAddressPairs:
Expand Down Expand Up @@ -63,4 +62,4 @@ status:
reason: Success
- type: Progressing
status: "False"
reason: Success
reason: Success
4 changes: 2 additions & 2 deletions internal/controllers/port/tests/port-update/02-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ status:
name: port-update
adminStateUp: true
portSecurityEnabled: false
propagateUplinkStatus: false
propagateUplinkStatus: true
status: DOWN
vnicType: normal
conditions:
Expand All @@ -35,4 +35,4 @@ status:
- type: Progressing
message: OpenStack resource is up to date
status: "False"
reason: Success
reason: Success
9 changes: 9 additions & 0 deletions internal/osclients/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,19 @@ type NetworkExt struct {
provider.NetworkProviderExt
}

// NOTE(winiciusallan): This is a temporary extension struct to
// workaround a missing pointer on Gophercloud and must be
// removed in future releases.
// See https://github.com/gophercloud/gophercloud/issues/3605
type PortTmpExt struct {
PropagateUplinkStatusPtr *bool `json:"propagate_uplink_status,omitempty"`
}

type PortExt struct {
ports.Port
portsecurity.PortSecurityExt
portsbinding.PortsBindingExt
PortTmpExt //nolint:govet
Copy link
Collaborator

Choose a reason for hiding this comment

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

The nolint marker silenced the error with golangci-lint, however we're still getting an error when running go vet directly:

❯ make vet
go vet ./...
# github.com/k-orc/openstack-resource-controller/v2/internal/osclients
internal/osclients/networking.go:67:2: struct field PropagateUplinkStatusPtr repeats json tag "propagate_uplink_status" also at ../../../../../go/pkg/mod/github.com/gophe
rcloud/gophercloud/[email protected]/openstack/networking/v2/ports/results.go:115
make: *** [Makefile:111: vet] Error 1

I suggest removing the workaround since we don't allow mutability now.

Copy link
Contributor Author

@winiciusallan winiciusallan Jan 19, 2026

Choose a reason for hiding this comment

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

We need the workaround to be able to not return the field if the extension is not enabled.

edit: I didn't find any way to suppress vet warning. Do you have any suggestion?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it should work if you add the field at the top level instead of embedding:

Suggested change
PortTmpExt //nolint:govet
PropagateUplinkStatusPtr *bool `json:"propagate_uplink_status,omitempty"`

See this small test.

}

type NetworkClient interface {
Expand Down
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