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

Pass API versions to flux-local builds #251

Closed
xoxys opened this issue Jun 30, 2023 · 7 comments
Closed

Pass API versions to flux-local builds #251

xoxys opened this issue Jun 30, 2023 · 7 comments

Comments

@xoxys
Copy link

xoxys commented Jun 30, 2023

I run into a problem when using flux-local build because some helm charts use .capabilities checks in the templates:

flux-local build flux/clusters/cloud-infra/ --enable-helm --skip-crds
Command '(None) helm template renovate renovate-renovate/renovate --namespace renovate --skip-crds --skip-tests --version 35.141.3 --values /tmp/tmpt7op_xuk/renovate-renovate-values.yaml --registry-config /dev/null --repository-cache /tmp/tmpy2tsl0ia --repository-config /tmp/tmpt7op_xuk/repository-config.yaml' failed with return code 1
Error: execution error at (renovate/templates/cronjob.yaml:8:6): 

 ERROR: You must have at least batch/v1beta1 to use CronJob

While using flux-local test we can pass -a "batch/v1/CronJob" to the command to work around this issue, is there any similar way for flux-local build?

@allenporter
Copy link
Owner

Yes, can take a look. Do you have a pointer to an example repo that exhibits the problem?

@xoxys
Copy link
Author

xoxys commented Jun 30, 2023

Thanks. I've created a min reproduction repo at https://github.com/xoxys/flux-local-test. Home that helps.

@allenporter
Copy link
Owner

@xoxys 💯 that's fantastic! I've copied the test example into the canonical set of test clusters used in the test framework and will get a fix out shortly.

allenporter added a commit that referenced this issue Jul 1, 2023
## Breaking change
This changes the `Helm.template` api which previously had a set of
boolean arguments to use an `Options` class.

## Change Details
Add tests that reproduce #251 including a copy of the provided test repo
@allenporter
Copy link
Owner

Releasing in 2.0.0

@xoxys
Copy link
Author

xoxys commented Jul 1, 2023

@allenporter Thanks again. The build command works now but test fails:

flux-local test --enable-helm  --path ./flux -a "batch/v1/CronJob"
[...]
/usr/lib64/python3.11/asyncio/tasks.py:267: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = Command(cmd=['helm', 'template', 'renovate', 'flux-system-renovate/renovate', '--namespace', 'default', '--skip-crds',...w0269cv/repository-config.yaml'], cwd=None, exc=<class 'flux_local.exceptions.HelmException'>, retcodes=None, env=None)
stdin = None

    async def run(self, stdin: bytes | None = None) -> bytes:
        """Run the command, returning stdout."""
        _LOGGER.debug("Running command: %s", self)
        env = {
            **os.environ,
            **(self.env if self.env else {}),
        }
        proc = await asyncio.create_subprocess_shell(
            self.string,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            cwd=self.cwd,
            env=env,
        )
        out, err = await proc.communicate(stdin)
        if proc.returncode:
            if self.retcodes and proc.returncode in self.retcodes:
                return out
            errors = [f"Command '{self}' failed with return code {proc.returncode}"]
            if out:
                errors.append(out.decode("utf-8"))
            if err:
                errors.append(err.decode("utf-8"))
            _LOGGER.error("\n".join(errors))
>           raise self.exc("\n".join(errors))
E           flux_local.exceptions.HelmException: Command '(None) helm template renovate flux-system-renovate/renovate --namespace default --skip-crds --skip-tests --values /tmp/tmphw0269cv/default-renovate-values.yaml --registry-config /dev/null --repository-cache /tmp/tmprd4jz592 --repository-config /tmp/tmphw0269cv/repository-config.yaml' failed with return code 1
E           Error: execution error at (renovate/templates/cronjob.yaml:8:6): 
E           
E            ERROR: You must have at least batch/v1beta1 to use CronJob
E           
E           Use --debug flag to render out invalid YAML

../../.local/pipx/venvs/flux-local/lib64/python3.11/site-packages/flux_local/command.py:87: HelmException
------------------------------------------------------------------------------------- Captured log call --------------------------------------------------------------------------------------
ERROR    flux_local.command:command.py:86 Command '(None) helm template renovate flux-system-renovate/renovate --namespace default --skip-crds --skip-tests --values /tmp/tmphw0269cv/default-renovate-values.yaml --registry-config /dev/null --repository-cache /tmp/tmprd4jz592 --repository-config /tmp/tmphw0269cv/repository-config.yaml' failed with return code 1
Error: execution error at (renovate/templates/cronjob.yaml:8:6): 

 ERROR: You must have at least batch/v1beta1 to use CronJob

Use --debug flag to render out invalid YAML
================================================================================== short test summary info ===================================================================================
FAILED flux::kustomization::default/renovate - flux_local.exceptions.HelmException: Command '(None) helm template renovate flux-system-renovate/renovate --namespace default --skip-crds --skip-tests --values /tmp/tmphw0269cv/default-...

@allenporter allenporter reopened this Jul 1, 2023
@allenporter
Copy link
Owner

Ok must have busted something during refactor

allenporter added a commit that referenced this issue Jul 1, 2023
Fix a bug in flux-test where kwargs were not passed properly.
Update test strategy to explicitly test each test cluster.

Issue #251
@allenporter
Copy link
Owner

Tagged 2.0.1 with a fix.
I've added the test repos to CI to make sure the tests are run in an additional way for every repo.

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

No branches or pull requests

2 participants