Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,25 @@ func KeepNodePlacementTolerations(nodePlacement *NodePlacement, obj client.Objec

return nil
}

var systemNodeToleration = corev1.Toleration{
Key: "dedicated.deckhouse.io",
Operator: corev1.TolerationOpEqual,
Value: "system",
}

func AddTolerationForSystemNodes(placement *NodePlacement) {
if placement == nil {
return
}
hasSystem := false
for _, toleration := range placement.Tolerations {
if toleration.Key == systemNodeToleration.Key && toleration.Value == systemNodeToleration.Value {
hasSystem = true
break
}
}
if !hasSystem {
placement.Tolerations = append(placement.Tolerations, systemNodeToleration)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (ds HTTPDataSource) Sync(ctx context.Context, cvi *v1alpha2.ClusterVirtualI
cvi.Status.Progress = ds.statService.GetProgress(cvi.GetUID(), pod, cvi.Status.Progress)

envSettings := ds.getEnvSettings(cvi, supgen)
err = ds.importerService.Start(ctx, envSettings, cvi, supgen, datasource.NewCABundleForCVMI(cvi.Spec.DataSource))
err = ds.importerService.Start(ctx, envSettings, cvi, supgen, datasource.NewCABundleForCVMI(cvi.Spec.DataSource), service.WithSystemNodeToleration())
switch {
case err == nil:
// OK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (

type Importer interface {
Start(ctx context.Context, settings *importer.Settings, obj client.Object, sup supplements.Generator, caBundle *datasource.CABundle, opts ...service.Option) error
StartWithPodSetting(ctx context.Context, settings *importer.Settings, sup supplements.Generator, caBundle *datasource.CABundle, podSettings *importer.PodSettings) error
StartWithPodSetting(ctx context.Context, settings *importer.Settings, sup supplements.Generator, caBundle *datasource.CABundle, podSettings *importer.PodSettings, opts ...service.Option) error
CleanUp(ctx context.Context, sup supplements.Generator) (bool, error)
CleanUpSupplements(ctx context.Context, sup supplements.Generator) (bool, error)
GetPod(ctx context.Context, sup supplements.Generator) (*corev1.Pod, error)
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (ds ObjectRefDataSource) Sync(ctx context.Context, cvi *v1alpha2.ClusterVir
return reconcile.Result{}, err
}

err = ds.importerService.Start(ctx, envSettings, cvi, supgen, datasource.NewCABundleForCVMI(cvi.Spec.DataSource))
err = ds.importerService.Start(ctx, envSettings, cvi, supgen, datasource.NewCABundleForCVMI(cvi.Spec.DataSource), service.WithSystemNodeToleration())
switch {
case err == nil:
// OK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (ds ObjectRefVirtualDisk) Sync(ctx context.Context, cvi *v1alpha2.ClusterVi

ownerRef := metav1.NewControllerRef(cvi, cvi.GroupVersionKind())
podSettings := ds.importerService.GetPodSettingsWithPVC(ownerRef, supgen, vdRef.Status.Target.PersistentVolumeClaim, vdRef.Namespace)
err = ds.importerService.StartWithPodSetting(ctx, envSettings, supgen, datasource.NewCABundleForCVMI(cvi.Spec.DataSource), podSettings)
err = ds.importerService.StartWithPodSetting(ctx, envSettings, supgen, datasource.NewCABundleForCVMI(cvi.Spec.DataSource), podSettings, service.WithSystemNodeToleration())
switch {
case err == nil:
// OK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (ds ObjectRefVirtualDiskSnapshot) Sync(ctx context.Context, cvi *v1alpha2.C

ownerRef := metav1.NewControllerRef(cvi, cvi.GroupVersionKind())
podSettings := ds.importerService.GetPodSettingsWithPVC(ownerRef, supgen, pvc.Name, pvc.Namespace)
err = ds.importerService.StartWithPodSetting(ctx, envSettings, supgen, datasource.NewCABundleForCVMI(cvi.Spec.DataSource), podSettings)
err = ds.importerService.StartWithPodSetting(ctx, envSettings, supgen, datasource.NewCABundleForCVMI(cvi.Spec.DataSource), podSettings, service.WithSystemNodeToleration())
switch {
case err == nil:
// OK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (ds ObjectRefVirtualImageOnPvc) Sync(ctx context.Context, cvi *v1alpha2.Clu

ownerRef := metav1.NewControllerRef(cvi, cvi.GroupVersionKind())
podSettings := ds.importerService.GetPodSettingsWithPVC(ownerRef, supgen, viRef.Status.Target.PersistentVolumeClaim, viRef.Namespace)
err = ds.importerService.StartWithPodSetting(ctx, envSettings, supgen, datasource.NewCABundleForCVMI(cvi.Spec.DataSource), podSettings)
err = ds.importerService.StartWithPodSetting(ctx, envSettings, supgen, datasource.NewCABundleForCVMI(cvi.Spec.DataSource), podSettings, service.WithSystemNodeToleration())
switch {
case err == nil:
// OK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (ds RegistryDataSource) Sync(ctx context.Context, cvi *v1alpha2.ClusterVirt
cvi.Status.Progress = "0%"

envSettings := ds.getEnvSettings(cvi, supgen)
err = ds.importerService.Start(ctx, envSettings, cvi, supgen, datasource.NewCABundleForCVMI(cvi.Spec.DataSource))
err = ds.importerService.Start(ctx, envSettings, cvi, supgen, datasource.NewCABundleForCVMI(cvi.Spec.DataSource), service.WithSystemNodeToleration())
switch {
case err == nil:
// OK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (ds UploadDataSource) Sync(ctx context.Context, cvi *v1alpha2.ClusterVirtua
log.Info("Cleaning up...")
case pod == nil || svc == nil || ing == nil:
envSettings := ds.getEnvSettings(cvi, supgen)
err = ds.uploaderService.Start(ctx, envSettings, cvi, supgen, datasource.NewCABundleForCVMI(cvi.Spec.DataSource))
err = ds.uploaderService.Start(ctx, envSettings, cvi, supgen, datasource.NewCABundleForCVMI(cvi.Spec.DataSource), service.WithSystemNodeToleration())
switch {
case err == nil:
// OK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,12 @@ func WithNodePlacement(nodePlacement *provisioner.NodePlacement) Option {
o.nodePlacement = nodePlacement
}
}

func WithSystemNodeToleration() Option {
return func(o *genericOptions) {
if o.nodePlacement == nil {
o.nodePlacement = &provisioner.NodePlacement{}
}
provisioner.AddTolerationForSystemNodes(o.nodePlacement)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,21 @@ func (s ImporterService) Start(
return supplements.EnsureForPod(ctx, s.client, sup, pod, caBundle, s.dvcrSettings)
}

func (s ImporterService) StartWithPodSetting(ctx context.Context, settings *importer.Settings, sup supplements.Generator, caBundle *datasource.CABundle, podSettings *importer.PodSettings) error {
func (s ImporterService) StartWithPodSetting(
ctx context.Context,
settings *importer.Settings,
sup supplements.Generator,
caBundle *datasource.CABundle,
podSettings *importer.PodSettings,
opts ...Option,
) error {
options := newGenericOptions(opts...)
settings.Verbose = s.verbose

podSettings.Finalizer = s.protection.finalizer
if options.nodePlacement != nil {
podSettings.NodePlacement = options.nodePlacement
}

pod, err := importer.NewImporter(podSettings, settings).GetOrCreatePod(ctx, s.client)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (ds HTTPDataSource) StoreToDVCR(ctx context.Context, vi *v1alpha2.VirtualIm

envSettings := ds.getEnvSettings(vi, supgen)

err = ds.importerService.Start(ctx, envSettings, vi, supgen, datasource.NewCABundleForVMI(vi.GetNamespace(), vi.Spec.DataSource))
err = ds.importerService.Start(ctx, envSettings, vi, supgen, datasource.NewCABundleForVMI(vi.GetNamespace(), vi.Spec.DataSource), service.WithSystemNodeToleration())
switch {
case err == nil:
// OK.
Expand Down Expand Up @@ -247,7 +247,7 @@ func (ds HTTPDataSource) StoreToPVC(ctx context.Context, vi *v1alpha2.VirtualIma
vi.Status.Progress = ds.statService.GetProgress(vi.GetUID(), pod, vi.Status.Progress)

envSettings := ds.getEnvSettings(vi, supgen)
err = ds.importerService.Start(ctx, envSettings, vi, supgen, datasource.NewCABundleForVMI(vi.GetNamespace(), vi.Spec.DataSource))
err = ds.importerService.Start(ctx, envSettings, vi, supgen, datasource.NewCABundleForVMI(vi.GetNamespace(), vi.Spec.DataSource), service.WithSystemNodeToleration())
switch {
case err == nil:
// OK.
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func (ds ObjectRefDataSource) StoreToDVCR(ctx context.Context, vi *v1alpha2.Virt
return reconcile.Result{}, err
}

err = ds.importerService.Start(ctx, envSettings, vi, supgen, datasource.NewCABundleForVMI(vi.GetNamespace(), vi.Spec.DataSource))
err = ds.importerService.Start(ctx, envSettings, vi, supgen, datasource.NewCABundleForVMI(vi.GetNamespace(), vi.Spec.DataSource), service.WithSystemNodeToleration())
switch {
case err == nil:
// OK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (ds ObjectRefVirtualDisk) StoreToDVCR(ctx context.Context, vi *v1alpha2.Vir

ownerRef := metav1.NewControllerRef(vi, vi.GroupVersionKind())
podSettings := ds.importerService.GetPodSettingsWithPVC(ownerRef, supgen, vdRef.Status.Target.PersistentVolumeClaim, vdRef.Namespace)
err = ds.importerService.StartWithPodSetting(ctx, envSettings, supgen, datasource.NewCABundleForVMI(vi.GetNamespace(), vi.Spec.DataSource), podSettings)
err = ds.importerService.StartWithPodSetting(ctx, envSettings, supgen, datasource.NewCABundleForVMI(vi.GetNamespace(), vi.Spec.DataSource), podSettings, service.WithSystemNodeToleration())
switch {
case err == nil:
// OK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ var _ = Describe("ObjectRef VirtualImageSnapshot ContainerRegistry", func() {
importer.GetPodSettingsWithPVCFunc = func(_ *metav1.OwnerReference, _ supplements.Generator, _, _ string) *importer2.PodSettings {
return nil
}
importer.StartWithPodSettingFunc = func(_ context.Context, _ *importer2.Settings, _ supplements.Generator, _ *datasource.CABundle, _ *importer2.PodSettings) error {
importer.StartWithPodSettingFunc = func(_ context.Context, _ *importer2.Settings, _ supplements.Generator, _ *datasource.CABundle, _ *importer2.PodSettings, _ ...service.Option) error {
podCreated = true
return nil
}
Expand Down Expand Up @@ -321,6 +321,7 @@ var _ = Describe("ObjectRef VirtualImageSnapshot ContainerRegistry", func() {
})

func ExpectCondition(vi *v1alpha2.VirtualImage, status metav1.ConditionStatus, reason vicondition.ReadyReason, msgExists bool) {
GinkgoHelper()
ready, _ := conditions.GetCondition(vicondition.Ready, vi.Status.Conditions)
Expect(ready.Status).To(Equal(status))
Expect(ready.Reason).To(Equal(reason.String()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (ds ObjectRefDataVirtualImageOnPVC) StoreToDVCR(ctx context.Context, vi, vi

ownerRef := metav1.NewControllerRef(vi, vi.GroupVersionKind())
podSettings := ds.importerService.GetPodSettingsWithPVC(ownerRef, supgen, viRef.Status.Target.PersistentVolumeClaim, viRef.Namespace)
err = ds.importerService.StartWithPodSetting(ctx, envSettings, supgen, datasource.NewCABundleForVMI(vi.GetNamespace(), vi.Spec.DataSource), podSettings)
err = ds.importerService.StartWithPodSetting(ctx, envSettings, supgen, datasource.NewCABundleForVMI(vi.GetNamespace(), vi.Spec.DataSource), podSettings, service.WithSystemNodeToleration())
switch {
case err == nil:
// OK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (ds RegistryDataSource) StoreToPVC(ctx context.Context, vi *v1alpha2.Virtua
vi.Status.Progress = "0%"

envSettings := ds.getEnvSettings(vi, supgen)
err = ds.importerService.Start(ctx, envSettings, vi, supgen, datasource.NewCABundleForVMI(vi.GetNamespace(), vi.Spec.DataSource))
err = ds.importerService.Start(ctx, envSettings, vi, supgen, datasource.NewCABundleForVMI(vi.GetNamespace(), vi.Spec.DataSource), service.WithSystemNodeToleration())
switch {
case err == nil:
// OK.
Expand Down Expand Up @@ -324,7 +324,7 @@ func (ds RegistryDataSource) StoreToDVCR(ctx context.Context, vi *v1alpha2.Virtu
vi.Status.Progress = "0%"

envSettings := ds.getEnvSettings(vi, supgen)
err = ds.importerService.Start(ctx, envSettings, vi, supgen, datasource.NewCABundleForVMI(vi.GetNamespace(), vi.Spec.DataSource))
err = ds.importerService.Start(ctx, envSettings, vi, supgen, datasource.NewCABundleForVMI(vi.GetNamespace(), vi.Spec.DataSource), service.WithSystemNodeToleration())
switch {
case err == nil:
// OK.
Expand Down
Loading
Loading