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
39 changes: 39 additions & 0 deletions api/v1beta1/hyperconverged_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v1beta1
import (
openshiftconfigv1 "github.com/openshift/api/config/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

v1 "kubevirt.io/api/core/v1"
Expand Down Expand Up @@ -856,6 +857,44 @@ type NodeInfoStatus struct {
WorkloadsArchitectures []string `json:"workloadsArchitectures,omitempty"`
// ControlPlaneArchitectures is a distinct list of the CPU architecture of the control-plane nodes.
ControlPlaneArchitectures []string `json:"controlPlaneArchitectures,omitempty"`
// RecommendedCpuModels is a list of recommended CPU models for the cluster based on available nodes
// +listType=map
// +listMapKey=name
RecommendedCpuModels []CpuModelInfo `json:"recommendedCpuModels,omitempty"`
}

// CpuModelInfo contains information about a CPU model and its availability in the cluster
type CpuModelInfo struct {
// Name is the CPU model name
Name string `json:"name"`
// Benchmark is the CPU performance score for this model
Benchmark int `json:"benchmark"`
// Nodes is the number of nodes that support this CPU model
Nodes int `json:"nodes"`
// CPU is the total CPU cores available across all nodes supporting this model
CPU *resource.Quantity `json:"cpu"`
// Memory is the total memory available across all nodes supporting this model
Memory *resource.Quantity `json:"memory"`
}

// Equal returns true if the two CpuModelInfo objects are equal
func (c CpuModelInfo) Equal(other CpuModelInfo) bool {
if c.Name != other.Name || c.Benchmark != other.Benchmark || c.Nodes != other.Nodes {
return false
}
if (c.CPU == nil) != (other.CPU == nil) {
return false
}
if c.CPU != nil && !c.CPU.Equal(*other.CPU) {
return false
}
if (c.Memory == nil) != (other.Memory == nil) {
return false
}
if c.Memory != nil && !c.Memory.Equal(*other.Memory) {
return false
}
return true
}

// ApplicationAwareConfigurations holds the AAQ configurations
Expand Down
35 changes: 34 additions & 1 deletion api/v1beta1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion api/v1beta1/zz_generated.defaults.go

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

2 changes: 1 addition & 1 deletion api/v1beta1/zz_generated.openapi.go

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

45 changes: 45 additions & 0 deletions config/crd/bases/hco.kubevirt.io_hyperconvergeds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5163,6 +5163,51 @@ spec:
items:
type: string
type: array
recommendedCpuModels:
description: RecommendedCpuModels is a list of recommended CPU
models for the cluster based on available nodes
items:
description: CpuModelInfo contains information about a CPU model
and its availability in the cluster
properties:
benchmark:
description: Benchmark is the CPU performance score for
this model
type: integer
cpu:
anyOf:
- type: integer
- type: string
description: CPU is the total CPU cores available across
all nodes supporting this model
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memory:
anyOf:
- type: integer
- type: string
description: Memory is the total memory available across
all nodes supporting this model
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
name:
description: Name is the CPU model name
type: string
nodes:
description: Nodes is the number of nodes that support this
CPU model
type: integer
required:
- benchmark
- cpu
- memory
- name
- nodes
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
workloadsArchitectures:
description: WorkloadsArchitectures is a distinct list of the
CPU architectures of the workloads nodes in the cluster.
Expand Down
5 changes: 5 additions & 0 deletions controllers/hyperconverged/hyperconverged_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,11 @@ func updateStatus(req *common.HcoRequest) {
req.Instance.Status.NodeInfo.WorkloadsArchitectures = workloadsArch
req.StatusDirty = true
}

if cpuModels := nodeinfo.GetRecommendedCpuModels(); !slices.EqualFunc(req.Instance.Status.NodeInfo.RecommendedCpuModels, cpuModels, hcov1beta1.CpuModelInfo.Equal) {
req.Instance.Status.NodeInfo.RecommendedCpuModels = cpuModels
req.StatusDirty = true
}
Comment on lines +517 to +521
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  1. we already have a comparison function in the nodeinfo package, we can't expose it for reuse, because it's in an internal package, but maybe we can add it as the CpuModel type's method, instead?
  2. this code is not tested. Can we have a few unit tests for it? We can use a simple mock, as done for the rest of the functions in the nodeinfo package, to return any desired value.

}

// getHyperConverged gets the HyperConverged resource from the Kubernetes API.
Expand Down
45 changes: 45 additions & 0 deletions deploy/crds/hco00.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5163,6 +5163,51 @@ spec:
items:
type: string
type: array
recommendedCpuModels:
description: RecommendedCpuModels is a list of recommended CPU
models for the cluster based on available nodes
items:
description: CpuModelInfo contains information about a CPU model
and its availability in the cluster
properties:
benchmark:
description: Benchmark is the CPU performance score for
this model
type: integer
cpu:
anyOf:
- type: integer
- type: string
description: CPU is the total CPU cores available across
all nodes supporting this model
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memory:
anyOf:
- type: integer
- type: string
description: Memory is the total memory available across
all nodes supporting this model
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
name:
description: Name is the CPU model name
type: string
nodes:
description: Nodes is the number of nodes that support this
CPU model
type: integer
required:
- benchmark
- cpu
- memory
- name
- nodes
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
workloadsArchitectures:
description: WorkloadsArchitectures is a distinct list of the
CPU architectures of the workloads nodes in the cluster.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5163,6 +5163,51 @@ spec:
items:
type: string
type: array
recommendedCpuModels:
description: RecommendedCpuModels is a list of recommended CPU
models for the cluster based on available nodes
items:
description: CpuModelInfo contains information about a CPU model
and its availability in the cluster
properties:
benchmark:
description: Benchmark is the CPU performance score for
this model
type: integer
cpu:
anyOf:
- type: integer
- type: string
description: CPU is the total CPU cores available across
all nodes supporting this model
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memory:
anyOf:
- type: integer
- type: string
description: Memory is the total memory available across
all nodes supporting this model
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
name:
description: Name is the CPU model name
type: string
nodes:
description: Nodes is the number of nodes that support this
CPU model
type: integer
required:
- benchmark
- cpu
- memory
- name
- nodes
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
workloadsArchitectures:
description: WorkloadsArchitectures is a distinct list of the
CPU architectures of the workloads nodes in the cluster.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5163,6 +5163,51 @@ spec:
items:
type: string
type: array
recommendedCpuModels:
description: RecommendedCpuModels is a list of recommended CPU
models for the cluster based on available nodes
items:
description: CpuModelInfo contains information about a CPU model
and its availability in the cluster
properties:
benchmark:
description: Benchmark is the CPU performance score for
this model
type: integer
cpu:
anyOf:
- type: integer
- type: string
description: CPU is the total CPU cores available across
all nodes supporting this model
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memory:
anyOf:
- type: integer
- type: string
description: Memory is the total memory available across
all nodes supporting this model
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
name:
description: Name is the CPU model name
type: string
nodes:
description: Nodes is the number of nodes that support this
CPU model
type: integer
required:
- benchmark
- cpu
- memory
- name
- nodes
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
workloadsArchitectures:
description: WorkloadsArchitectures is a distinct list of the
CPU architectures of the workloads nodes in the cluster.
Expand Down
16 changes: 16 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This Document documents the types introduced by the hyperconverged-cluster-opera
* [ApplicationAwareConfigurations](#applicationawareconfigurations)
* [CertRotateConfigCA](#certrotateconfigca)
* [CertRotateConfigServer](#certrotateconfigserver)
* [CpuModelInfo](#cpumodelinfo)
* [DataImportCronStatus](#dataimportcronstatus)
* [DataImportCronTemplate](#dataimportcrontemplate)
* [DataImportCronTemplateStatus](#dataimportcrontemplatestatus)
Expand Down Expand Up @@ -71,6 +72,20 @@ CertRotateConfigServer contains the tunables for TLS certificates.

[Back to TOC](#table-of-contents)

## CpuModelInfo

CpuModelInfo contains information about a CPU model and its availability in the cluster

| Field | Description | Scheme | Default | Required |
| ----- | ----------- | ------ | -------- |-------- |
| name | Name is the CPU model name | string | | true |
| benchmark | Benchmark is the CPU performance score for this model | int | | true |
| nodes | Nodes is the number of nodes that support this CPU model | int | | true |
| cpu | CPU is the total CPU cores available across all nodes supporting this model | *resource.Quantity | | true |
| memory | Memory is the total memory available across all nodes supporting this model | *resource.Quantity | | true |

[Back to TOC](#table-of-contents)

## DataImportCronStatus

DataImportCronStatus is the status field of the DIC template
Expand Down Expand Up @@ -353,6 +368,7 @@ NodeInfoStatus holds information about the cluster nodes
| ----- | ----------- | ------ | -------- |-------- |
| workloadsArchitectures | WorkloadsArchitectures is a distinct list of the CPU architectures of the workloads nodes in the cluster. | []string | | false |
| controlPlaneArchitectures | ControlPlaneArchitectures is a distinct list of the CPU architecture of the control-plane nodes. | []string | | false |
| recommendedCpuModels | RecommendedCpuModels is a list of recommended CPU models for the cluster based on available nodes | [][CpuModelInfo](#cpumodelinfo) | | false |

[Back to TOC](#table-of-contents)

Expand Down
Loading