From 52339bfc8aeea1c85b8867a8ffbb244c18200bd5 Mon Sep 17 00:00:00 2001 From: sp-yduck Date: Sat, 1 Feb 2025 07:40:44 +0000 Subject: [PATCH 1/4] fix nil pointer on node_resource plugin --- cloud/scheduler/plugins/noderesource/node_resrouce.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cloud/scheduler/plugins/noderesource/node_resrouce.go b/cloud/scheduler/plugins/noderesource/node_resrouce.go index 07505b2..2cb280f 100644 --- a/cloud/scheduler/plugins/noderesource/node_resrouce.go +++ b/cloud/scheduler/plugins/noderesource/node_resrouce.go @@ -28,5 +28,7 @@ func (pl *NodeResource) Score(ctx context.Context, state *framework.CycleState, maxMem := nodeInfo.Node().MaxMem u := cpu / float32(maxCPU) * float32(mem/maxMem) score := int64(1 / u) - return score, nil + status := framework.NewStatus() + status.SetCode(1) + return score, status } From 4533db2ed62f4cb4cce18efbf871e78cf72d10e4 Mon Sep 17 00:00:00 2001 From: sp-yduck Date: Sat, 1 Feb 2025 08:17:36 +0000 Subject: [PATCH 2/4] update controller tools version to v0.17.1 --- Makefile | 2 +- api/v1beta1/zz_generated.deepcopy.go | 1 - ...ture.cluster.x-k8s.io_proxmoxclusters.yaml | 72 +++--- ...ture.cluster.x-k8s.io_proxmoxmachines.yaml | 206 ++++++++++-------- ...ster.x-k8s.io_proxmoxmachinetemplates.yaml | 197 +++++++++-------- config/rbac/role.yaml | 35 +-- go.sum | 2 - 7 files changed, 255 insertions(+), 260 deletions(-) diff --git a/Makefile b/Makefile index 6dc98a3..5038b5c 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ KIND ?= $(LOCALBIN)/kind ## Tool Versions KUSTOMIZE_VERSION ?= v5.0.0 -CONTROLLER_TOOLS_VERSION ?= v0.11.3 +CONTROLLER_TOOLS_VERSION ?= v0.17.1 ENVSUBST_VER ?= v1.4.2 KUBECTL_VER := v1.25.10 TILT_VER := 0.33.6 diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index c523ac1..b297ecd 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated /* Copyright 2023 Teppei Sudo. diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml index 97c36bb..8f2658d 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.3 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.17.1 name: proxmoxclusters.infrastructure.cluster.x-k8s.io spec: group: infrastructure.cluster.x-k8s.io @@ -38,14 +37,19 @@ spec: description: ProxmoxCluster is the Schema for the proxmoxclusters API properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object @@ -79,10 +83,14 @@ spec: proxmox login secrets properties: name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names type: string namespace: - description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' + description: |- + Namespace of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ type: string required: - name @@ -112,37 +120,37 @@ spec: operational state. properties: lastTransitionTime: - description: Last time the condition transitioned from one status - to another. This should be when the underlying condition changed. - If that is not known, then using the time when the API field - changed is acceptable. + description: |- + Last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. format: date-time type: string message: - description: A human readable message indicating details about - the transition. This field may be empty. + description: |- + A human readable message indicating details about the transition. + This field may be empty. type: string reason: - description: The reason for the condition's last transition - in CamelCase. The specific API may choose whether or not this - field is considered a guaranteed API. This field may not be - empty. + description: |- + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may not be empty. type: string severity: - description: Severity provides an explicit classification of - Reason code, so the users or machines can immediately understand - the current situation and act accordingly. The Severity field - MUST be set only when Status=False. + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. type: string status: description: Status of the condition, one of True, False, Unknown. type: string type: - description: Type of condition in CamelCase or in foo.example.com/CamelCase. - Many .condition.type values are consistent across resources - like Available, but because arbitrary conditions can be useful - (see .node.status.conditions), the ability to deconflict is - important. + description: |- + Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. type: string required: - lastTransitionTime @@ -152,9 +160,9 @@ spec: type: array failureDomains: additionalProperties: - description: FailureDomainSpec is the Schema for Cluster API failure - domains. It allows controllers to understand how many failure - domains a cluster can optionally span across. + description: |- + FailureDomainSpec is the Schema for Cluster API failure domains. + It allows controllers to understand how many failure domains a cluster can optionally span across. properties: attributes: additionalProperties: diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachines.yaml index 1c8ea51..a3bd9c6 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachines.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.3 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.17.1 name: proxmoxmachines.infrastructure.cluster.x-k8s.io spec: group: infrastructure.cluster.x-k8s.io @@ -53,14 +52,19 @@ spec: description: ProxmoxMachine is the Schema for the proxmoxmachines API properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object @@ -68,8 +72,9 @@ spec: description: ProxmoxMachineSpec defines the desired state of ProxmoxMachine properties: cloudInit: - description: CloudInit defines options related to the bootstrapping - systems where CloudInit is used. + description: |- + CloudInit defines options related to the bootstrapping systems where + CloudInit is used. properties: user: properties: @@ -230,8 +235,9 @@ spec: description: Hardware properties: bios: - description: Select BIOS implementation. Defaults to seabios. - seabios or ovmf. Defaults to seabios. + description: |- + Select BIOS implementation. Defaults to seabios. seabios or ovmf. + Defaults to seabios. enum: - seabios - ovmf @@ -242,9 +248,9 @@ spec: minimum: 1 type: integer cpuLimit: - description: Limit of CPU usage. If the computer has 2 CPUs, it - has total of '2' CPU time. Value '0' indicates no CPU limit. - Defaults to 0. + description: |- + Limit of CPU usage. If the computer has 2 CPUs, it has total of '2' CPU time. + Value '0' indicates no CPU limit. Defaults to 0. minimum: 0 type: integer cpuType: @@ -265,7 +271,9 @@ spec: bridge: vmbr0 firewall: true model: virtio - description: 'network devices to do: multiple devices' + description: |- + network devices + to do: multiple devices properties: bridge: default: vmbr0 @@ -312,9 +320,11 @@ spec: description: Image is the image to be provisioned properties: checksum: - description: Checksum Always better to specify checksum otherwise - cappx will download same image for every time. If checksum is - specified, cappx will try to avoid downloading existing image. + description: |- + Checksum + Always better to specify checksum otherwise cappx will download + same image for every time. If checksum is specified, cappx will try + to avoid downloading existing image. type: string checksumType: description: ChecksumType @@ -325,8 +335,9 @@ spec: - md5sum type: string url: - description: URL is a location of an image to deploy. supported - formats are iso/qcow2/qed/raw/vdi/vpc/vmdk. + description: |- + URL is a location of an image to deploy. + supported formats are iso/qcow2/qed/raw/vdi/vpc/vmdk. pattern: .*\.(iso|img|qcow2|qed|raw|vdi|vpc|vmdk)$ type: string required: @@ -381,9 +392,9 @@ spec: minimum: 0 type: integer description: - description: Description for the VM. Shown in the web-interface - VM's summary. This is saved as comment inside the configuration - file. + description: |- + Description for the VM. Shown in the web-interface VM's summary. + This is saved as comment inside the configuration file. type: string hugePages: description: enable/disable hugepages memory. 0 or 2 or 1024. @@ -394,18 +405,18 @@ spec: - 1024 type: integer keepHugePages: - description: Use together with hugepages. If enabled, hugepages - will not not be deleted after VM shutdown and can be used for - subsequent starts. Defaults to false. + description: |- + Use together with hugepages. If enabled, hugepages will not not be deleted + after VM shutdown and can be used for subsequent starts. Defaults to false. type: boolean kvm: description: Enable/disable KVM hardware virtualization. Defaults to true. type: boolean localTime: - description: Set the real time clock (RTC) to local time. This - is enabled by default if the `ostype` indicates a Microsoft - Windows OS. + description: |- + Set the real time clock (RTC) to local time. + This is enabled by default if the `ostype` indicates a Microsoft Windows OS. type: boolean lock: description: Lock/unlock the VM. @@ -428,8 +439,9 @@ spec: bootup. type: boolean osType: - description: Specify guest operating system. This is used to enable - special optimization/features for specific operating systems. + description: |- + Specify guest operating system. This is used to enable special + optimization/features for specific operating systems. enum: - other - wxp @@ -446,30 +458,32 @@ spec: - solaris type: string protection: - description: Sets the protection flag of the VM. This will disable - the remove VM and remove disk operations. Defaults to false. + description: |- + Sets the protection flag of the VM. + This will disable the remove VM and remove disk operations. + Defaults to false. type: boolean reboot: - description: Allow reboot. If set to 'false' the VM exit on reboot. + description: |- + Allow reboot. If set to 'false' the VM exit on reboot. Defaults to true. type: boolean shares: - description: Amount of memory shares for auto-ballooning. The - larger the number is, the more memory this VM gets. Number is - relative to weights of all other running VMs. Using zero disables - auto-ballooning. Auto-ballooning is done by pvestatd. 0 ~ 5000. - Defaults to 1000. + description: |- + Amount of memory shares for auto-ballooning. The larger the number is, the more memory this VM gets. + Number is relative to weights of all other running VMs. Using zero disables auto-ballooning. + Auto-ballooning is done by pvestatd. 0 ~ 5000. Defaults to 1000. maximum: 5000 minimum: 0 type: integer tablet: - description: Enable/disable the USB tablet device. This device - is usually needed to allow absolute mouse positioning with VNC. - Else the mouse runs out of sync with normal VNC clients. If - you're running lots of console-only guests on one host, you - may consider disabling this to save some context switches. This - is turned off by default if you use spice (`qm set --vga - qxl`). Defaults to true. + description: |- + Enable/disable the USB tablet device. This device is usually needed to allow + absolute mouse positioning with VNC. Else the mouse runs out of sync with normal VNC clients. + If you're running lots of console-only guests on one host, + you may consider disabling this to save some context switches. + This is turned off by default if you use spice (`qm set --vga qxl`). + Defaults to true. type: boolean tags: description: Tags of the VM. This is only meta information. @@ -488,17 +502,14 @@ spec: minimum: 0 type: integer vmGenerationID: - description: 'The VM generation ID (vmgenid) device exposes a - 128-bit integer value identifier to the guest OS. This allows - to notify the guest operating system when the virtual machine - is executed with a different configuration (e.g. snapshot execution - or creation from a template). The guest operating system notices - the change, and is then able to react as appropriate by marking - its copies of distributed databases as dirty, re-initializing - its random number generator, etc. Note that auto-creation only - works when done through API/CLI create or update methods, but - not when manually editing the config file. regex: (?:[a-fA-F0-9]{8}(?:-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}|[01]). - Defaults to 1 (autogenerated)' + description: |- + The VM generation ID (vmgenid) device exposes a 128-bit integer value identifier to the guest OS. + This allows to notify the guest operating system when the virtual machine is executed with a different configuration + (e.g. snapshot execution or creation from a template). + The guest operating system notices the change, and is then able to react as appropriate by marking its copies of distributed databases as dirty, + re-initializing its random number generator, etc. + Note that auto-creation only works when done through API/CLI create or update methods, but not when manually editing the config file. + regex: (?:[a-fA-F0-9]{8}(?:-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}|[01]). Defaults to 1 (autogenerated) pattern: (?:[a-fA-F0-9]{8}(?:-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}|[01]) type: string type: object @@ -506,9 +517,10 @@ spec: description: ProviderID type: string storage: - description: Storage is name of proxmox storage used by this node. - The storage must support "images(VM Disks)" type of content. cappx - will use random storage if empty + description: |- + Storage is name of proxmox storage used by this node. + The storage must support "images(VM Disks)" type of content. + cappx will use random storage if empty type: string vmID: description: VMID is proxmox qemu's id @@ -545,37 +557,37 @@ spec: operational state. properties: lastTransitionTime: - description: Last time the condition transitioned from one status - to another. This should be when the underlying condition changed. - If that is not known, then using the time when the API field - changed is acceptable. + description: |- + Last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. format: date-time type: string message: - description: A human readable message indicating details about - the transition. This field may be empty. + description: |- + A human readable message indicating details about the transition. + This field may be empty. type: string reason: - description: The reason for the condition's last transition - in CamelCase. The specific API may choose whether or not this - field is considered a guaranteed API. This field may not be - empty. + description: |- + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may not be empty. type: string severity: - description: Severity provides an explicit classification of - Reason code, so the users or machines can immediately understand - the current situation and act accordingly. The Severity field - MUST be set only when Status=False. + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. type: string status: description: Status of the condition, one of True, False, Unknown. type: string type: - description: Type of condition in CamelCase or in foo.example.com/CamelCase. - Many .condition.type values are consistent across resources - like Available, but because arbitrary conditions can be useful - (see .node.status.conditions), the ability to deconflict is - important. + description: |- + Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. type: string required: - lastTransitionTime @@ -601,8 +613,10 @@ spec: description: Virtual processor architecture. Defaults to the host. type: string args: - description: 'Arbitrary arguments passed to kvm, for example: - args: -no-reboot -no-hpet NOTE: this option is for experts only.' + description: |- + Arbitrary arguments passed to kvm, for example: + args: -no-reboot -no-hpet + NOTE: this option is for experts only. type: string audio0: description: Configure a audio device, useful in combination with @@ -629,15 +643,15 @@ spec: automatically generated ones at start.' type: string cipassword: - description: 'cloud-init: Password to assign the user. Using this - is generally not recommended. Use ssh keys instead. Also note - that older cloud-init versions do not support hashed passwords.' + description: |- + cloud-init: Password to assign the user. Using this is generally not recommended. + Use ssh keys instead. Also note that older cloud-init versions do not support hashed passwords. type: string citype: - description: Specifies the cloud-init configuration format. The - default depends on the configured operating system type (`ostype`. - We use the `nocloud` format for Linux, and `configdrive2` for - windows. + description: |- + Specifies the cloud-init configuration format. + The default depends on the configured operating system type (`ostype`. + We use the `nocloud` format for Linux, and `configdrive2` for windows. type: string ciuser: description: 'cloud-init: User name to change ssh keys and password @@ -650,15 +664,15 @@ spec: description: emulated cpu type type: string cpulimit: - description: 'Limit of CPU usage. NOTE: If the computer has 2 - CPUs, it has total of ''2'' CPU time. Value ''0'' indicates - no CPU limit.' + description: |- + Limit of CPU usage. + NOTE: If the computer has 2 CPUs, it has total of '2' CPU time. Value '0' indicates no CPU limit. type: integer cpuunits: - description: CPU weight for a VM. Argument is used in the kernel - fair scheduler. The larger the number is, the more CPU time - this VM gets. Number is relative to weights of all the other - running VMs. + description: |- + CPU weight for a VM. Argument is used in the kernel fair scheduler. + The larger the number is, the more CPU time this VM gets. + Number is relative to weights of all the other running VMs. type: integer description: type: string diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachinetemplates.yaml index 312207d..2c20b26 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxmachinetemplates.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.3 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.17.1 name: proxmoxmachinetemplates.infrastructure.cluster.x-k8s.io spec: group: infrastructure.cluster.x-k8s.io @@ -22,14 +21,19 @@ spec: API properties: apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds type: string metadata: type: object @@ -39,53 +43,55 @@ spec: template: properties: metadata.omitempty: - description: "ObjectMeta is metadata that all persisted resources - must have, which includes all objects users must create. This - is a copy of customizable fields from metav1.ObjectMeta. \n - ObjectMeta is embedded in `Machine.Spec`, `MachineDeployment.Template` - and `MachineSet.Template`, which are not top-level Kubernetes - objects. Given that metav1.ObjectMeta has lots of special cases - and read-only fields which end up in the generated CRD validation, - having it as a subset simplifies the API and some issues that - can impact user experience. \n During the [upgrade to controller-tools@v2](https://github.com/kubernetes-sigs/cluster-api/pull/1054) - for v1alpha2, we noticed a failure would occur running Cluster - API test suite against the new CRDs, specifically `spec.metadata.creationTimestamp - in body must be of type string: \"null\"`. The investigation - showed that `controller-tools@v2` behaves differently than its - previous version when handling types from [metav1](k8s.io/apimachinery/pkg/apis/meta/v1) - package. \n In more details, we found that embedded (non-top - level) types that embedded `metav1.ObjectMeta` had validation - properties, including for `creationTimestamp` (metav1.Time). - The `metav1.Time` type specifies a custom json marshaller that, - when IsZero() is true, returns `null` which breaks validation - because the field isn't marked as nullable. \n In future versions, - controller-tools@v2 might allow overriding the type and validation - for embedded types. When that happens, this hack should be revisited." + description: |- + ObjectMeta is metadata that all persisted resources must have, which includes all objects + users must create. This is a copy of customizable fields from metav1.ObjectMeta. + + ObjectMeta is embedded in `Machine.Spec`, `MachineDeployment.Template` and `MachineSet.Template`, + which are not top-level Kubernetes objects. Given that metav1.ObjectMeta has lots of special cases + and read-only fields which end up in the generated CRD validation, having it as a subset simplifies + the API and some issues that can impact user experience. + + During the [upgrade to controller-tools@v2](https://github.com/kubernetes-sigs/cluster-api/pull/1054) + for v1alpha2, we noticed a failure would occur running Cluster API test suite against the new CRDs, + specifically `spec.metadata.creationTimestamp in body must be of type string: "null"`. + The investigation showed that `controller-tools@v2` behaves differently than its previous version + when handling types from [metav1](k8s.io/apimachinery/pkg/apis/meta/v1) package. + + In more details, we found that embedded (non-top level) types that embedded `metav1.ObjectMeta` + had validation properties, including for `creationTimestamp` (metav1.Time). + The `metav1.Time` type specifies a custom json marshaller that, when IsZero() is true, returns `null` + which breaks validation because the field isn't marked as nullable. + + In future versions, controller-tools@v2 might allow overriding the type and validation for embedded + types. When that happens, this hack should be revisited. properties: annotations: additionalProperties: type: string - description: 'Annotations is an unstructured key value map - stored with a resource that may be set by external tools - to store and retrieve arbitrary metadata. They are not queryable - and should be preserved when modifying objects. More info: - http://kubernetes.io/docs/user-guide/annotations' + description: |- + Annotations is an unstructured key value map stored with a resource that may be + set by external tools to store and retrieve arbitrary metadata. They are not + queryable and should be preserved when modifying objects. + More info: http://kubernetes.io/docs/user-guide/annotations type: object labels: additionalProperties: type: string - description: 'Map of string keys and values that can be used - to organize and categorize (scope and select) objects. May - match selectors of replication controllers and services. - More info: http://kubernetes.io/docs/user-guide/labels' + description: |- + Map of string keys and values that can be used to organize and categorize + (scope and select) objects. May match selectors of replication controllers + and services. + More info: http://kubernetes.io/docs/user-guide/labels type: object type: object spec: description: ProxmoxMachineSpec defines the desired state of ProxmoxMachine properties: cloudInit: - description: CloudInit defines options related to the bootstrapping - systems where CloudInit is used. + description: |- + CloudInit defines options related to the bootstrapping systems where + CloudInit is used. properties: user: properties: @@ -247,8 +253,9 @@ spec: description: Hardware properties: bios: - description: Select BIOS implementation. Defaults to seabios. - seabios or ovmf. Defaults to seabios. + description: |- + Select BIOS implementation. Defaults to seabios. seabios or ovmf. + Defaults to seabios. enum: - seabios - ovmf @@ -259,9 +266,9 @@ spec: minimum: 1 type: integer cpuLimit: - description: Limit of CPU usage. If the computer has 2 - CPUs, it has total of '2' CPU time. Value '0' indicates - no CPU limit. Defaults to 0. + description: |- + Limit of CPU usage. If the computer has 2 CPUs, it has total of '2' CPU time. + Value '0' indicates no CPU limit. Defaults to 0. minimum: 0 type: integer cpuType: @@ -282,7 +289,9 @@ spec: bridge: vmbr0 firewall: true model: virtio - description: 'network devices to do: multiple devices' + description: |- + network devices + to do: multiple devices properties: bridge: default: vmbr0 @@ -329,10 +338,11 @@ spec: description: Image is the image to be provisioned properties: checksum: - description: Checksum Always better to specify checksum - otherwise cappx will download same image for every time. - If checksum is specified, cappx will try to avoid downloading - existing image. + description: |- + Checksum + Always better to specify checksum otherwise cappx will download + same image for every time. If checksum is specified, cappx will try + to avoid downloading existing image. type: string checksumType: description: ChecksumType @@ -343,7 +353,8 @@ spec: - md5sum type: string url: - description: URL is a location of an image to deploy. + description: |- + URL is a location of an image to deploy. supported formats are iso/qcow2/qed/raw/vdi/vpc/vmdk. pattern: .*\.(iso|img|qcow2|qed|raw|vdi|vpc|vmdk)$ type: string @@ -399,9 +410,9 @@ spec: minimum: 0 type: integer description: - description: Description for the VM. Shown in the web-interface - VM's summary. This is saved as comment inside the configuration - file. + description: |- + Description for the VM. Shown in the web-interface VM's summary. + This is saved as comment inside the configuration file. type: string hugePages: description: enable/disable hugepages memory. 0 or 2 or @@ -412,18 +423,18 @@ spec: - 1024 type: integer keepHugePages: - description: Use together with hugepages. If enabled, - hugepages will not not be deleted after VM shutdown - and can be used for subsequent starts. Defaults to false. + description: |- + Use together with hugepages. If enabled, hugepages will not not be deleted + after VM shutdown and can be used for subsequent starts. Defaults to false. type: boolean kvm: description: Enable/disable KVM hardware virtualization. Defaults to true. type: boolean localTime: - description: Set the real time clock (RTC) to local time. - This is enabled by default if the `ostype` indicates - a Microsoft Windows OS. + description: |- + Set the real time clock (RTC) to local time. + This is enabled by default if the `ostype` indicates a Microsoft Windows OS. type: boolean lock: description: Lock/unlock the VM. @@ -446,9 +457,9 @@ spec: system bootup. type: boolean osType: - description: Specify guest operating system. This is used - to enable special optimization/features for specific - operating systems. + description: |- + Specify guest operating system. This is used to enable special + optimization/features for specific operating systems. enum: - other - wxp @@ -465,31 +476,31 @@ spec: - solaris type: string protection: - description: Sets the protection flag of the VM. This - will disable the remove VM and remove disk operations. + description: |- + Sets the protection flag of the VM. + This will disable the remove VM and remove disk operations. Defaults to false. type: boolean reboot: - description: Allow reboot. If set to 'false' the VM exit - on reboot. Defaults to true. + description: |- + Allow reboot. If set to 'false' the VM exit on reboot. + Defaults to true. type: boolean shares: - description: Amount of memory shares for auto-ballooning. - The larger the number is, the more memory this VM gets. - Number is relative to weights of all other running VMs. - Using zero disables auto-ballooning. Auto-ballooning - is done by pvestatd. 0 ~ 5000. Defaults to 1000. + description: |- + Amount of memory shares for auto-ballooning. The larger the number is, the more memory this VM gets. + Number is relative to weights of all other running VMs. Using zero disables auto-ballooning. + Auto-ballooning is done by pvestatd. 0 ~ 5000. Defaults to 1000. maximum: 5000 minimum: 0 type: integer tablet: - description: Enable/disable the USB tablet device. This - device is usually needed to allow absolute mouse positioning - with VNC. Else the mouse runs out of sync with normal - VNC clients. If you're running lots of console-only - guests on one host, you may consider disabling this - to save some context switches. This is turned off by - default if you use spice (`qm set --vga qxl`). + description: |- + Enable/disable the USB tablet device. This device is usually needed to allow + absolute mouse positioning with VNC. Else the mouse runs out of sync with normal VNC clients. + If you're running lots of console-only guests on one host, + you may consider disabling this to save some context switches. + This is turned off by default if you use spice (`qm set --vga qxl`). Defaults to true. type: boolean tags: @@ -510,19 +521,14 @@ spec: minimum: 0 type: integer vmGenerationID: - description: 'The VM generation ID (vmgenid) device exposes - a 128-bit integer value identifier to the guest OS. - This allows to notify the guest operating system when - the virtual machine is executed with a different configuration + description: |- + The VM generation ID (vmgenid) device exposes a 128-bit integer value identifier to the guest OS. + This allows to notify the guest operating system when the virtual machine is executed with a different configuration (e.g. snapshot execution or creation from a template). - The guest operating system notices the change, and is - then able to react as appropriate by marking its copies - of distributed databases as dirty, re-initializing its - random number generator, etc. Note that auto-creation - only works when done through API/CLI create or update - methods, but not when manually editing the config file. - regex: (?:[a-fA-F0-9]{8}(?:-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}|[01]). - Defaults to 1 (autogenerated)' + The guest operating system notices the change, and is then able to react as appropriate by marking its copies of distributed databases as dirty, + re-initializing its random number generator, etc. + Note that auto-creation only works when done through API/CLI create or update methods, but not when manually editing the config file. + regex: (?:[a-fA-F0-9]{8}(?:-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}|[01]). Defaults to 1 (autogenerated) pattern: (?:[a-fA-F0-9]{8}(?:-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}|[01]) type: string type: object @@ -530,9 +536,10 @@ spec: description: ProviderID type: string storage: - description: Storage is name of proxmox storage used by this - node. The storage must support "images(VM Disks)" type of - content. cappx will use random storage if empty + description: |- + Storage is name of proxmox storage used by this node. + The storage must support "images(VM Disks)" type of content. + cappx will use random storage if empty type: string vmID: description: VMID is proxmox qemu's id diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index e0d5185..bbfc606 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -2,7 +2,6 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - creationTimestamp: null name: manager-role rules: - apiGroups: @@ -31,13 +30,6 @@ rules: resources: - clusters - clusters/status - verbs: - - get - - list - - watch -- apiGroups: - - cluster.x-k8s.io - resources: - machines - machines/status verbs: @@ -48,31 +40,6 @@ rules: - infrastructure.cluster.x-k8s.io resources: - proxmoxclusters - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - infrastructure.cluster.x-k8s.io - resources: - - proxmoxclusters/finalizers - verbs: - - update -- apiGroups: - - infrastructure.cluster.x-k8s.io - resources: - - proxmoxclusters/status - verbs: - - get - - patch - - update -- apiGroups: - - infrastructure.cluster.x-k8s.io - resources: - proxmoxmachines verbs: - create @@ -85,12 +52,14 @@ rules: - apiGroups: - infrastructure.cluster.x-k8s.io resources: + - proxmoxclusters/finalizers - proxmoxmachines/finalizers verbs: - update - apiGroups: - infrastructure.cluster.x-k8s.io resources: + - proxmoxclusters/status - proxmoxmachines/status verbs: - get diff --git a/go.sum b/go.sum index 063f845..1d4c4bf 100644 --- a/go.sum +++ b/go.sum @@ -301,8 +301,6 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1 github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/k8s-proxmox/proxmox-go v0.0.0-alpha25 h1:vPkQUj+1ZsJNhxFktsWB9+efgGIWJ8VmgSgq9OJKxPI= -github.com/k8s-proxmox/proxmox-go v0.0.0-alpha25/go.mod h1:ZSAdc9vVAEcIhbNkZxURWTY+k59cXUy9mswp5ofMM40= github.com/k8s-proxmox/proxmox-go v0.0.0-alpha28 h1:h0PwVITcljicpXCmMcOyXeXWhkVeYBiK4F2A/Ch5dxg= github.com/k8s-proxmox/proxmox-go v0.0.0-alpha28/go.mod h1:ZSAdc9vVAEcIhbNkZxURWTY+k59cXUy9mswp5ofMM40= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= From bbfd54689b3794e4a12b96034af9d8b73655e192 Mon Sep 17 00:00:00 2001 From: sp-yduck Date: Sat, 1 Feb 2025 08:21:53 +0000 Subject: [PATCH 3/4] format --- cloud/scheduler/queue/queue_test.go | 4 +- cloud/scope/providerid.go | 83 +++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 cloud/scope/providerid.go diff --git a/cloud/scheduler/queue/queue_test.go b/cloud/scheduler/queue/queue_test.go index 0c34838..7923148 100644 --- a/cloud/scheduler/queue/queue_test.go +++ b/cloud/scheduler/queue/queue_test.go @@ -5,10 +5,10 @@ import ( "testing" "time" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" "github.com/k8s-proxmox/cluster-api-provider-proxmox/cloud/scheduler/queue" "github.com/k8s-proxmox/proxmox-go/api" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" ) func TestQueue(t *testing.T) { diff --git a/cloud/scope/providerid.go b/cloud/scope/providerid.go new file mode 100644 index 0000000..cf6be17 --- /dev/null +++ b/cloud/scope/providerid.go @@ -0,0 +1,83 @@ +/* +Copyright 2019 The Kubernetes 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 scope + +import ( + "errors" + "net/url" + "path" +) + +var ( + ErrEmptyProviderID = errors.New("providerID is empty") + ErrInvalidProviderID = errors.New("providerID is not valid") +) + +// ProviderID is a struct representation of a Kubernetes ProviderID. +// Format: cloudProvider://optional/segments/etc/id +type ProviderID struct { + value *url.URL +} + +// NewProviderID parses the input string and returns a new ProviderID. +func NewProviderID(id string) (*ProviderID, error) { + if id == "" { + return nil, ErrEmptyProviderID + } + + parsed, err := url.Parse(id) + if err != nil { + return nil, err + } + + res := &ProviderID{ + value: parsed, + } + + if !res.Validate() { + return nil, ErrInvalidProviderID + } + + return res, nil +} + +// CloudProvider returns the cloud provider portion of the ProviderID. +func (p *ProviderID) CloudProvider() string { + return p.value.Scheme +} + +// ID returns the identifier portion of the ProviderID. +func (p *ProviderID) ID() string { + return path.Base(p.value.Path) +} + +// Equals returns true if both the CloudProvider and ID match. +func (p *ProviderID) Equals(o *ProviderID) bool { + return p.CloudProvider() == o.CloudProvider() && p.ID() == o.ID() +} + +// String returns the string representation of this object. +func (p *ProviderID) String() string { + return p.value.String() +} + +// Validate returns true if the provider id is valid. +func (p *ProviderID) Validate() bool { + return p.CloudProvider() != "" && + p.ID() != "" && + p.ID() != "/" // path.Base returns "/" if consists only of slashes. +} From 0598c44cd557d0726e7a2f6d502693e2518e4d52 Mon Sep 17 00:00:00 2001 From: sp-yduck Date: Sat, 1 Feb 2025 08:34:25 +0000 Subject: [PATCH 4/4] rm cloud/scope/providerid.go --- cloud/scope/providerid.go | 83 --------------------------------------- 1 file changed, 83 deletions(-) delete mode 100644 cloud/scope/providerid.go diff --git a/cloud/scope/providerid.go b/cloud/scope/providerid.go deleted file mode 100644 index cf6be17..0000000 --- a/cloud/scope/providerid.go +++ /dev/null @@ -1,83 +0,0 @@ -/* -Copyright 2019 The Kubernetes 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 scope - -import ( - "errors" - "net/url" - "path" -) - -var ( - ErrEmptyProviderID = errors.New("providerID is empty") - ErrInvalidProviderID = errors.New("providerID is not valid") -) - -// ProviderID is a struct representation of a Kubernetes ProviderID. -// Format: cloudProvider://optional/segments/etc/id -type ProviderID struct { - value *url.URL -} - -// NewProviderID parses the input string and returns a new ProviderID. -func NewProviderID(id string) (*ProviderID, error) { - if id == "" { - return nil, ErrEmptyProviderID - } - - parsed, err := url.Parse(id) - if err != nil { - return nil, err - } - - res := &ProviderID{ - value: parsed, - } - - if !res.Validate() { - return nil, ErrInvalidProviderID - } - - return res, nil -} - -// CloudProvider returns the cloud provider portion of the ProviderID. -func (p *ProviderID) CloudProvider() string { - return p.value.Scheme -} - -// ID returns the identifier portion of the ProviderID. -func (p *ProviderID) ID() string { - return path.Base(p.value.Path) -} - -// Equals returns true if both the CloudProvider and ID match. -func (p *ProviderID) Equals(o *ProviderID) bool { - return p.CloudProvider() == o.CloudProvider() && p.ID() == o.ID() -} - -// String returns the string representation of this object. -func (p *ProviderID) String() string { - return p.value.String() -} - -// Validate returns true if the provider id is valid. -func (p *ProviderID) Validate() bool { - return p.CloudProvider() != "" && - p.ID() != "" && - p.ID() != "/" // path.Base returns "/" if consists only of slashes. -}