Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@ spec:
- SingleReplica
- External
type: string
cpuPartitioning:
default: None
description: cpuPartitioning expresses if CPU partitioning is a currently enabled feature in the cluster. CPU Partitioning means that this cluster can support partitioning workloads to specific CPU Sets. Valid values are "None" and "AllNodes". When omitted, the default value is "None". The default value of "None" indicates that no nodes will be setup with CPU partitioning. The "AllNodes" value indicates that all nodes have been setup with CPU partitioning, and can then be further configured via the PerformanceProfile API.
enum:
- None
- AllNodes
type: string
etcdDiscoveryDomain:
description: 'etcdDiscoveryDomain is the domain used to fetch the SRV records for discovering etcd servers and clients. For more info: https://github.com/etcd-io/etcd/blob/329be66e8b3f9e2e6af83c123ff89297e49ebd15/Documentation/op-guide/clustering.md#dns-discovery deprecated: as of 4.7, this field is no longer set or honored. It will be removed in a future release.'
type: string
Expand Down
34 changes: 34 additions & 0 deletions config/v1/techpreview.infrastructure.testsuite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,37 @@ tests:
apiVersion: config.openshift.io/v1
kind: Infrastructure
spec: {}
onUpdate:
- name: Status Should contain default fields
initial: |
apiVersion: config.openshift.io/v1
kind: Infrastructure
spec: {}
status: {}
updated: |
apiVersion: config.openshift.io/v1
kind: Infrastructure
spec: {}
status: {}
expected: |
apiVersion: config.openshift.io/v1
kind: Infrastructure
spec: {}
status:
cpuPartitioning: None
infrastructureTopology: HighlyAvailable
controlPlaneTopology: HighlyAvailable
- name: Status update cpuPartitioning should fail validation check
initial: |
apiVersion: config.openshift.io/v1
kind: Infrastructure
spec: {}
status:
cpuPartitioning: None
updated: |
apiVersion: config.openshift.io/v1
kind: Infrastructure
spec: {}
status:
cpuPartitioning: "Invalid"
expectedStatusError: 'status.cpuPartitioning: Unsupported value: "Invalid": supported values: "None", "AllNodes"'
24 changes: 24 additions & 0 deletions config/v1/types_infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ type InfrastructureStatus struct {
// +kubebuilder:default=HighlyAvailable
// +kubebuilder:validation:Enum=HighlyAvailable;SingleReplica
InfrastructureTopology TopologyMode `json:"infrastructureTopology"`

// cpuPartitioning expresses if CPU partitioning is a currently enabled feature in the cluster.
// CPU Partitioning means that this cluster can support partitioning workloads to specific CPU Sets.
// Valid values are "None" and "AllNodes". When omitted, the default value is "None".
// The default value of "None" indicates that no nodes will be setup with CPU partitioning.
// The "AllNodes" value indicates that all nodes have been setup with CPU partitioning,
// and can then be further configured via the PerformanceProfile API.
// +kubebuilder:default=None
// +default="None"
// +kubebuilder:validation:Enum=None;AllNodes
// +openshift:enable:FeatureSets=TechPreviewNoUpgrade
// +optional
CPUPartitioning CPUPartitioningMode `json:"cpuPartitioning,omitempty"`
}

// TopologyMode defines the topology mode of the control/infra nodes.
Expand All @@ -123,6 +136,17 @@ const (
ExternalTopologyMode TopologyMode = "External"
)

// CPUPartitioningMode defines the mode for CPU partitioning
type CPUPartitioningMode string

const (
// CPUPartitioningNone means that no CPU Partitioning is on in this cluster infrastructure
CPUPartitioningNone CPUPartitioningMode = "None"

// CPUPartitioningAllNodes means that all nodes are configured with CPU Partitioning in this cluster
CPUPartitioningAllNodes CPUPartitioningMode = "AllNodes"
)

// PlatformType is a specific supported infrastructure provider.
// +kubebuilder:validation:Enum="";AWS;Azure;BareMetal;GCP;Libvirt;OpenStack;None;VSphere;oVirt;IBMCloud;KubeVirt;EquinixMetal;PowerVS;AlibabaCloud;Nutanix;External
type PlatformType string
Expand Down
49 changes: 29 additions & 20 deletions config/v1/types_infrastructure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,52 @@ package v1

