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

Fix bug on fbc_utils.enforce_json_config_dir #675

Merged
merged 1 commit into from
May 28, 2024
Merged

Fix bug on fbc_utils.enforce_json_config_dir #675

merged 1 commit into from
May 28, 2024

Conversation

JAVGan
Copy link
Contributor

@JAVGan JAVGan commented May 22, 2024

This commit fixes a bug on fbc_utils.enforce_json_config_dir which was caused by the incoming catalog.yaml being composed of multiple data chunks (multiple "inner yamls").

The bugfix was tested alongisde opm validate and can be verified manually with the following steps:

  1. Pull registry-proxy.engineering.redhat.com/rh-osbs/iib-pub:v4.12
  2. Copy the directory configs/rhbk-operator/ to a temporary location in your machine.
  3. Create two sub-directories called in and out
  4. Move the catalog.yaml to the sub-directory in
  5. Create a new file named converter.py with the following snippet and run it:
import contextlib
import json
import os

import ruamel.yaml

yaml = ruamel.yaml.YAML()

with contextlib.suppress(FileNotFoundError):
    os.remove('out/catalog.json')

with open('in/catalog.yaml', 'r') as yaml_in, open('out/catalog.json', 'a') as json_out:
    data = yaml.load_all(yaml_in)

    for chunk in data:
        json.dump(chunk, json_out)
  1. Use opm validate out to validate the output catalog.

Refers to CLOUDDST-22904

This commit fixes a bug on `fbc_utils.enforce_json_config_dir` which was
caused by the incoming `catalog.yaml` being composed of multiple data
chunks (multiple "inner yamls").

The bugfix was tested alongisde opm validate and can be verified
manually with the following steps:

1. Pull ` registry-proxy.engineering.redhat.com/rh-osbs/iib-pub:v4.12`
2. Copy the directory `configs/rhbk-operator/` to a temporary location
   in your machine.
3. Create two sub-directories called `in` and `out`
3. Move the `catalog.yaml` to the sub-directory `in`
4. Create a new file named `converter.py` with the following snippet and
   run it:

```
import contextlib
import json
import os

import ruamel.yaml

yaml = ruamel.yaml.YAML()

with contextlib.suppress(FileNotFoundError):
    os.remove('out/catalog.json')

with open('in/catalog.yaml', 'r') as yaml_in, open('out/catalog.json', 'a') as json_out:
    data = yaml.load_all(yaml_in)

    for chunk in data:
        json.dump(chunk, json_out)
```

5. Use `opm validate out` to validate the output catalog.

Refers to CLOUDDST-22904
@lipoja
Copy link
Contributor

lipoja commented May 28, 2024

@JAVGan Did you test it with the problematic index image on dev-env?

@JAVGan
Copy link
Contributor Author

JAVGan commented May 28, 2024

@JAVGan Did you test it with the problematic index image on dev-env?

Yes, using the steps from the description

@JAVGan JAVGan merged commit f26f254 into master May 28, 2024
2 checks passed
@JAVGan JAVGan deleted the fixconverter branch May 28, 2024 13:04
@chandwanitulsi
Copy link
Contributor

@JAVGan Did you test it with the problematic index image on dev-env?

Yes, using the steps from the description

I tested using 4.12 index as well, lgtm
curl -u: --negotiate -X POST -H "Content-Type: application/json" http://localhost:8080/api/v1/builds/add -d '{"bundles": ["registry.redhat.io/rhacm2/acm-operator-bundle:v2.10.3-11"], "binary_image":"registry.redhat.io/openshift4/ose-operator-registry:v4.12", "from_index":"registry-proxy.engineering.redhat.com/rh-osbs/iib-pub:v4.12"}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants