diff --git a/pkg/controller/plan/adapter/vsphere/BUILD.bazel b/pkg/controller/plan/adapter/vsphere/BUILD.bazel index 74a5ba7e7..66ecd8c86 100644 --- a/pkg/controller/plan/adapter/vsphere/BUILD.bazel +++ b/pkg/controller/plan/adapter/vsphere/BUILD.bazel @@ -27,6 +27,7 @@ go_library( "//pkg/lib/condition", "//pkg/lib/error", "//pkg/lib/itinerary", + "//pkg/lib/ref", "//pkg/settings", "//vendor/github.com/vmware/govmomi", "//vendor/github.com/vmware/govmomi/find", diff --git a/pkg/controller/plan/adapter/vsphere/builder.go b/pkg/controller/plan/adapter/vsphere/builder.go index cad607afe..3e58bcac2 100644 --- a/pkg/controller/plan/adapter/vsphere/builder.go +++ b/pkg/controller/plan/adapter/vsphere/builder.go @@ -24,6 +24,7 @@ import ( libcnd "github.com/konveyor/forklift-controller/pkg/lib/condition" liberr "github.com/konveyor/forklift-controller/pkg/lib/error" libitr "github.com/konveyor/forklift-controller/pkg/lib/itinerary" + libref "github.com/konveyor/forklift-controller/pkg/lib/ref" "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/types" core "k8s.io/api/core/v1" @@ -787,6 +788,10 @@ func (r *Builder) loadHosts() (err error) { for i := range list.Items { host := &list.Items[i] ref := host.Spec.Ref + if !libref.Equals(&host.Spec.Provider, &r.Plan.Spec.Provider.Source) { + continue + } + if !host.Status.HasCondition(libcnd.Ready) { continue } diff --git a/pkg/lib/ref/ref.go b/pkg/lib/ref/ref.go index b3f4185ba..395afe025 100644 --- a/pkg/lib/ref/ref.go +++ b/pkg/lib/ref/ref.go @@ -33,10 +33,19 @@ func RefSet(ref *v1.ObjectReference) bool { // Equals comparison. // May be used with `nil` pointers. -func Equals(refA, refB *v1.ObjectReference) bool { +func DeepEquals(refA, refB *v1.ObjectReference) bool { if refA == nil || refB == nil { return false } return reflect.DeepEqual(refA, refB) } + +// Determind if both refs have the same name and namespace +func Equals(refA, refB *v1.ObjectReference) bool { + if refA == nil || refB == nil { + return refA == refB + } + + return refA.Name == refB.Name && refA.Namespace == refB.Namespace +}