Skip to content

Commit

Permalink
Introduce ConsumedCapacity into the SpaceProvisionerConfig status (#450)
Browse files Browse the repository at this point in the history
* Introduce ConsumedCapacity into the SpaceProvisionerConfig status that is
meant to mirror the relevant information from the ToolchainStatus for
easier inspection of the cluster conditions.

* fix the typo in the json field name.
  • Loading branch information
metlos authored Nov 19, 2024
1 parent 44333bf commit f6581d5
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 7 deletions.
29 changes: 28 additions & 1 deletion api/v1alpha1/docs/apiref.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,29 @@ Defines all parameters concerned with the console
|===


[id="{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-consumedcapacity"]
==== ConsumedCapacity



ConsumedCapacity describes the capacity of the cluster consumed by the spaces
currently provisioned to it.



.Appears In:
****
- xref:{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-spaceprovisionerconfigstatus[$$SpaceProvisionerConfigStatus$$]
****

[cols="20a,50a,15a,15a", options="header"]
|===
| Field | Description | Default | Validation
| *`memoryUsagePercentPerNodeRole`* __object (keys:string, values:integer)__ | MemoryUsagePercentPerNodeRole is the percent of the memory used per node role (eg. worker, master) + | |
| *`spaceCount`* __integer__ | SpaceCount is the number of spaces currently deployed to the cluster + | |
|===


[id="{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-deactivationconfig"]
==== DeactivationConfig

Expand Down Expand Up @@ -2861,8 +2884,12 @@ the space scheduling decisions. + | |
[cols="20a,50a,15a,15a", options="header"]
|===
| Field | Description | Default | Validation
| *`consumedCapacity`* __xref:{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-consumedcapacity[$$ConsumedCapacity$$]__ | ConsumedCapacity reflects the runtime state of the cluster and the capacity it currently consumes. +
Nil if the consumed capacity is not known + | |
| *`conditions`* __xref:{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-condition[$$Condition$$] array__ | Conditions describes the state of the configuration (its validity). +
The only known condition type is "Ready". + | |
The only known condition type is "Ready". The SpaceProvisionerConfig is ready when the following is true: +
* the referenced ToolchainCluster object exists and is itself ready +
* the consumed capacity doesn't breach the thresholds defined in the spec + | |
|===


Expand Down
30 changes: 26 additions & 4 deletions api/v1alpha1/spaceprovisionerconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ package v1alpha1
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

const (
SpaceProvisionerConfigToolchainClusterNotFoundReason = "ToolchainClusterNotFound"
SpaceProvisionerConfigToolchainClusterNotReadyReason = "ToolchainClusterNotReady"
SpaceProvisionerConfigValidReason = "AllChecksPassed"
SpaceProvisionerConfigToolchainClusterNotFoundReason = "ToolchainClusterNotFound"
SpaceProvisionerConfigToolchainClusterNotReadyReason = "ToolchainClusterNotReady"
SpaceProvisionerConfigInsufficientCapacityReason = "InsufficientCapacity"
SpaceProvisionerConfigFailedToDetermineCapacityReason = "FailedToDetermineCapacity"
SpaceProvisionerConfigValidReason = "AllChecksPassed"
SpaceProvisionerConfigDisabledReason = "Disabled"
)

// +k8s:openapi-gen=true
Expand Down Expand Up @@ -50,10 +53,29 @@ type SpaceProvisionerCapacityThresholds struct {
MaxMemoryUtilizationPercent uint `json:"maxMemoryUtilizationPercent,omitempty"`
}

// ConsumedCapacity describes the capacity of the cluster consumed by the spaces
// currently provisioned to it.
type ConsumedCapacity struct {
// MemoryUsagePercentPerNodeRole is the percent of the memory used per node role (eg. worker, master)
// +maptype: atomic
MemoryUsagePercentPerNodeRole map[string]int `json:"memoryUsagePercentPerNodeRole"`

// SpaceCount is the number of spaces currently deployed to the cluster
SpaceCount int `json:"spaceCount"`
}

// +k8s:openapi-gen=true
type SpaceProvisionerConfigStatus struct {
// ConsumedCapacity reflects the runtime state of the cluster and the capacity it currently consumes.
// Nil if the consumed capacity is not known
// +optional
ConsumedCapacity *ConsumedCapacity `json:"consumedCapacity,omitempty"`

// Conditions describes the state of the configuration (its validity).
// The only known condition type is "Ready".
// The only known condition type is "Ready". The SpaceProvisionerConfig is ready when the following is true:
// * the referenced ToolchainCluster object exists and is itself ready
// * the consumed capacity doesn't breach the thresholds defined in the spec
//
// +optional
// +patchMergeKey=type
// +patchStrategy=merge
Expand Down
27 changes: 27 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

10 changes: 8 additions & 2 deletions api/v1alpha1/zz_generated.openapi.go

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

0 comments on commit f6581d5

Please sign in to comment.