Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1735728: Add description to operator user facing CRDs. #65

Merged
merged 2 commits into from Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions deploy/crds/sriovnetwork_v1_sriovnetwork_crd.yaml
Expand Up @@ -26,22 +26,30 @@ spec:
metadata:
type: object
spec:
description: Specification describing how a NetworkAttachmentDefinition
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we also change the file under manifests/4.2/manifests/4.2/sriov-network-operator-sriovnetwork.crd.yaml?
before this PR, they have same content.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Will do.

custom resource shall be defined for SR-IOV CNI plugin.
properties:
ipam:
description: IPAM configuration to be used for this network.
type: string
networkNamespace:
description: Namespace of the NetworkAttachmentDefinition custom resource
type: string
resourceName:
description: SRIOV Network device plugin endpoint resource name
type: string
spoofChk:
description: VF spoof check
type: boolean
trust:
description: VF trust mode
type: boolean
vlan:
description: VLAN ID to assign for the VF. Defaults to 0.
format: int64
type: integer
minimum: 0
maximum: 4096
minimum: 0
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I noticed the order of max/min vlan numbers have been changed many times, is there particular reason for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The CRD file is auto generated by operator-sdk. I don't think the order matters.

type: integer
required:
- resourceName
type: object
Expand Down
19 changes: 17 additions & 2 deletions deploy/crds/sriovnetwork_v1_sriovnetworknodepolicy_crd.yaml
Expand Up @@ -10,8 +10,6 @@ spec:
plural: sriovnetworknodepolicies
singular: sriovnetworknodepolicy
scope: Namespaced
subresources:
Copy link
Contributor

Choose a reason for hiding this comment

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

so nodepolicy status is never used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct

status: {}
validation:
openAPIV3Schema:
properties:
Expand All @@ -28,32 +26,44 @@ spec:
metadata:
type: object
spec:
description: Spec hold the intent of how this operator should configure
the SR-IoV on host.
properties:
deviceType:
description: The driver type for configured VFs. Allowed value "netdevice",
"vfio-pci". Defaults to netdevice.
enum:
- netdevice
- vfio-pci
type: string
isRdma:
description: RDMA mode. Defaults to false.
type: boolean
mtu:
description: MTU of VF
format: int64
maximum: 9000
minimum: 1
type: integer
nicSelector:
description: NicSelector selects the NICs to be configured
properties:
deviceID:
description: The device hex code of SR-IoV device.
type: string
pfNames:
description: Name of SR-IoV PF.
items:
type: string
type: array
rootDevices:
description: PCI address of SR-IoV PF.
items:
type: string
type: array
vendor:
description: The vendor hex code of SR-IoV device. Allowed value
"8086", "15b3".
enum:
- "8086"
- 15b3
Expand All @@ -62,17 +72,22 @@ spec:
nodeSelector:
additionalProperties:
type: string
description: NodeSelector selects the nodes to be configured
type: object
numVfs:
description: Number of VFs for each PF
format: int64
minimum: 0
type: integer
priority:
description: Priority of the policy, higher priority policies can override
lower ones.
format: int64
maximum: 99
minimum: 0
type: integer
resourceName:
description: SRIOV Network device plugin endpoint resource name
type: string
required:
- resourceName
Expand Down
12 changes: 10 additions & 2 deletions manifests/4.2/sriov-network-operator-sriovnetwork.crd.yaml
Expand Up @@ -26,22 +26,30 @@ spec:
metadata:
type: object
spec:
description: Specification describing how a NetworkAttachmentDefinition
custom resource shall be defined for SR-IOV CNI plugin.
properties:
ipam:
description: IPAM configuration to be used for this network.
type: string
networkNamespace:
description: Namespace of the NetworkAttachmentDefinition custom resource
type: string
resourceName:
description: SRIOV Network device plugin endpoint resource name
type: string
spoofChk:
description: VF spoof check
type: boolean
trust:
description: VF trust mode
type: boolean
vlan:
description: VLAN ID to assign for the VF. Defaults to 0.
format: int64
type: integer
minimum: 0
maximum: 4096
minimum: 0
type: integer
required:
- resourceName
type: object
Expand Down
Expand Up @@ -10,8 +10,6 @@ spec:
plural: sriovnetworknodepolicies
singular: sriovnetworknodepolicy
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
Expand All @@ -28,32 +26,44 @@ spec:
metadata:
type: object
spec:
description: Spec hold the intent of how this operator should configure
the SR-IoV on host.
properties:
deviceType:
description: The driver type for configured VFs. Allowed value "netdevice",
"vfio-pci". Defaults to netdevice.
enum:
- netdevice
- vfio-pci
type: string
isRdma:
description: RDMA mode. Defaults to false.
type: boolean
mtu:
description: MTU of VF
format: int64
maximum: 9000
minimum: 1
type: integer
nicSelector:
description: NicSelector selects the NICs to be configured
properties:
deviceID:
description: The device hex code of SR-IoV device.
type: string
pfNames:
description: Name of SR-IoV PF.
items:
type: string
type: array
rootDevices:
description: PCI address of SR-IoV PF.
items:
type: string
type: array
vendor:
description: The vendor hex code of SR-IoV device. Allowed value
"8086", "15b3".
enum:
- "8086"
- 15b3
Expand All @@ -62,17 +72,22 @@ spec:
nodeSelector:
additionalProperties:
type: string
description: NodeSelector selects the nodes to be configured
type: object
numVfs:
description: Number of VFs for each PF
format: int64
minimum: 0
type: integer
priority:
description: Priority of the policy, higher priority policies can override
lower ones.
format: int64
maximum: 99
minimum: 0
type: integer
resourceName:
description: SRIOV Network device plugin endpoint resource name
type: string
required:
- resourceName
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/k8s/v1/zz_generated.deepcopy.go

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

