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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.17.1
ENVTEST_VERSION ?= release-0.22
GOLANGCI_LINT_VERSION ?= v2.5.0
KAL_VERSION ?= v0.0.0-20250924094418-502783c08f9d
MOCKGEN_VERSION ?= v0.5.0
MOCKGEN_VERSION ?= v0.6.0
KUTTL_VERSION ?= v0.23.0
GOVULNCHECK_VERSION ?= v1.1.4
OPERATOR_SDK_VERSION ?= v1.41.1
Expand Down
8 changes: 8 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ resources:
kind: Subnet
path: github.com/k-orc/openstack-resource-controller/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
domain: k-orc.cloud
group: openstack
kind: Trunk
path: github.com/k-orc/openstack-resource-controller/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ kubectl delete -f $ORC_RELEASE
| server | | ◐ | ◐ |
| server group | | ✔ | ✔ |
| subnet | | ◐ | ◐ |
| trunk | | ✔ | ✔ |
| volume | | ◐ | ◐ |
| volume type | | ◐ | ◐ |
| domain | | ✔ | ✔ |
Expand Down
158 changes: 158 additions & 0 deletions api/v1alpha1/trunk_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*
Copyright 2025 The ORC Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

// TrunkFilter specifies a filter to select a trunk. At least one parameter must be specified.
// +kubebuilder:validation:MinProperties:=1
type TrunkFilter struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

// name of the existing resource
// +optional
Name *OpenStackName `json:"name,omitempty"`

// description of the existing resource
// +optional
Description *NeutronDescription `json:"description,omitempty"`

// portRef is a reference to the ORC Port which this trunk is associated with.
// +optional
PortRef *KubernetesNameRef `json:"portRef,omitempty"`

// projectRef is a reference to the ORC Project this resource is associated with.
// Typically, only used by admin.
// +optional
ProjectRef *KubernetesNameRef `json:"projectRef,omitempty"`

FilterByNeutronTags `json:",inline"`
}

