Skip to content

Commit 3e0a047

Browse files
init
Signed-off-by: Yaroslav Borbat <[email protected]>
1 parent 5fb3e48 commit 3e0a047

File tree

75 files changed

+1059
-573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1059
-573
lines changed

api/core/v1alpha2/vdcondition/condition.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const (
3636
StorageClassReadyType Type = "StorageClassReady"
3737
// InUseType indicates whether the VirtualDisk is attached to a running VirtualMachine or is being used in a process of an image creation.
3838
InUseType Type = "InUse"
39+
// MigrationType indicates whether the VirtualDisk is being volume migrating.
40+
MigrationType Type = "Migration"
3941
)
4042

4143
type (
@@ -51,6 +53,8 @@ type (
5153
StorageClassReadyReason string
5254
// InUseReason represents the various reasons for the InUse condition type.
5355
InUseReason string
56+
// MigrationReason represents the various reasons for the Migration condition type.
57+
MigrationReason string
5458
)
5559

5660
func (s DatasourceReadyReason) String() string {
@@ -77,6 +81,10 @@ func (s InUseReason) String() string {
7781
return string(s)
7882
}
7983

84+
func (s MigrationReason) String() string {
85+
return string(s)
86+
}
87+
8088
const (
8189
// DatasourceReady indicates that the datasource is ready for use, allowing the import process to start.
8290
DatasourceReady DatasourceReadyReason = "DatasourceReady"
@@ -168,3 +176,7 @@ const (
168176
// NotInUse indicates that VirtualDisk free for use.
169177
NotInUse InUseReason = "NotInUse"
170178
)
179+
180+
const (
181+
MigratingReason MigrationReason = "Migrating"
182+
)

api/core/v1alpha2/virtual_disk.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ type VirtualDiskStatus struct {
7979
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
8080
// Name of the StorageClass used by the PersistentVolumeClaim if `Kubernetes` storage type is used.
8181
StorageClassName string `json:"storageClassName,omitempty"`
82+
83+
// Migration information.
84+
MigrationInfo *VirtualDiskMigrationInfo `json:"migrationInfo,omitempty"`
85+
// Migration requests.
86+
MigrationRequests []VirtualDiskMigrationRequest `json:"migrationRequest,omitempty"`
8287
}
8388

8489
// VirtualDisk statistics.
@@ -198,6 +203,7 @@ type VirtualDiskList struct {
198203
// * `PVCLost`: The child PVC of the resource is missing. The resource cannot be used.
199204
// * `Exporting`: The child PV of the resource is in the process of exporting.
200205
// * `Terminating`: The resource is being deleted.
206+
// * `Migrating`: The resource is being migrating.
201207
// +kubebuilder:validation:Enum:={Pending,Provisioning,WaitForUserUpload,WaitForFirstConsumer,Ready,Resizing,Failed,PVCLost,Exporting,Terminating}
202208
type DiskPhase string
203209

@@ -212,4 +218,27 @@ const (
212218
DiskLost DiskPhase = "PVCLost"
213219
DiskExporting DiskPhase = "Exporting"
214220
DiskTerminating DiskPhase = "Terminating"
221+
DiskMigrating DiskPhase = "Migrating"
222+
)
223+
224+
type VirtualDiskMigrationInfo struct {
225+
// Source PersistentVolumeClaim name.
226+
SourcePVC string `json:"sourcePVC,omitempty"`
227+
// Target PersistentVolumeClaim name.
228+
TargetPVC string `json:"targetPVC,omitempty"`
229+
Completed bool `json:"completed"`
230+
Failed bool `json:"failed"`
231+
}
232+
233+
type VirtualDiskMigrationRequest struct {
234+
Action VirtualDiskMigrationRequestAction `json:"action"`
235+
Requester string `json:"requester"`
236+
StorageClassName string `json:"storageClassName"`
237+
}
238+
239+
type VirtualDiskMigrationRequestAction string
240+
241+
const (
242+
VirtualDiskMigrationRequestActionMigrate VirtualDiskMigrationRequestAction = "migrate"
243+
VirtualDiskMigrationRequestActionRevert VirtualDiskMigrationRequestAction = "revert"
215244
)

api/core/v1alpha2/zz_generated.deepcopy.go

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/pkg/apiserver/api/generated/openapi/zz_generated.openapi.go

Lines changed: 98 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crds/virtualdisks.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,39 @@ spec:
366366
the cluster.
367367
type: string
368368
type: object
369+
migrationInfo:
370+
description: Migration information.
371+
properties:
372+
completed:
373+
type: boolean
374+
failed:
375+
type: boolean
376+
sourcePVC:
377+
description: Source PersistentVolumeClaim name.
378+
type: string
379+
targetPVC:
380+
description: Target PersistentVolumeClaim name.
381+
type: string
382+
required:
383+
- completed
384+
- failed
385+
type: object
386+
migrationRequest:
387+
description: Migration requests.
388+
items:
389+
properties:
390+
action:
391+
type: string
392+
requester:
393+
type: string
394+
storageClassName:
395+
type: string
396+
required:
397+
- action
398+
- requester
399+
- storageClassName
400+
type: object
401+
type: array
369402
observedGeneration:
370403
description: Resource generation last processed by the controller.
371404
format: int64
@@ -383,6 +416,7 @@ spec:
383416
* `PVCLost`: The child PVC of the resource is missing. The resource cannot be used.
384417
* `Exporting`: The child PV of the resource is in the process of exporting.
385418
* `Terminating`: The resource is being deleted.
419+
* `Migrating`: The resource is being migrating.
386420
enum:
387421
- Pending
388422
- Provisioning

images/virtualization-artifact/pkg/common/annotations/annotations.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ const (
155155
AnnNetworksSpec = "network.deckhouse.io/networks-spec"
156156
// AnnNetworksStatus is the annotation for view current network configuration into Pod.
157157
AnnNetworksStatus = "network.deckhouse.io/networks-status"
158+
159+
AnnVolumeMigrationRequest = "virtualization.deckhouse.io/volume-migration-request"
160+
AnnVolumeMigrationStatus = "virtualization.deckhouse.io/volume-migration-status"
158161
)
159162

160163
// AddAnnotation adds an annotation to an object

images/virtualization-artifact/pkg/common/pwgen/pwgen.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ func generateString(length int, chars string) string {
3939
func AlphaNum(length int) string {
4040
return generateString(length, alphaNum)
4141
}
42+
43+
func LowerAlpha(length int) string {
44+
return generateString(length, lowercaseAlpha)
45+
}

images/virtualization-artifact/pkg/controller/cvi/internal/source/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func (ds HTTPDataSource) Validate(_ context.Context, _ *virtv2.ClusterVirtualIma
235235
return nil
236236
}
237237

238-
func (ds HTTPDataSource) getEnvSettings(cvi *virtv2.ClusterVirtualImage, supgen *supplements.Generator) *importer.Settings {
238+
func (ds HTTPDataSource) getEnvSettings(cvi *virtv2.ClusterVirtualImage, supgen supplements.Generator) *importer.Settings {
239239
var settings importer.Settings
240240

241241
importer.ApplyHTTPSourceSettings(&settings, cvi.Spec.DataSource.HTTP, supgen)

images/virtualization-artifact/pkg/controller/cvi/internal/source/interfaces.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
netv1 "k8s.io/api/networking/v1"
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2525
"k8s.io/apimachinery/pkg/types"
26+
"sigs.k8s.io/controller-runtime/pkg/client"
2627

2728
"github.com/deckhouse/virtualization-controller/pkg/common/datasource"
2829
"github.com/deckhouse/virtualization-controller/pkg/controller/importer"
@@ -35,23 +36,23 @@ import (
3536
//go:generate go tool moq -rm -out mock.go . Importer Uploader Stat
3637

3738
type Importer interface {
38-
Start(ctx context.Context, settings *importer.Settings, obj service.ObjectKind, sup *supplements.Generator, caBundle *datasource.CABundle, opts ...service.Option) error
39-
StartWithPodSetting(ctx context.Context, settings *importer.Settings, sup *supplements.Generator, caBundle *datasource.CABundle, podSettings *importer.PodSettings) error
40-
CleanUp(ctx context.Context, sup *supplements.Generator) (bool, error)
41-
CleanUpSupplements(ctx context.Context, sup *supplements.Generator) (bool, error)
42-
GetPod(ctx context.Context, sup *supplements.Generator) (*corev1.Pod, error)
43-
DeletePod(ctx context.Context, obj service.ObjectKind, controllerName string) (bool, error)
39+
Start(ctx context.Context, settings *importer.Settings, obj client.Object, sup supplements.Generator, caBundle *datasource.CABundle, opts ...service.Option) error
40+
StartWithPodSetting(ctx context.Context, settings *importer.Settings, sup supplements.Generator, caBundle *datasource.CABundle, podSettings *importer.PodSettings) error
41+
CleanUp(ctx context.Context, sup supplements.Generator) (bool, error)
42+
CleanUpSupplements(ctx context.Context, sup supplements.Generator) (bool, error)
43+
GetPod(ctx context.Context, sup supplements.Generator) (*corev1.Pod, error)
44+
DeletePod(ctx context.Context, obj client.Object, controllerName string) (bool, error)
4445
Protect(ctx context.Context, pod *corev1.Pod) error
4546
Unprotect(ctx context.Context, pod *corev1.Pod) error
46-
GetPodSettingsWithPVC(ownerRef *metav1.OwnerReference, sup *supplements.Generator, pvcName, pvcNamespace string) *importer.PodSettings
47+
GetPodSettingsWithPVC(ownerRef *metav1.OwnerReference, sup supplements.Generator, pvcName, pvcNamespace string) *importer.PodSettings
4748
}
4849

4950
type Uploader interface {
50-
Start(ctx context.Context, settings *uploader.Settings, obj service.ObjectKind, sup *supplements.Generator, caBundle *datasource.CABundle, opts ...service.Option) error
51-
CleanUp(ctx context.Context, sup *supplements.Generator) (bool, error)
52-
GetPod(ctx context.Context, sup *supplements.Generator) (*corev1.Pod, error)
53-
GetIngress(ctx context.Context, sup *supplements.Generator) (*netv1.Ingress, error)
54-
GetService(ctx context.Context, sup *supplements.Generator) (*corev1.Service, error)
51+
Start(ctx context.Context, settings *uploader.Settings, obj client.Object, sup supplements.Generator, caBundle *datasource.CABundle, opts ...service.Option) error
52+
CleanUp(ctx context.Context, sup supplements.Generator) (bool, error)
53+
GetPod(ctx context.Context, sup supplements.Generator) (*corev1.Pod, error)
54+
GetIngress(ctx context.Context, sup supplements.Generator) (*netv1.Ingress, error)
55+
GetService(ctx context.Context, sup supplements.Generator) (*corev1.Service, error)
5556
Protect(ctx context.Context, pod *corev1.Pod, svc *corev1.Service, ing *netv1.Ingress) error
5657
Unprotect(ctx context.Context, pod *corev1.Pod, svc *corev1.Service, ing *netv1.Ingress) error
5758
GetExternalURL(ctx context.Context, ing *netv1.Ingress) string

0 commit comments

Comments
 (0)