import (
"io/ioutil"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"testing"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

"sigs.k8s.io/yaml"
)

const infraCRDFilePath = "0000_10_config-operator_01_infrastructure-Default.crd.yaml"
const (
infraCRDDefaultFilePath = "0000_10_config-operator_01_infrastructure-Default.crd.yaml"
infraCRDTestPreviewFilePath = "0000_10_config-operator_01_infrastructure-TechPreviewNoUpgrade.crd.yaml"
)

// TestInfrastructureStatusDefault verifies that the infrastructure CR status does not have default value
// The admission code under https://github.com/openshift/kubernetes/pull/877 is expecting that the infrastructure status
// field will not have a default value.
// It allows separating between clean installation and the roll-back to the previous version of the cluster
func TestInfrastructureStatusDefault(t *testing.T) {
infraCRDBytes, err := ioutil.ReadFile(infraCRDFilePath)
if err != nil {
t.Fatalf("failed to read infrastructure CRD file %q: %v", infraCRDFilePath, err)
}

var infraCRD map[string]interface{}
if err := yaml.Unmarshal(infraCRDBytes, &infraCRD); err != nil {
t.Fatalf("failed to unmarshal infra CRD: %v", err)
}
infraCRDSpec := infraCRD["spec"].(map[string]interface{})
infraCRDVersions := infraCRDSpec["versions"].([]interface{})
for _, v := range infraCRDVersions {
infraCRDVersion := v.(map[string]interface{})
status, exists, err := unstructured.NestedMap(infraCRDVersion, "schema", "openAPIV3Schema", "properties", "status")
filePaths := []string{infraCRDDefaultFilePath, infraCRDTestPreviewFilePath}

for _, filepath := range filePaths {
infraCRDBytes, err := ioutil.ReadFile(filepath)
if err != nil {
t.Fatalf("failed to get nested map: %v", err)
t.Fatalf("failed to read infrastructure CRD file %q: %v", filepath, err)
}

if !exists {
t.Fatalf("one of fields does not exist under the CRD")
var infraCRD map[string]interface{}
if err := yaml.Unmarshal(infraCRDBytes, &infraCRD); err != nil {
t.Fatalf("failed to unmarshal infra CRD: %v", err)
}
infraCRDSpec := infraCRD["spec"].(map[string]interface{})
infraCRDVersions := infraCRDSpec["versions"].([]interface{})
for _, v := range infraCRDVersions {
infraCRDVersion := v.(map[string]interface{})
status, exists, err := unstructured.NestedMap(infraCRDVersion, "schema", "openAPIV3Schema", "properties", "status")
if err != nil {
t.Fatalf("failed to get nested map: %v", err)
}

if !exists {
t.Fatalf("one of fields does not exist under the CRD")
}

if _, ok := status["default"]; ok {
t.Fatalf("expected no default for the infrastructure CRD status")
if _, ok := status["default"]; ok {
t.Fatalf("expected no default for the infrastructure CRD status")
}
}
}
}
1 change: 1 addition & 0 deletions config/v1/zz_generated.swagger_doc_generated.go

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

8 changes: 8 additions & 0 deletions openapi/generated_openapi/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 openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -6972,6 +6972,11 @@
"type": "string",
"default": ""
},
"cpuPartitioning": {
"description": "cpuPartitioning expresses if CPU partitioning is a currently enabled feature in the cluster. CPU Partitioning means that this cluster can support partitioning workloads to specific CPU Sets. Valid values are \"None\" and \"AllNodes\". When omitted, the default value is \"None\". The default value of \"None\" indicates that no nodes will be setup with CPU partitioning. The \"AllNodes\" value indicates that all nodes have been setup with CPU partitioning, and can then be further configured via the PerformanceProfile API.",
"type": "string",
"default": "None"
},
"etcdDiscoveryDomain": {
"description": "etcdDiscoveryDomain is the domain used to fetch the SRV records for discovering etcd servers and clients. For more info: https://github.com/etcd-io/etcd/blob/329be66e8b3f9e2e6af83c123ff89297e49ebd15/Documentation/op-guide/clustering.md#dns-discovery deprecated: as of 4.7, this field is no longer set or honored. It will be removed in a future release.",
"type": "string",
Expand Down