// Subport represents a subport that will be attached to a trunk.
type Subport struct {
// portRef is a reference to the ORC Port which will be used as a subport.
// +required
PortRef KubernetesNameRef `json:"portRef"`

Check failure on line 46 in api/v1alpha1/trunk_type.go

View workflow job for this annotation

GitHub Actions / go-lint

requiredfields: field PortRef does not allow the zero value. It must have the omitempty tag. (kubeapilinter)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
PortRef KubernetesNameRef `json:"portRef"`
PortRef KubernetesNameRef `json:"portRef,omitempty"`


// segmentationType is the type of segmentation to use (e.g., "vlan").
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// segmentationType is the type of segmentation to use (e.g., "vlan").
// segmentationType is the type of segmentation to use.
// Possible values are "vlan" or "inherit".

If the only two supported types are VLAN and inherit, I think we can quote them here.

// +required
// +kubebuilder:validation:MaxLength=64
Copy link
Contributor

@winiciusallan winiciusallan Nov 25, 2025

Choose a reason for hiding this comment

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

Did you specify the max length as 64 for some specific reason? The Neutron schema defines the length as 32 bytes

https://github.com/openstack/neutron/blob/master/neutron/services/trunk/models.py#L71

SegmentationType string `json:"segmentationType"`

// segmentationID is the segmentation identifier (e.g., VLAN ID).
// +required
SegmentationID int32 `json:"segmentationID"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
SegmentationID int32 `json:"segmentationID"`
SegmentationID int16 `json:"segmentationID"`

I'd change to use integers with 16 bits, since in practice neutron only supports VLAN segmentation type (4094 possible IDs) for subports.

Wdyt?

To be honest, I don't know if guidelines restrict usage to only int32 and int64. Can you give an input, @mandre?

Copy link
Contributor

@winiciusallan winiciusallan Nov 26, 2025

Choose a reason for hiding this comment

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

sorry! kubeapi conventions says it MUST be used int32 or int64, so ORC may so.

ignore my suggestion :)

}

// SubportStatus represents the observed state of a subport.
type SubportStatus struct {
// portID is the ID of the port used as a subport.
// +kubebuilder:validation:MaxLength=1024
// +optional
PortID string `json:"portID,omitempty"`

// segmentationType is the type of segmentation used.
// +kubebuilder:validation:MaxLength=1024
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this should match the same validation in spec for this field.

// +optional
SegmentationType string `json:"segmentationType,omitempty"`

// segmentationID is the segmentation identifier.
// +optional
SegmentationID *int32 `json:"segmentationID,omitempty"`
}

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="portRef is immutable"
type TrunkResourceSpec struct {
// name is a human-readable name of the trunk. If not set, the object's name will be used.
// +optional
Name *OpenStackName `json:"name,omitempty"`

// description is a human-readable description for the resource.
// +optional
Description *NeutronDescription `json:"description,omitempty"`

// portRef is a reference to the ORC Port which will be used as the parent port for this trunk.
// +required
PortRef KubernetesNameRef `json:"portRef"`

Check failure on line 87 in api/v1alpha1/trunk_type.go

View workflow job for this annotation

GitHub Actions / go-lint

requiredfields: field PortRef does not allow the zero value. It must have the omitempty tag. (kubeapilinter)

// tags is a list of tags which will be applied to the trunk.
// +kubebuilder:validation:MaxItems:=64
// +listType=set
// +optional
Tags []NeutronTag `json:"tags,omitempty"`

// adminStateUp is the administrative state of the trunk, which is up (true) or down (false).
// +optional
AdminStateUp *bool `json:"adminStateUp,omitempty"`

// subports are the subports that will be attached to this trunk.
// +kubebuilder:validation:MaxItems:=128
// +listType=atomic
// +optional
Subports []Subport `json:"subports,omitempty"`

// projectRef is a reference to the ORC Project this resource is associated with.
// Typically, only used by admin.
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="projectRef is immutable"
ProjectRef *KubernetesNameRef `json:"projectRef,omitempty"`
}

type TrunkResourceStatus struct {
// name is the human-readable name of the resource. Might not be unique.
// +kubebuilder:validation:MaxLength=1024
// +optional
Name string `json:"name,omitempty"`

// description is a human-readable description for the resource.
// +kubebuilder:validation:MaxLength=1024
Copy link
Contributor

@winiciusallan winiciusallan Nov 25, 2025

Choose a reason for hiding this comment

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

Since we didn't set a max length for the description at spec, I think this could lead to an error - you define a description with 1025+ characters and the controller tries to write the status, but the kube-apiserver fails when validating.

Same for the other fields on this struct.

// +optional
Description string `json:"description,omitempty"`

// portID is the ID of the parent port.
// +kubebuilder:validation:MaxLength=1024
// +optional
PortID string `json:"portID,omitempty"`

// projectID is the project owner of the resource.
// +kubebuilder:validation:MaxLength=1024
// +optional
ProjectID string `json:"projectID,omitempty"`

// status indicates the current status of the resource.
// +kubebuilder:validation:MaxLength=1024
// +optional
Status string `json:"status,omitempty"`

// tags is the list of tags on the resource.
// +kubebuilder:validation:MaxItems=64
// +kubebuilder:validation:items:MaxLength=1024
// +listType=atomic
// +optional
Tags []string `json:"tags,omitempty"`

// adminStateUp is the administrative state of the trunk,
// which is up (true) or down (false).
// +optional
AdminStateUp *bool `json:"adminStateUp,omitempty"`

// subports is a list of subports attached to this trunk.
// +kubebuilder:validation:MaxItems=128
// +listType=atomic
// +optional
Subports []SubportStatus `json:"subports,omitempty"`

NeutronStatusMetadata `json:",inline"`
}

Check failure on line 158 in api/v1alpha1/trunk_type.go

View workflow job for this annotation

GitHub Actions / go-lint

File is not properly formatted (gofmt)
Loading
Loading