Skip to content

Commit

Permalink
MTV-1536 | Use CDI for disk transfer in cold migration feature toggle
Browse files Browse the repository at this point in the history
Issue:
This is alternative to kubev2v#1109
which removes the virt-v2v disk transfer and replaces it with te CDI.
The main dissadvatage of that solution is that in case customer will
have problems with the new CDI method there won't be any easy way how to
go back, to the virt-v2v.

Fix:
This change adds a new feature toggle `feature_vsphere_cold_cdi` in the
forklift controller. By default the feature will be enabled and in case
there will be problems such as disk corruption the user can disable it.

Signed-off-by: Martin Necas <[email protected]>
  • Loading branch information
mnecas committed Nov 5, 2024
1 parent ba19a21 commit ad4648e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions operator/roles/forkliftcontroller/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ app_namespace: "{{ lookup( 'env', 'WATCH_NAMESPACE') or 'konveyor-forklift' }}"
feature_ui_plugin: true
feature_validation: true
feature_volume_populator: true
feature_vsphere_cold_cdi: true

k8s_cluster: false
feature_auth_required: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ spec:
{% if virt_customize_configmap_name is defined %}
- name: VIRT_CUSTOMIZE_MAP
value: {{ virt_customize_configmap_name }}
{% endif %}
- name: VSPHERE_COLD_CDI
{% if feature_vsphere_cold_cdi|bool %}
value: "true"
{% else %}
value: "false"
{% endif %}
{% if controller_profile_kind is defined and controller_profile_path is defined and controller_profile_duration is defined %}
- name: PROFILE_KIND
Expand Down
20 changes: 19 additions & 1 deletion pkg/apis/forklift/v1beta1/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ limitations under the License.
package v1beta1

import (
"os"
"strconv"

"github.com/konveyor/forklift-controller/pkg/apis/forklift/v1beta1/plan"
"github.com/konveyor/forklift-controller/pkg/apis/forklift/v1beta1/provider"
"github.com/konveyor/forklift-controller/pkg/apis/forklift/v1beta1/ref"
Expand Down Expand Up @@ -93,6 +96,16 @@ type Plan struct {
Referenced `json:"-"`
}

// useCdiForColdMigration this is feature toggle which can be controlled by the user,
// to enable or disable the CDI import instead of v2v disk transfer
func (p *Plan) useCdiForColdMigration() (bool, error) {
resp, err := strconv.ParseBool(os.Getenv("VSPHERE_COLD_CDI"))
if err != nil {
return false, err
}
return resp, nil
}

// If the plan calls for the vm to be cold migrated to the local cluster, we can
// just use virt-v2v directly to convert the vm while copying data over. In other
// cases, we use CDI to transfer disks to the destination cluster and then use
Expand All @@ -107,9 +120,14 @@ func (p *Plan) VSphereColdLocal() (bool, error) {
return false, liberr.New("Cannot analyze plan, destination provider is missing.")
}

useCdiForColdMigration, err := p.useCdiForColdMigration()
if err != nil {
return false, err
}

switch source.Type() {
case VSphere:
return !p.Spec.Warm && destination.IsHost(), nil
return !p.Spec.Warm && destination.IsHost() && !useCdiForColdMigration, nil
case Ova:
return true, nil
default:
Expand Down

0 comments on commit ad4648e

Please sign in to comment.