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

Backport to 2.7.5 #1227

Merged
merged 2 commits into from
Nov 28, 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
2 changes: 1 addition & 1 deletion pkg/controller/plan/adapter/vsphere/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ func (r *Builder) mapNetworks(vm *model.VM, object *cnv.VirtualMachineSpec) (err
needed := []vsphere.NIC{}
for _, nic := range vm.NICs {
switch network.Variant {
case vsphere.NetDvPortGroup:
case vsphere.NetDvPortGroup, vsphere.OpaqueNetwork:
if nic.Network.ID == network.Key {
needed = append(needed, nic)
}
Expand Down
29 changes: 17 additions & 12 deletions pkg/controller/plan/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/konveyor/forklift-controller/pkg/settings"
batchv1 "k8s.io/api/batch/v1"
core "k8s.io/api/core/v1"
k8serr "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -1622,23 +1623,27 @@ func (r *Migration) updateCopyProgress(vm *plan.VMStatus, step *plan.Step) (err
path.Join(dv.Namespace, dv.Name))
continue
}
primePvc := &core.PersistentVolumeClaim{}
err = r.Destination.Client.Get(context.TODO(), types.NamespacedName{
Namespace: r.Plan.Spec.TargetNamespace,
Name: fmt.Sprintf("prime-%s", pvc.UID),
}, primePvc)
}, pvc)
if err != nil {
log.Error(
err,
"Could not get prime PVC for DataVolume.",
"vm",
vm.String(),
"dv",
path.Join(dv.Namespace, dv.Name))
continue
if k8serr.IsNotFound(err) {
log.Info("Could not find prime PVC")
// Ignore error
err = nil
} else {
log.Error(
err,
"Could not get prime PVC for DataVolume.",
"vm",
vm.String(),
"dv",
path.Join(dv.Namespace, dv.Name))
continue
}
}

importer, found, kErr = r.kubevirt.GetImporterPod(*primePvc)
importer, found, kErr = r.kubevirt.GetImporterPod(*pvc)
}

if kErr != nil {
Expand Down
22 changes: 21 additions & 1 deletion pkg/controller/provider/container/vsphere/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
ComputeResource = "ComputeResource"
Host = "HostSystem"
Network = "Network"
OpaqueNetwork = "OpaqueNetwork"
DVPortGroup = "DistributedVirtualPortgroup"
DVSwitch = "VmwareDistributedVirtualSwitch"
Datastore = "Datastore"
Expand Down Expand Up @@ -83,7 +84,8 @@ const (
fThumbprint = "summary.config.sslThumbprint"
fMgtServerIp = "summary.managementServerIp"
// Network
fTag = "tag"
fTag = "tag"
fSummary = "summary"
// PortGroup
fDVSwitch = "config.distributedVirtualSwitch"
fKey = "key"
Expand Down Expand Up @@ -671,6 +673,15 @@ func (r *Collector) propertySpec() []types.PropertySpec {
fTag,
},
},
{
Type: OpaqueNetwork,
PathSet: []string{
fName,
fParent,
fTag,
fSummary,
},
},
{
Type: DVPortGroup,
PathSet: []string{
Expand Down Expand Up @@ -823,6 +834,15 @@ func (r *Collector) selectAdapter(u types.ObjectUpdate) (Adapter, bool) {
},
},
}
case OpaqueNetwork:
adapter = &NetworkAdapter{
model: model.Network{
Base: model.Base{
Variant: model.OpaqueNetwork,
ID: u.Obj.Value,
},
},
}
case DVPortGroup:
adapter = &NetworkAdapter{
model: model.Network{
Expand Down
6 changes: 6 additions & 0 deletions pkg/controller/provider/container/vsphere/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ func (v *NetworkAdapter) Apply(u types.ObjectUpdate) {
}
case fDVSwitch:
v.model.DVSwitch = v.Ref(p.Val)
case fSummary:
if s, cast := p.Val.(types.OpaqueNetworkSummary); cast {
v.model.Key = s.OpaqueNetworkId
}
}
}
}
Expand Down Expand Up @@ -704,6 +708,8 @@ func (v *VmAdapter) Apply(u types.ObjectUpdate) {
}
case *types.VirtualEthernetCardDistributedVirtualPortBackingInfo:
network = backing.Port.PortgroupKey
case *types.VirtualEthernetCardOpaqueNetworkBackingInfo:
network = backing.OpaqueNetworkId
}

devList = append(
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/provider/model/vsphere/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const (
// Network.
NetStandard = "Standard"
NetDvPortGroup = "DvPortGroup"
OpaqueNetwork = "OpaqueNetwork"
NetDvSwitch = "DvSwitch"
// Cluster.
ComputeResource = "ComputeResource"
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/provider/web/vsphere/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ func (r *Network) With(m *model.Network) {
case model.NetDvPortGroup:
r.DVSwitch = &m.DVSwitch
r.Key = m.Key
case model.OpaqueNetwork:
r.Key = m.Key
case model.NetDvSwitch:
r.Host = m.Host
}
Expand Down
Loading