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

Migration plan resources (DEBUG) view shows all PVRs/PVBs. This should be a filtered list. #1049

Closed
djwhatle opened this issue Oct 29, 2020 · 2 comments · Fixed by migtools/mig-controller#723
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@djwhatle
Copy link
Contributor

djwhatle commented Oct 29, 2020

Fix posted: migtools/mig-controller#723

Debug view shows all PodVolumeRestores instead of only the PodVolumeRestores owned by my Velero Restore.
Seeing the same problem with PodVolumeBackups.

Using latest controller, latest mig-ui

image


 `Restore` `"6f4dd5c0-1942-11eb-8198-914427d8f387-jkgr8"`
  >> `PodVolumeRestore` `"90e2a400-1937-11eb-8198-914427d8f387-nkrdb-s2kxn"`
  >>>> OwnerReferences [
  {
    "apiVersion": "velero.io/v1",
    "kind": "Restore",
    "name": "90e2a400-1937-11eb-8198-914427d8f387-nkrdb",  <<<< THIS IS != the Restore above.
    "uid": "17290d0c-2511-4e0b-abdf-e1d477c0a7cf",
    "controller": true
  }
]
@djwhatle djwhatle added the kind/bug Categorizes issue or PR as related to a bug. label Oct 29, 2020
@djwhatle
Copy link
Contributor Author

djwhatle commented Oct 29, 2020

The discovery service tree endpoint is giving back the results shown in the UI, fix will likely be there.

{
    "kind": "Plan",
    "namespace": "openshift-migration",
    "name": "plan-foo",
    "children": [
        {
            "kind": "Migration",
            "namespace": "openshift-migration",
            "name": "6f4dd5c0-1942-11eb-8198-914427d8f387",
            "children": [
                {
                    "kind": "Backup",
                    "namespace": "openshift-migration",
                    "name": "6f4dd5c0-1942-11eb-8198-914427d8f387-nvrbb",
                    "children": [
                        {
                            "kind": "PodVolumeBackup",
                            "namespace": "openshift-migration",
                            "name": "3612faa0-1335-11eb-ad9e-d5160a3c0f86-jct6l-g9sr2",
                            "objectLink": "/namespaces/openshift-migration/clusters/o311/namespaces/openshift-migration/podvolumebackups/3612faa0-1335-11eb-ad9e-d5160a3c0f86-jct6l-g9sr2"
                        },
                        {
                            "kind": "PodVolumeBackup",
                            "namespace": "openshift-migration",
                            "name": "61ca4470-193c-11eb-8198-914427d8f387-sbfnf-8p7xx",
                            "objectLink": "/namespaces/openshift-migration/clusters/o311/namespaces/openshift-migration/podvolumebackups/61ca4470-193c-11eb-8198-914427d8f387-sbfnf-8p7xx"
                        },
                        {
                            "kind": "PodVolumeBackup",
                            "namespace": "openshift-migration",
                            "name": "ocp-29918-hooks-mig-1603858914-966c6-q2kmx",
                            "objectLink": "/namespaces/openshift-migration/clusters/o311/namespaces/openshift-migration/podvolumebackups/ocp-29918-hooks-mig-1603858914-966c6-q2kmx"
                        },

... [this goes on for a while] ...

@djwhatle
Copy link
Contributor Author

djwhatle commented Oct 29, 2020

Looking at the discovery service treeview endpoint code, it seems the filtering logic for finding relevant PVRs/PVBs has a bug.

//
// Add related velero PodVolumeBackups.
func (t *PlanTree) addPvBackups(backup *model.Backup, parent *TreeNode) error {
	cluster := t.cluster.source
	collection := model.PodVolumeBackup{
		Base: model.Base{
			Cluster: cluster.PK,
		},
	}
	list, err := collection.List(t.db, model.ListOptions{})
	if err != nil {
		Log.Trace(err)
		return err
	}
	for _, m := range list {
		object := m.DecodeObject()
		for _, ref := range object.OwnerReferences {
			if ref.Kind != migref.ToKind(backup) ||
				ref.Name != backup.Name ||
				m.Namespace != backup.Namespace {
				continue
			}
		}
		parent.Children = append(
			parent.Children,
			TreeNode{
				Kind:       migref.ToKind(m),
				ObjectLink: PvBackupHandler{}.Link(&cluster, m),
				Namespace:  m.Namespace,
				Name:       m.Name,
			})
	}
	return nil
}

Specifically, in this region, the continue will move onto the next ownerRef to check but won't break out of the higher level loop iteration.

		for _, ref := range object.OwnerReferences {
			if ref.Kind != migref.ToKind(backup) ||
				ref.Name != backup.Name ||
				m.Namespace != backup.Namespace {
				continue
			}
		}

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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant