Bug 1994985

Summary: Web console crashes when a MigPlan custom resource is created with an empty namespaces list
Product: Migration Toolkit for Containers Reporter: Sergio <sregidor>
Component: UIAssignee: Ian <ibolton>
Status: CLOSED ERRATA QA Contact: Xin jiang <xjiang>
Severity: low Docs Contact: Avital Pinnick <apinnick>
Priority: low    
Version: 1.6.0CC: ernelson, prajoshi, rjohnson, ssingla, whu, xjiang
Target Milestone: ---   
Target Release: 1.6.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-09-29 14:35:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sergio 2021-08-18 09:07:36 UTC
Description of problem:
If we make a mistake when creating a migplan resource via CLI and the "namespaces" list is not defined in the migplan, the MTC UI crashes and it becomes blank. The backend, nevertheless, can handle the issue and create a CriticalCondition for the migplan.


Version-Release number of selected component (if applicable):
MTC 1.6.0

It has been found in 1.6.0, but it is probably present in previous releases too.

How reproducible:
Always

Steps to Reproduce:
1. Using the CLI create a migplan resource without a ‘namespaces’ list defined

[Use the right values for source cluster, destination cluster and migstorage names]

apiVersion: migration.openshift.io/v1alpha1
kind: MigPlan
metadata:
  name:  mig-plan-name
  namespace: openshift-migration
spec:
  destMigClusterRef:
    name: host
    namespace: openshift-migration
  migStorageRef:
    name: automatic
    namespace: openshift-migration
  srcMigClusterRef:
    name: source-cluster
    namespace: openshift-migration


2. Open the "plans" screen in the MTC UI.


Actual results:
The MTC UI crashes and cannot show the plans. It becomes blank.

In the browser's console we can see this error:

TypeError: Cannot read property 'length' of undefined
    at Object.t.getPlanInfo (app.bundle.js:2)
    at app.bundle.js:2
    at app.bundle.js:2
    at Array.sort (<anonymous>)
    at Object.t.useSortState (app.bundle.js:2)
    at t.default (app.bundle.js:2)
    at ci (app.bundle.js:2)
    at jr (app.bundle.js:2)
    at bs (app.bundle.js:2)
    at Ms (app.bundle.js:2)


The migplan status shows this CriticalCondition:

status:
  conditions:
  - category: Critical
    lastTransitionTime: "2021-08-17T11:07:39Z"
    message: The `namespaces` list may not be empty.
    reason: NotFound
    status: "True"
    type: NamespaceListEmpty



Expected results:
The UI should not crash, and it should report all existing migration plans, as well as this misconfigured migration plan as "Not Ready".


Additional info:

Comment 7 errata-xmlrpc 2021-09-29 14:35:03 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: Migration Toolkit for Containers (MTC) 1.6.0 security & bugfix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2021:3694