Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cvi): apply new controller design #111

Merged
merged 2 commits into from
Jun 25, 2024
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
25 changes: 25 additions & 0 deletions .mirrord/mirrord.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"feature": {
"network": {
"incoming": "steal",
"outgoing": true
},
"fs": {
"mode": "read",
"read_only": [ "^/tmp/", "^/var/" ]
},
"env": true
},
"agent": {
"communication_timeout": 6000,
"startup_timeout": 56000
},
"internal_proxy": {
"start_idle_timeout": 13000,
"idle_timeout": 1500
},
"target": {
"namespace": "d8-virtualization",
"path": "deployment/virtualization-controller/container/virtualization-controller"
}
}
4 changes: 3 additions & 1 deletion api/core/v1alpha2/cluster_virtual_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,7 @@ const (
)

type ClusterVirtualImageStatus struct {
ImageStatus `json:",inline"`
ImageStatus `json:",inline"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}
42 changes: 42 additions & 0 deletions api/core/v1alpha2/cvicondition/condition.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
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 cvicondition

type Type = string

const (
DatasourceReadyType Type = "DatasourceReady"
ReadyType Type = "Ready"
)

type (
DatasourceReadyReason = string
ReadyReason = string
)

const (
DatasourceReadyReason_DatasourceReady DatasourceReadyReason = "DatasourceReady"
DatasourceReadyReason_ContainerRegistrySecretNotFound DatasourceReadyReason = "ContainerRegistrySecretNotFound"
DatasourceReadyReason_ImageNotReady DatasourceReadyReason = "ImageNotReady"
DatasourceReadyReason_ClusterImageNotReady DatasourceReadyReason = "ClusterImageNotReady"

ReadyReason_WaitForUserUpload ReadyReason = "WaitForUserUpload"
ReadyReason_Provisioning ReadyReason = "Provisioning"
ReadyReason_ProvisioningNotStarted ReadyReason = "ProvisioningNotStarted"
ReadyReason_ProvisioningFailed ReadyReason = "ProvisioningFailed"
ReadyReason_Ready ReadyReason = "Ready"
)
10 changes: 4 additions & 6 deletions api/core/v1alpha2/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ type Checksum struct {
type DataSourceType string

const (
DataSourceTypeHTTP DataSourceType = "HTTP"
DataSourceTypeContainerImage DataSourceType = "ContainerImage"
DataSourceTypeObjectRef DataSourceType = "ObjectRef"
DataSourceTypeUpload DataSourceType = "Upload"
DataSourceTypeVirtualDiskSnapshot DataSourceType = "VirtualDiskSnapshot"
DataSourceTypePersistentVolumeClaim DataSourceType = "PersistentVolumeClaim"
DataSourceTypeHTTP DataSourceType = "HTTP"
DataSourceTypeContainerImage DataSourceType = "ContainerImage"
DataSourceTypeObjectRef DataSourceType = "ObjectRef"
DataSourceTypeUpload DataSourceType = "Upload"
)
20 changes: 11 additions & 9 deletions api/core/v1alpha2/finalizers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ limitations under the License.
package v1alpha2

const (
FinalizerPodProtection = "virtualization.deckhouse.io/pod-protection"
FinalizerServiceProtection = "virtualization.deckhouse.io/svc-protection"
FinalizerIngressProtection = "virtualization.deckhouse.io/ingress-protection"
FinalizerSecretProtection = "virtualization.deckhouse.io/secret-protection"
FinalizerDVProtection = "virtualization.deckhouse.io/dv-protection"
FinalizerPVCProtection = "virtualization.deckhouse.io/pvc-protection"
FinalizerPVProtection = "virtualization.deckhouse.io/pv-protection"
FinalizerClusterVirtualImageProtection = "virtualization.deckhouse.io/cvi-protection"
FinalizerVirtualDiskProtection = "virtualization.deckhouse.io/vd-protection"
FinalizerPodProtection = "virtualization.deckhouse.io/pod-protection"
FinalizerServiceProtection = "virtualization.deckhouse.io/svc-protection"
FinalizerIngressProtection = "virtualization.deckhouse.io/ingress-protection"
FinalizerSecretProtection = "virtualization.deckhouse.io/secret-protection"
FinalizerDVProtection = "virtualization.deckhouse.io/dv-protection"
FinalizerPVCProtection = "virtualization.deckhouse.io/pvc-protection"
FinalizerPVProtection = "virtualization.deckhouse.io/pv-protection"

FinalizerCVMIProtection = "virtualization.deckhouse.io/cvi-protection"
FinalizerVMIProtection = "virtualization.deckhouse.io/vi-protection"
Expand All @@ -32,9 +34,9 @@ const (
FinalizerVMOPProtection = "virtualization.deckhouse.io/vmop-protection"
FinalizerVMCPUProtection = "virtualization.deckhouse.io/vmcpu-protection"

FinalizerCVMICleanup = "virtualization.deckhouse.io/cvi-cleanup"
FinalizerCVICleanup = "virtualization.deckhouse.io/cvi-cleanup"
FinalizerVDCleanup = "virtualization.deckhouse.io/vd-cleanup"
FinalizerVMICleanup = "virtualization.deckhouse.io/vi-cleanup"
FinalizerVMDCleanup = "virtualization.deckhouse.io/vd-cleanup"
FinalizerVMCleanup = "virtualization.deckhouse.io/vm-cleanup"
FinalizerIPAddressClaimCleanup = "virtualization.deckhouse.io/vmip-cleanup"
FinalizerIPAddressLeaseCleanup = "virtualization.deckhouse.io/vmipl-cleanup"
Expand Down
39 changes: 24 additions & 15 deletions api/core/v1alpha2/image_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,30 @@ const (
ImageFailed ImagePhase = "Failed"
ImagePVCLost ImagePhase = "PVCLost"
ImageUnknown ImagePhase = "Unknown"
ImageTerminating ImagePhase = "Terminating"
)

type ImageStatus struct {
DownloadSpeed ImageStatusSpeed `json:"downloadSpeed"`
Size ImageStatusSize `json:"size"`
Format string `json:"format"`
// FIXME: create ClusterImageStatus without Capacity and PersistentVolumeClaim
Capacity string `json:"capacity,omitempty"`
CDROM bool `json:"cdrom"`
Target ImageStatusTarget `json:"target"`
Phase ImagePhase `json:"phase"`
Progress string `json:"progress,omitempty"`
UploadCommand string `json:"uploadCommand,omitempty"`
FailureReason string `json:"failureReason"`
FailureMessage string `json:"failureMessage"`
Format string `json:"format,omitempty"`
// FIXME: create ClusterImageStatus without Capacity and PersistentVolumeClaim.
Capacity string `json:"capacity,omitempty"`
CDROM bool `json:"cdrom,omitempty"`
Target ImageStatusTarget `json:"target"`
Phase ImagePhase `json:"phase,omitempty"`
Progress string `json:"progress,omitempty"`
UploadCommand string `json:"uploadCommand,omitempty"`
// TODO remove.
FailureReason string `json:"failureReason,omitempty"`
FailureMessage string `json:"failureMessage,omitempty"`
}

type StatusSpeed struct {
Avg string `json:"avg,omitempty"`
AvgBytes string `json:"avgBytes,omitempty"`
Current string `json:"current,omitempty"`
CurrentBytes string `json:"currentBytes,omitempty"`
}

type ImageStatusSpeed struct {
Expand All @@ -51,14 +60,14 @@ type ImageStatusSpeed struct {
}

type ImageStatusSize struct {
Stored string `json:"stored"`
StoredBytes string `json:"storedBytes"`
Unpacked string `json:"unpacked"`
UnpackedBytes string `json:"unpackedBytes"`
Stored string `json:"stored,omitempty"`
StoredBytes string `json:"storedBytes,omitempty"`
Unpacked string `json:"unpacked,omitempty"`
UnpackedBytes string `json:"unpackedBytes,omitempty"`
}

type ImageStatusTarget struct {
RegistryURL string `json:"registryURL"`
RegistryURL string `json:"registryURL,omitempty"`
// FIXME: create ClusterImageStatus without Capacity and PersistentVolumeClaim
PersistentVolumeClaim string `json:"persistentVolumeClaimName,omitempty"`
}
50 changes: 50 additions & 0 deletions api/core/v1alpha2/vdcondition/condition.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
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 vdcondition

type Type = string

const (
DatasourceReadyType Type = "DatasourceReady"
ReadyType Type = "Ready"
ResizedType Type = "Resized"
)

type (
DatasourceReadyReason = string
ReadyReason = string
ResizedReason = string
)

const (
DatasourceReadyReason_DatasourceReady DatasourceReadyReason = "DatasourceReady"
DatasourceReadyReason_ContainerRegistrySecretNotFound DatasourceReadyReason = "ContainerRegistrySecretNotFound"
DatasourceReadyReason_ImageNotReady DatasourceReadyReason = "ImageNotReady"
DatasourceReadyReason_ClusterImageNotReady DatasourceReadyReason = "ClusterImageNotReady"

ReadyReason_WaitForUserUpload ReadyReason = "WaitForUserUpload"
ReadyReason_Provisioning ReadyReason = "Provisioning"
ReadyReason_ProvisioningNotStarted ReadyReason = "ProvisioningNotStarted"
ReadyReason_ProvisioningFailed ReadyReason = "ProvisioningFailed"
ReadyReason_Ready ReadyReason = "Ready"
ReadyReason_Lost ReadyReason = "PVCLost"

ResizedReason_NotRequested ResizedReason = "NotRequested"
ResizedReason_InProgress ResizedReason = "InProgress"
ResizedReason_TooSmallDiskSize ResizedReason = "TooSmallDiskSize"
ResizedReason_Resized ResizedReason = "Resized"
)
30 changes: 18 additions & 12 deletions api/core/v1alpha2/virtual_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,19 @@ type VirtualDiskSpec struct {
}

type VirtualDiskStatus struct {
DownloadSpeed VirtualDiskDownloadSpeed `json:"downloadSpeed"`
Capacity string `json:"capacity,omitempty"`
Target DiskTarget `json:"target"`
Progress string `json:"progress,omitempty"`
UploadCommand string `json:"uploadCommand,omitempty"`
Phase DiskPhase `json:"phase"`
FailureReason string `json:"failureReason"`
FailureMessage string `json:"failureMessage"`
DownloadSpeed VirtualDiskDownloadSpeed `json:"downloadSpeed"`
Capacity string `json:"capacity,omitempty"`
Target DiskTarget `json:"target"`
Progress string `json:"progress,omitempty"`
UploadCommand string `json:"uploadCommand,omitempty"`
Phase DiskPhase `json:"phase"`
AttachedToVirtualMachines []AttachedVirtualMachine `json:"attachedToVirtualMachines,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

type AttachedVirtualMachine struct {
Name string `json:"name"`
}

type VirtualDiskDataSource struct {
Expand Down Expand Up @@ -80,7 +85,7 @@ type VirtualDiskDownloadSpeed struct {
}

type DiskTarget struct {
PersistentVolumeClaim string `json:"persistentVolumeClaimName"`
PersistentVolumeClaim string `json:"persistentVolumeClaimName,omitempty"`
}

type VirtualDiskPersistentVolumeClaim struct {
Expand All @@ -102,8 +107,9 @@ const (
DiskPending DiskPhase = "Pending"
DiskWaitForUserUpload DiskPhase = "WaitForUserUpload"
DiskProvisioning DiskPhase = "Provisioning"
DiskReady DiskPhase = "Ready"
DiskFailed DiskPhase = "Failed"
DiskPVCLost DiskPhase = "PVCLost"
DiskUnknown DiskPhase = "Unknown"
DiskLost DiskPhase = "Lost"
DiskReady DiskPhase = "Ready"
DiskResizing DiskPhase = "Resizing"
DiskTerminating DiskPhase = "Terminating"
)
Loading