Bug 1856814
| Summary: | [RFE] Make it easier to access plan information in a hook container | |||
|---|---|---|---|---|
| Product: | OpenShift Container Platform | Reporter: | Jason Montleon <jmontleo> | |
| Component: | Migration Tooling | Assignee: | Jason Montleon <jmontleo> | |
| Status: | CLOSED ERRATA | QA Contact: | Xin jiang <xjiang> | |
| Severity: | medium | Docs Contact: | ||
| Priority: | medium | |||
| Version: | 4.4 | CC: | chezhang, kelly.brown1, mberube, rjohnson, sregidor, whu | |
| Target Milestone: | --- | |||
| Target Release: | 4.4.z | |||
| Hardware: | Unspecified | |||
| OS: | Unspecified | |||
| URL: | https://github.com/konveyor/mig-controller/pull/587 | |||
| Whiteboard: | ||||
| Fixed In Version: | Doc Type: | No Doc Update | ||
| Doc Text: |
Feature: Hooks
Reason: Reason
Result:
|
Story Points: | --- | |
| Clone Of: | ||||
| : | 1856973 (view as bug list) | Environment: | ||
| Last Closed: | 2020-08-05 10:51:25 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: | ||||
| Bug Depends On: | 1856973 | |||
| Bug Blocks: | ||||
With https://github.com/konveyor/mig-controller/pull/587 the same can be achieved with: - hosts: localhost gather_facts: false tasks: - debug: msg: "{{ (lookup( 'env', 'MIGRATION_NAMESPACES')).split(',') }}" Verified in 1.2.4 stage
Image: openshift-migration-rhel7-operator@sha256:5f1deddb16fcf9688f59f7e977f4246cff08e765a4da83c15f3c94bf1ecb68c8
This works fine
- hosts: localhost
gather_facts: false
tasks:
- set_fact:
namespace: "{{ (lookup( 'env', 'MIGRATION_NAMESPACES')).split(',') }}"
- debug: msg={{ namespace }}
- fail:
msg: "no namespace defined"
when: namespace|first != "MYMIGRATEDNAMESPACE"
Notice that in the playbook used to verify the BZ, "MYMIGRATEDNAMESPACE" needs to be replaced with the name you actually used in your migration. 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 (Cluster Application Migration (CAM) Tool Image Release Advisory 1.2.4), 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/RHBA-2020:3320 |
Description of problem: Version-Release number of selected component (if applicable): 1.2.3 Actual results: It takes a lot of work to get something like the list of namespaces for the plan when running a hook. Expected results: We should at least add the plan name as an env var so it can be looked up, if not also adding env vars for common resources like namespaces, and so on. It shouldn't require doing something like below. And this is the easier case of your hook running on the controller cluster. If it's on the other cluster where the mig* resources don't exist it will be even more difficult. Additional info: To get namespaces looks like: - hosts: localhost gather_facts: false tasks: - k8s_facts: kind: pods api: v1 namespace: openshift-migration name: "{{ lookup( 'env', 'HOSTNAME') }}" register: pods - k8s_facts: kind: jobs api: batch/v1 namespace: openshift-migration name: "{{ pods.resources[0].metadata.ownerReferences[0].name }}" register: jobs - k8s_facts: kind: jobs api: batch/v1 namespace: openshift-migration name: "{{ pods.resources[0].metadata.ownerReferences[0].name }}" register: jobs - k8s_facts: kind: migmigration api: migration.openshift.io/v1alpha1 namespace: openshift-migration register: migrations - set_fact: migmigration: "{{ item.metadata }}" with_items: "{{ migrations.resources }}" when: item.metadata.uid == jobs.resources[0].metadata.labels.owner - k8s_facts: kind: migplan api: migration.openshift.io/v1alpha1 namespace: openshift-migration name: "{{ migmigration.ownerReferences[0].name }}" register: migplans - set_fact: namespaces: "{{ migplans.resources[0].spec.namespaces }}" - debug: msg: "{{ namespaces }}"