Skip to content

Commit

Permalink
Fix the taints and labels
Browse files Browse the repository at this point in the history
Replace the taints with proper data structure
and migrate labels to map
  • Loading branch information
petrkotas committed May 15, 2024
1 parent dd28057 commit 105e3ca
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 20 deletions.
2 changes: 1 addition & 1 deletion api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SHELL = /bin/bash
generate:
tsp format --check "**/*.tsp"
tsp compile redhatopenshift/HcpCluster --warn-as-error
autorest autorest-config.yaml
autorest --verbose autorest-config.yaml

.PHONY: fmt
fmt:
Expand Down
65 changes: 62 additions & 3 deletions api/redhatopenshift/HcpCluster/hcpCluster-models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,41 @@ model NodePoolProperties {
spec: NodePoolSpec;
}

/** taintKey is the k8s valid key of the taint type on the nodepool nodes
* The good example of the taint key is `node-role.kubernetes.io/master`
*/
@minLength(1)
@maxLength(316)
scalar taintKey extends string;

/** taintValue is the k8s valid value of the taint type on the nodepool nodes
* The good example of the taint value is `NoSchedule`
*/
@minLength(1)
@maxLength(63)
scalar taintValue extends string;

/** labelValue is the k8s valid value of the label on the nodepool nodes
* The good example of the label value is `master`
*/
@minLength(1)
@maxLength(63)
scalar labelValue extends string;

/** The taint effect the same as in K8s */
union Effect {
string,

/** NoSchedule taint effect */
NoSchedule: "NoSchedule",

/** PreferNoSchedule taint effect */
PreferNoSchedule: "PreferNoSchedule",

/** NoExecute taint effect */
NoExecute: "NoExecute",
}

/** Worker node pool profile */
model NodePoolSpec {
/** OpenShift version for the nodepool */
Expand All @@ -461,13 +496,19 @@ model NodePoolSpec {
/** Representation of a autoscaling in a node pool. */
autoScaling?: NodePoolAutoScaling;

/** Labels for the nodes */
// This warning means to ensure good customer experience, to not create
// poorly defined types. However here the type literarly is the map<string, value>
/** K8s labels to propagate to the NodePool Nodes
* The good example of the label is `node-role.kubernetes.io/master: ""`
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-no-record" ""
@visibility("create", "update")
labels?: string[];
labels?: Record<labelValue>;

/** Taints for the nodes */
@visibility("create", "update")
taints?: string[];
@OpenAPI.extension("x-ms-identifiers", ["key", "value", "effect"])
taints?: Taint[];

/*
* The Tuned API is defined here:
Expand All @@ -486,6 +527,24 @@ model NodePoolSpec {
tuningConfigs?: string[];
}

/** Taint is controlling the node taint and its effects */
model Taint {
/** The key of the taint
* The good example of the taint key is `node-role.kubernetes.io/master`
*/
key: taintKey;

/** The value of the taint
* The good example of the taint value is `NoSchedule`
*/
value?: taintValue;

/** The effect of the taint
* The good example of the taint effect is `NoSchedule`
*/
effect: Effect;
}

/** Azure node pool platform configuration */
model NodePoolPlatformProfile {
/** The resourceId for the subnet used by the workers */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,35 @@
"type": "object",
"description": "DNS contains the DNS settings of the cluster"
},
"Effect": {
"type": "string",
"enum": [
"NoSchedule",
"PreferNoSchedule",
"NoExecute"
],
"x-ms-enum": {
"name": "Effect",
"modelAsString": true,
"values": [
{
"name": "NoSchedule",
"value": "NoSchedule",
"description": "NoSchedule taint effect"
},
{
"name": "PreferNoSchedule",
"value": "PreferNoSchedule",
"description": "PreferNoSchedule taint effect"
},
{
"name": "NoExecute",
"value": "NoExecute",
"description": "NoExecute taint effect"
}
]
}
},
"ExternalAuthClaimProfile": {
"type": "object",
"description": "External auth claim profile",
Expand Down Expand Up @@ -1446,10 +1475,10 @@
"description": "Representation of a autoscaling in a node pool."
},
"labels": {
"type": "array",
"description": "Labels for the nodes",
"items": {
"type": "string"
"type": "object",
"description": "K8s labels to propagate to the NodePool Nodes\nThe good example of the label is `node-role.kubernetes.io/master: \"\"`",
"additionalProperties": {
"$ref": "#/definitions/labelValue"
},
"x-ms-mutability": [
"update",
Expand All @@ -1460,8 +1489,13 @@
"type": "array",
"description": "Taints for the nodes",
"items": {
"type": "string"
"$ref": "#/definitions/Taint"
},
"x-ms-identifiers": [
"key",
"value",
"effect"
],
"x-ms-mutability": [
"update",
"create"
Expand Down Expand Up @@ -1901,10 +1935,10 @@
"description": "Representation of a autoscaling in a node pool."
},
"labels": {
"type": "array",
"description": "Labels for the nodes",
"items": {
"type": "string"
"type": "object",
"description": "K8s labels to propagate to the NodePool Nodes\nThe good example of the label is `node-role.kubernetes.io/master: \"\"`",
"additionalProperties": {
"$ref": "#/definitions/labelValue"
},
"x-ms-mutability": [
"update",
Expand All @@ -1915,8 +1949,13 @@
"type": "array",
"description": "Taints for the nodes",
"items": {
"type": "string"
"$ref": "#/definitions/Taint"
},
"x-ms-identifiers": [
"key",
"value",
"effect"
],
"x-ms-mutability": [
"update",
"create"
Expand Down Expand Up @@ -2052,6 +2091,28 @@
}
}
},
"Taint": {
"type": "object",
"description": "Taint is controlling the node taint and its effects",
"properties": {
"key": {
"$ref": "#/definitions/taintKey",
"description": "The key of the taint\nThe good example of the taint key is `node-role.kubernetes.io/master`"
},
"value": {
"$ref": "#/definitions/taintValue",
"description": "The value of the taint\nThe good example of the taint value is `NoSchedule`"
},
"effect": {
"$ref": "#/definitions/Effect",
"description": "The effect of the taint\nThe good example of the taint effect is `NoSchedule`"
}
},
"required": [
"key",
"effect"
]
},
"TokenClaimMappingsProfile": {
"type": "object",
"description": "External auth claim mappings profile",
Expand Down Expand Up @@ -2185,6 +2246,24 @@
}
]
}
},
"labelValue": {
"type": "string",
"description": "labelValue is the k8s valid value of the label on the nodepool nodes\nThe good example of the label value is `master`",
"minLength": 1,
"maxLength": 63
},
"taintKey": {
"type": "string",
"description": "taintKey is the k8s valid key of the taint type on the nodepool nodes\nThe good example of the taint key is `node-role.kubernetes.io/master`",
"minLength": 1,
"maxLength": 316
},
"taintValue": {
"type": "string",
"description": "taintValue is the k8s valid value of the taint type on the nodepool nodes\nThe good example of the taint value is `NoSchedule`",
"minLength": 1,
"maxLength": 63
}
},
"parameters": {}
Expand Down
20 changes: 20 additions & 0 deletions internal/api/v20240610preview/generated_constants.go

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

24 changes: 18 additions & 6 deletions internal/api/v20240610preview/generated_models.go

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

35 changes: 35 additions & 0 deletions internal/api/v20240610preview/generated_models_serde.go

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

0 comments on commit 105e3ca

Please sign in to comment.