Skip to content

Commit

Permalink
feat(vmbda): apply new controller design
Browse files Browse the repository at this point in the history
* feat(vmbda): apply new design

New vmbda controller design
Conditions: BlockDeviceReady, VirtualMachineReady, Attached

Signed-off-by: Isteb4k <dmitry.rakitin@flant.com>
  • Loading branch information
Isteb4k authored Jul 5, 2024
1 parent 0cce992 commit 2f489e4
Show file tree
Hide file tree
Showing 37 changed files with 1,736 additions and 884 deletions.
3 changes: 3 additions & 0 deletions api/core/v1alpha2/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const (
// ReasonVMWaitForBlockDevices is event reason that block devices used by VM are not ready yet.
ReasonVMWaitForBlockDevices = "WaitForBlockDevices"

// ReasonUnknownHotPluggedVolume is event reason that volume was hot plugged to VirtualMachineInstance, but it is not a VirtualDisk.
ReasonUnknownHotPluggedVolume = "UnknownHotPluggedVolume"

// ReasonVMChangesApplied is event reason that changes applied from VM to underlying KVVM.
ReasonVMChangesApplied = "ChangesApplied"

Expand Down
23 changes: 10 additions & 13 deletions api/core/v1alpha2/virtual_machine_block_disk_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ type VirtualMachineBlockDeviceAttachmentList struct {
}

type VirtualMachineBlockDeviceAttachmentSpec struct {
VirtualMachine string `json:"virtualMachineName"`
BlockDeviceRef VMBDAObjectRef `json:"blockDeviceRef"`
VirtualMachineName string `json:"virtualMachineName"`
BlockDeviceRef VMBDAObjectRef `json:"blockDeviceRef"`
}

type VMBDAObjectRef struct {
Expand All @@ -60,21 +60,18 @@ const (
VMBDAObjectRefKindVirtualDisk VMBDAObjectRefKind = "VirtualDisk"
)

type VirtualMachineBlockDeviceAttachmentObjectRefKind string

const BlockDeviceAttachmentTypeVirtualDisk VirtualMachineBlockDeviceAttachmentObjectRefKind = "VirtualDisk"

type VirtualMachineBlockDeviceAttachmentStatus struct {
VirtualMachine string `json:"virtualMachine,omitempty"`
Phase BlockDeviceAttachmentPhase `json:"phase,omitempty"`
FailureReason string `json:"failureReason,omitempty"`
FailureMessage string `json:"failureMessage,omitempty"`
Phase BlockDeviceAttachmentPhase `json:"phase,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

type BlockDeviceAttachmentPhase string

const (
BlockDeviceAttachmentPhaseInProgress BlockDeviceAttachmentPhase = "InProgress"
BlockDeviceAttachmentPhaseAttached BlockDeviceAttachmentPhase = "Attached"
BlockDeviceAttachmentPhaseFailed BlockDeviceAttachmentPhase = "Failed"
BlockDeviceAttachmentPhasePending BlockDeviceAttachmentPhase = "Pending"
BlockDeviceAttachmentPhaseInProgress BlockDeviceAttachmentPhase = "InProgress"
BlockDeviceAttachmentPhaseAttached BlockDeviceAttachmentPhase = "Attached"
BlockDeviceAttachmentPhaseFailed BlockDeviceAttachmentPhase = "Failed"
BlockDeviceAttachmentPhaseTerminating BlockDeviceAttachmentPhase = "Terminating"
)
43 changes: 43 additions & 0 deletions api/core/v1alpha2/vmbdacondition/condition.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Copyright 2024 Flant JSC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package vmbdacondition

type Type = string

const (
BlockDeviceReadyType Type = "BlockDeviceReady"
VirtualMachineReadyType Type = "VirtualMachineReady"
AttachedType Type = "Attached"
)

type (
BlockDeviceReadyReason = string
VirtualMachineReadyReason = string
AttachedReason = string
)

const (
BlockDeviceReady BlockDeviceReadyReason = "BlockDeviceReady"
BlockDeviceNotReady BlockDeviceReadyReason = "BlockDeviceNotReady"

VirtualMachineReady VirtualMachineReadyReason = "VirtualMachineReady"
VirtualMachineNotReady VirtualMachineReadyReason = "VirtualMachineNotReady"

Attached AttachedReason = "Attached"
NotAttached AttachedReason = "NotAttached"
AttachmentRequestSent AttachedReason = "AttachmentRequestSent"
)
9 changes: 8 additions & 1 deletion api/core/v1alpha2/zz_generated.deepcopy.go

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

27 changes: 15 additions & 12 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.

39 changes: 19 additions & 20 deletions crds/doc-ru-virtualimage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,22 @@ spec:
properties:
conditions:
description: |
Последние доступные наблюдения текущего состояния объекта.
properties:
type:
description: Тип состояния.
status:
description: Статус состояния (одно из True, False, Unknown).
message:
description: Cообщение c деталями последнего перехода состояния.
reason:
description: Краткая причина последнего перехода состояния.
lastProbeTime:
description: Время последней проверки состояния.
lastTransitionTime:
description: Время последнего перехода состояния из одного статуса в другой.
Последнее подтвержденное состояние данного ресурса.
items:
properties:
lastProbeTime:
description: Время проверки условия.
lastTransitionTime:
description: Время перехода условия из одного состояния в другое.
message:
description: Удобочитаемое сообщение с подробной информацией о последнем переходе.
reason:
description: Краткая причина последнего перехода состояния.
status:
description: |
Статус условия. Возможные значения: `True`, `False`, `Unknown`.
type:
description: Тип условия.
cdrom:
description: |
Является ли образ форматом, который должен быть смонтирован как cdrom, например iso и т. д.
Expand All @@ -124,12 +126,6 @@ spec:
currentBytes:
description: |
Текущая скорость загрузки в байтах в секунду.
failureMessage:
description: |
Подробное описание ошибки.
failureReason:
description: |
Краткое описание причины ошибки.
format:
description: |
Обнаруженный формат образа.
Expand Down Expand Up @@ -170,3 +166,6 @@ spec:
uploadCommand:
description: |
Команда для загрузки образа для типа 'Upload'.
observedGeneration:
description: |
Поколение ресурса, которое в последний раз обрабатывалось контроллером.
29 changes: 23 additions & 6 deletions crds/doc-ru-virtualmachineblockdeviceattachment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,36 @@ spec:
Имя виртуальной машины, к которой подключен диск.
status:
properties:
failureMessage:
conditions:
description: |
Подробное описание ошибки.
failureReason:
description: |
Краткое описание причины ошибки.
Последнее подтвержденное состояние данного ресурса.
items:
properties:
lastProbeTime:
description: Время проверки условия.
lastTransitionTime:
description: Время перехода условия из одного состояния в другое.
message:
description: Удобочитаемое сообщение с подробной информацией о последнем переходе.
reason:
description: Краткая причина последнего перехода состояния.
status:
description: |
Статус условия. Возможные значения: `True`, `False`, `Unknown`.
type:
description: Тип условия.
phase:
description: |
Фаза ресурса:
* Pending — ресурс был создан и находится в очереди ожидания.
* InProgress — диск в процессе подключения к ВМ.
* Attached — диск подключен к ВМ.
* Failed — возникла проблема с подключением диска. Смотрите `.status.failureReason`.
* Failed — возникла проблема с подключением диска.
* Terminating - Ресурс находится в процессе удаления.
virtualMachineName:
description: |
Имя виртуальной машины, к которой подключен этот диск.
observedGeneration:
description: |
Поколение ресурса, которое в последний раз обрабатывалось контроллером.
2 changes: 1 addition & 1 deletion crds/virtualdisk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ spec:
* WaitForUserUpload - Waiting for the user to upload the image. The endpoint to upload the image is specified in `.status.uploadCommand`.
* Ready - The resource is created and ready to use.
* Resizing — The process of resource resizing is in progress.
* Failed - There was a problem when creating a resource, details can be seen in `.status.failureReason` and `.status.failureMessage`.
* Failed - There was a problem when creating a resource.
* PVCLost - The child PVC of the resource is missing. The resource cannot be used.
* Terminating - The process of resource deletion is in progress.
enum:
Expand Down
40 changes: 18 additions & 22 deletions crds/virtualimage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,40 +193,36 @@ spec:
type: object
properties:
conditions:
type: array
description: |
The latest available observations of an object's current state.
type: array
items:
type: object
properties:
type:
type: string
description: Type of condition.
status:
type: string
description: Status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- "Unknown"
reason:
type: string
description: Reason for the condition's last transition.
message:
type: string
description: |
Human readable message indicating details about last transition.
lastProbeTime:
type: string
description: Last time the condition was checked.
format: date-time
lastTransitionTime:
type: string
lastTransitionTime:
description: Last time the condition transit from one status to another.
format: date-time
type: string
message:
description: Human readable message indicating details about last transition.
type: string
reason:
description: (brief) reason for the condition's last transition.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
enum: ["True", "False", "Unknown"]
type:
description: Type of condition.
type: string
required:
- type
- status
- type
downloadSpeed:
type: object
description: |
Expand Down Expand Up @@ -325,7 +321,7 @@ spec:
observedGeneration:
type: integer
description: |
Represents the .metadata.generation that the status was set based upon.
The generation last processed by the controller.
additionalPrinterColumns:
- name: Phase
type: string
Expand Down
Loading

0 comments on commit 2f489e4

Please sign in to comment.