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

Bug 1831711: Fix GVK diff to work for special kinds with multiple groups #534

Merged
merged 1 commit into from May 12, 2020

Conversation

alaypatel07
Copy link
Contributor

This implements the fix described here

@mig-ci-robot
Copy link

Can one of the admins verify this patch?

@djwhatle djwhatle marked this pull request as draft May 11, 2020 21:31
@djwhatle djwhatle added the kind/bug Categorizes issue or PR as related to a bug. label May 11, 2020
@djwhatle djwhatle changed the title [WIP]: fix GVK diff to work for special kinds with multiple groups Bug 1831711: Fix GVK diff to work for special kinds with multiple groups May 11, 2020
@djwhatle djwhatle added this to the 1.2.0 milestone May 11, 2020
@djwhatle djwhatle self-requested a review May 11, 2020 21:32
@djwhatle
Copy link
Contributor

\test

@mig-ci-robot
Copy link

✔️ Setup e2e environment
✔️ Login to OCP 3.7
✔️ Login to OCP 4.3
✔️ Build mig-controller image
✔️ Deploy mig-operator on source cluster
✔️ Deploy mig-controller on source cluster
✔️ Deploy mig-operator on destination cluster
✔️ Deploy mig-controller on destination cluster
✔️ Execute migration with test cases : all

Find full build log here
Find instructions to debug here

@djwhatle djwhatle marked this pull request as ready for review May 11, 2020 22:32
pkg/gvk/gvk.go Outdated
if !resourceExist(resource, fingResourceList(srcList.GroupVersion, dst)) {
if cohabitator, found := r.CohabitatingResources[resource.Name]; found {
if cohabitator.seen {
// TODO: need to add log entry
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In mig-controller the logging philosophy is essentially "less is more". We rely heavily on CR conditions to convey information as needed.

mig-controller only writes logs when:

  1. an error occurs
  2. it enters or exits stages in an active migration
  3. controller or watches start/stop

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I would argue that the resulting MigPlan condition conveying GVK diff information would be sufficient, no log message required. Open to counter-argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, not logging here makes sense in this case. Upstream Velero logs here, but I was not sure if we want our controller to log. I'll remove the TODO.

@@ -261,7 +297,7 @@ func compareResources(src []*metav1.APIResourceList, dst []*metav1.APIResourceLi
return missingResources
}

func fingResourceList(groupVersion string, list []*metav1.APIResourceList) []metav1.APIResource {
func findResourceList(groupVersion string, list []*metav1.APIResourceList) []metav1.APIResource {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
}

func NewCohabitatingResources() map[string]*cohabitatingResource {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be exported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I believe so because it is used in another package for instantiation[1].

  1. https://github.com/konveyor/mig-controller/pull/534/files#diff-ff4cf8d4f8669d3270d95d4c88c43266R67

Copy link
Contributor

@djwhatle djwhatle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! This solves the problem we had with GVK diff contents including extra items not actually used in a migration.

@alaypatel07
Copy link
Contributor Author

updated as per review, PTAL whenever you get a chance @djwhatle

Copy link
Contributor

@djwhatle djwhatle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @alaypatel07

}

func NewCohabitatingResources() map[string]*cohabitatingResource {
return map[string]*cohabitatingResource{
Copy link
Contributor

@djwhatle djwhatle May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI for anyone looking on, this is borrowed from Velero source.

Our goal here is to accurately simulate the logic that Velero runs to choose which resource to back up when resources cohabitating in several API groups are present on a source cluster.


// sortResources sources resources by moving extensions to the end of the slice. The order of all
// the other resources is preserved.
func sortResources(resources []*metav1.APIResourceList) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another piece borrowed from Velero to accurately simulate the logic used in Velero to determine which resources should be prioritized in a backup.

@djwhatle
Copy link
Contributor

Closes #531

@djwhatle djwhatle linked an issue May 12, 2020 that may be closed by this pull request
@djwhatle djwhatle merged commit 83e2821 into migtools:master May 12, 2020
djwhatle pushed a commit that referenced this pull request May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. release-1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GVK differ reports incorrectly with multiple groups of same kind
3 participants