Skip to content

Commit

Permalink
feat(vi,vd): add storage class ready condition, waiting in pending wh…
Browse files Browse the repository at this point in the history
…ile storage class not ready (#423)

Introduces a readiness condition and validation for StorageClass specified in VirtualImage and VirtualDisk. If the specified StorageClass is not ready, the resource will remain in a pending state.

---------

Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
  • Loading branch information
eofff authored Nov 14, 2024
1 parent ce6f8b0 commit fff39cc
Show file tree
Hide file tree
Showing 53 changed files with 2,784 additions and 125 deletions.
11 changes: 11 additions & 0 deletions api/core/v1alpha2/vdcondition/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const (
ResizedType Type = "Resized"
// SnapshottingType indicates whether the disk snapshotting operation is in progress.
SnapshottingType Type = "Snapshotting"
// StorageClassReadyType indicates whether the storage class is ready.
StorageClassReadyType Type = "StorageClassReady"
)

type (
Expand All @@ -39,6 +41,8 @@ type (
ResizedReason = string
// SnapshottingReason represents the various reasons for the Snapshotting condition type.
SnapshottingReason = string
// StorageClassReadyReason represents the various reasons for the Storageclass ready condition type.
StorageClassReadyReason = string
)

const (
Expand All @@ -63,6 +67,8 @@ const (
WaitingForFirstConsumer ReadyReason = "WaitingForFirstConsumer"
// ProvisioningFailed indicates that the provisioning process has failed.
ProvisioningFailed ReadyReason = "ProvisioningFailed"
// StorageClassNotReady indicates that the provisioning process pending because `StorageClass` not ready.
StorageClassNotReady ReadyReason = "StorageClassNotReady"
// Ready indicates that the import process is complete and the `VirtualDisk` is ready for use.
Ready ReadyReason = "Ready"
// Lost indicates that the underlying PersistentVolumeClaim has been lost and the `VirtualDisk` can no longer be used.
Expand All @@ -83,4 +89,9 @@ const (
Snapshotting SnapshottingReason = "Snapshotting"
// SnapshottingNotAvailable indicates that the snapshotting operation is not available for now.
SnapshottingNotAvailable SnapshottingReason = "NotAvailable"

// StorageClassReady indicates that the storage class is ready
StorageClassReady StorageClassReadyReason = "StorageClassReady"
// StorageClassNotFound indicates that the storage class is not ready
StorageClassNotFound StorageClassReadyReason = "StorageClassNotFound"
)
13 changes: 13 additions & 0 deletions api/core/v1alpha2/vicondition/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ const (
DatasourceReadyType Type = "DatasourceReady"
// ReadyType indicates whether the import process succeeded and the `VirtualImage` is ready for use.
ReadyType Type = "Ready"
// StorageClassReadyType indicates whether the storageClass ready
StorageClassReadyType Type = "StorageClassReady"
)

type (
// DatasourceReadyReason represents the various reasons for the DatasourceReady condition type.
DatasourceReadyReason = string
// ReadyReason represents the various reasons for the Ready condition type.
ReadyReason = string
// StorageClassReadyReason represents the various reasons for the StorageClassReady condition type.
StorageClassReadyReason = string
)

const (
Expand All @@ -53,9 +57,18 @@ const (
ProvisioningNotStarted ReadyReason = "ProvisioningNotStarted"
// ProvisioningFailed indicates that the provisioning process has failed.
ProvisioningFailed ReadyReason = "ProvisioningFailed"
// StorageClassNotReady indicates that the provisioning process pending because `StorageClass` not ready.
StorageClassNotReady ReadyReason = "StorageClassNotReady"
// Ready indicates that the import process is complete and the `VirtualImage` is ready for use.
Ready ReadyReason = "Ready"

// Lost indicates that the underlying PersistentVolumeClaim has been lost and the `VirtualImage` can no longer be used.
Lost ReadyReason = "PVCLost"

// StorageClassReady indicates that the chosen StorageClass exists.
StorageClassReady StorageClassReadyReason = "StorageClassReady"
// StorageClassNotFound indicates that the chosen StorageClass not found.
StorageClassNotFound StorageClassReadyReason = "StorageClassNotFound"
// DVCRTypeUsed indicates that the DVCR provisioning chosen.
DVCRTypeUsed StorageClassReadyReason = "DVCRTypeUsed"
)
1 change: 1 addition & 0 deletions api/core/v1alpha2/virtual_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type VirtualDiskStatus struct {
SourceUID *types.UID `json:"sourceUID,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
StorageClassName string `json:"storageClassName,omitempty"`
}

type VirtualDiskStats struct {
Expand Down
1 change: 1 addition & 0 deletions api/core/v1alpha2/virtual_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type VirtualImageStatus struct {
ImageStatus `json:",inline"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
StorageClassName string `json:"storageClassName,omitempty"`
}

type VirtualImageDataSource struct {
Expand Down
12 changes: 12 additions & 0 deletions api/pkg/apiserver/api/generated/openapi/zz_generated.openapi.go

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

3 changes: 3 additions & 0 deletions crds/doc-ru-virtualdisks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ spec:
sourceUID:
description: |
UID источника (`VirtualImage` или `ClusterVirtualImage`), использовавшегося при создании виртуального диска.
storageClassName:
description: |
Имя StorageClass, использованного для создания DataVolume.
observedGeneration:
description: |
Поколение ресурса, которое в последний раз обрабатывалось контроллером.
3 changes: 3 additions & 0 deletions crds/doc-ru-virtualimages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ spec:
sourceUID:
description: |
UID источника (`VirtualImage`, `ClusterVirtualImage` или `VirtualDisk`), использовавшегося при создании виртуального образа.
storageClassName:
description: |
Имя StorageClass, использованного для создания DataVolume если в поле `storage` был выбран тип `Kubernetes`.
observedGeneration:
description: |
Поколение ресурса, которое в последний раз обрабатывалось контроллером.
4 changes: 4 additions & 0 deletions crds/virtualdisks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ spec:
type: string
description: |
The UID of the source (`VirtualImage` or `ClusterVirtualImage`) used when creating the virtual disk.
storageClassName:
type: string
description: |
The name of the `StorageClass` used by the `PersistentVolumeClaim`.
observedGeneration:
type: integer
description: |
Expand Down
4 changes: 4 additions & 0 deletions crds/virtualimages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ spec:
type: string
description: |
The UID of the source (`VirtualImage`, `ClusterVirtualImage` or `VirtualDisk`) used when creating the virtual image.
storageClassName:
type: string
description: |
The name of the StorageClass used by the PersistentVolumeClaim if `Kubernetes` storage type used.
observedGeneration:
type: integer
description: |
Expand Down
21 changes: 4 additions & 17 deletions crds/virtualmachineblockdeviceattachments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.16.4
labels:
heritage: deckhouse
module: virtualization
Expand Down Expand Up @@ -93,16 +93,8 @@ spec:
description: Contains details of the current state of this API Resource.
items:
description:
"Condition contains details for one aspect of the current
state of this API Resource.\n---\nThis struct is intended for
direct use as an array at the field path .status.conditions. For
example,\n\n\n\ttype FooStatus struct{\n\t // Represents the
observations of a foo's current state.\n\t // Known .status.conditions.type
are: \"Available\", \"Progressing\", and \"Degraded\"\n\t //
+patchMergeKey=type\n\t // +patchStrategy=merge\n\t // +listType=map\n\t
\ // +listMapKey=type\n\t Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`\n\n\n\t
\ // other fields\n\t}"
Condition contains details for one aspect of the current
state of this API Resource.
properties:
lastTransitionTime:
description: |-
Expand Down Expand Up @@ -143,12 +135,7 @@ spec:
- 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.
The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
description: type of condition in CamelCase or in foo.example.com/CamelCase.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
Expand Down
21 changes: 4 additions & 17 deletions crds/virtualmachineclasses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.16.4
labels:
backup.deckhouse.io/cluster-config: "true"
heritage: deckhouse
Expand Down Expand Up @@ -390,16 +390,8 @@ spec:
resource.
items:
description:
"Condition contains details for one aspect of the current
state of this API Resource.\n---\nThis struct is intended for
direct use as an array at the field path .status.conditions. For
example,\n\n\n\ttype FooStatus struct{\n\t // Represents the
observations of a foo's current state.\n\t // Known .status.conditions.type
are: \"Available\", \"Progressing\", and \"Degraded\"\n\t //
+patchMergeKey=type\n\t // +patchStrategy=merge\n\t // +listType=map\n\t
\ // +listMapKey=type\n\t Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`\n\n\n\t
\ // other fields\n\t}"
Condition contains details for one aspect of the current
state of this API Resource.
properties:
lastTransitionTime:
description: |-
Expand Down Expand Up @@ -440,12 +432,7 @@ spec:
- 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.
The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
description: type of condition in CamelCase or in foo.example.com/CamelCase.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
Expand Down
21 changes: 4 additions & 17 deletions crds/virtualmachineoperations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.16.4
labels:
heritage: deckhouse
module: virtualization
Expand Down Expand Up @@ -111,16 +111,8 @@ spec:
resource.
items:
description:
"Condition contains details for one aspect of the current
state of this API Resource.\n---\nThis struct is intended for
direct use as an array at the field path .status.conditions. For
example,\n\n\n\ttype FooStatus struct{\n\t // Represents the
observations of a foo's current state.\n\t // Known .status.conditions.type
are: \"Available\", \"Progressing\", and \"Degraded\"\n\t //
+patchMergeKey=type\n\t // +patchStrategy=merge\n\t // +listType=map\n\t
\ // +listMapKey=type\n\t Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`\n\n\n\t
\ // other fields\n\t}"
Condition contains details for one aspect of the current
state of this API Resource.
properties:
lastTransitionTime:
description: |-
Expand Down Expand Up @@ -161,12 +153,7 @@ spec:
- 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.
The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
description: type of condition in CamelCase or in foo.example.com/CamelCase.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
Expand Down
21 changes: 4 additions & 17 deletions crds/virtualmachinerestores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.16.4
labels:
heritage: deckhouse
module: virtualization
Expand Down Expand Up @@ -99,16 +99,8 @@ spec:
description: Contains details of the current state of this API Resource.
items:
description:
"Condition contains details for one aspect of the current
state of this API Resource.\n---\nThis struct is intended for
direct use as an array at the field path .status.conditions. For
example,\n\n\n\ttype FooStatus struct{\n\t // Represents the
observations of a foo's current state.\n\t // Known .status.conditions.type
are: \"Available\", \"Progressing\", and \"Degraded\"\n\t //
+patchMergeKey=type\n\t // +patchStrategy=merge\n\t // +listType=map\n\t
\ // +listMapKey=type\n\t Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`\n\n\n\t
\ // other fields\n\t}"
Condition contains details for one aspect of the current
state of this API Resource.
properties:
lastTransitionTime:
description: |-
Expand Down Expand Up @@ -149,12 +141,7 @@ spec:
- 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.
The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
description: type of condition in CamelCase or in foo.example.com/CamelCase.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
Expand Down
Loading

0 comments on commit fff39cc

Please sign in to comment.