4 changes: 1 addition & 3 deletions pkg/apis/k8s/v1/zz_generated.openapi.go
@@ -1,6 +1,4 @@
// +build !ignore_autogenerated

// Code generated by openapi-gen. DO NOT EDIT.
// +build !

// This file was autogenerated by openapi-gen. Do not edit it manually!

Expand Down
12 changes: 7 additions & 5 deletions pkg/apis/sriovnetwork/v1/sriovnetwork_types.go
Expand Up @@ -10,21 +10,22 @@ import (
// SriovNetworkSpec defines the desired state of SriovNetwork
// +k8s:openapi-gen=true
type SriovNetworkSpec struct {
// Namespace of the NetworkAttachmentDefinition custom resource
NetworkNamespace string `json:"networkNamespace,omitempty"`
// SRIOV Network device plugin endpoint resource name
ResourceName string `json:"resourceName"`
//IPAM configuration to be used for this network.
IPAM string `json:"ipam,omitempty"`
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=4096
// VLAN ID to assign for the VF. Defaults to 0.
Vlan int `json:"vlan,omitempty"`
// VF spoof check
SpoofChk *bool `json:"spoofChk,omitempty"`
// VF trust mode
Trust *bool `json:"trust,omitempty"`
}

// // Ipam defines the desired state of IPAM
// type Ipam struct {
// Type string `json:"type,omitempty"`
// }

// SriovNetworkStatus defines the observed state of SriovNetwork
// +k8s:openapi-gen=true
type SriovNetworkStatus struct {
Expand All @@ -41,6 +42,7 @@ type SriovNetwork struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Specification describing how a NetworkAttachmentDefinition custom resource shall be defined for SR-IOV CNI plugin.
Spec SriovNetworkSpec `json:"spec,omitempty"`
Status SriovNetworkStatus `json:"status,omitempty"`
}
Expand Down
13 changes: 13 additions & 0 deletions pkg/apis/sriovnetwork/v1/sriovnetworknodepolicy_types.go
Expand Up @@ -10,29 +10,41 @@ import (
// SriovNetworkNodePolicySpec defines the desired state of SriovNetworkNodePolicy
// +k8s:openapi-gen=true
type SriovNetworkNodePolicySpec struct {
// SRIOV Network device plugin endpoint resource name
ResourceName string `json:"resourceName"`
// +kubebuilder:validation:MinItems=0
// +kubebuilder:validation:UniqueItems=true
// NodeSelector selects the nodes to be configured
NodeSelector map[string]string `json:"nodeSelector"`
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=99
// Priority of the policy, higher priority policies can override lower ones.
Priority int `json:"priority,omitempty"`
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=9000
// MTU of VF
Mtu int `json:"mtu,omitempty"`
// +kubebuilder:validation:Minimum=0
// Number of VFs for each PF
NumVfs int `json:"numVfs"`
// NicSelector selects the NICs to be configured
NicSelector SriovNetworkNicSelector `json:"nicSelector"`
// +kubebuilder:validation:Enum=netdevice,vfio-pci
// The driver type for configured VFs. Allowed value "netdevice", "vfio-pci". Defaults to netdevice.
DeviceType string `json:"deviceType,omitempty"`
// RDMA mode. Defaults to false.
IsRdma bool `json:"isRdma,omitempty"`
}

type SriovNetworkNicSelector struct {
// +kubebuilder:validation:Enum=8086,15b3
// The vendor hex code of SR-IoV device. Allowed value "8086", "15b3".
Vendor string `json:"vendor,omitempty"`
// The device hex code of SR-IoV device.
DeviceID string `json:"deviceID,omitempty"`
// PCI address of SR-IoV PF.
RootDevices []string `json:"rootDevices,omitempty"`
// Name of SR-IoV PF.
PfNames []string `json:"pfNames,omitempty"`
}

Expand All @@ -52,6 +64,7 @@ type SriovNetworkNodePolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec hold the intent of how this operator should configure the SR-IoV on host.
Spec SriovNetworkNodePolicySpec `json:"spec,omitempty"`
Status SriovNetworkNodePolicyStatus `json:"status,omitempty"`
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/sriovnetwork/v1/sriovnetworknodestate_types.go
Expand Up @@ -53,7 +53,7 @@ type SriovNetworkNodeStateStatus struct {

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// +kubebuilder:subresource:status
Copy link
Contributor

Choose a reason for hiding this comment

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

curious, does updating nodestate work without this tag before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a bug in operator-sdk, which makes errors the generated CRD. Therefore, we have to do manual change to the generated CRD.

// SriovNetworkNodeState is the Schema for the sriovnetworknodestates API
// +k8s:openapi-gen=true
type SriovNetworkNodeState struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/sriovnetwork/v1/zz_generated.deepcopy.go

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