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
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"`
}

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"`

// 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