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

passing k8s_resources to pod.set_spec does not work #293

Closed
vmpjdc opened this issue May 26, 2020 · 1 comment · Fixed by #369
Closed

passing k8s_resources to pod.set_spec does not work #293

vmpjdc opened this issue May 26, 2020 · 1 comment · Fixed by #369

Comments

@vmpjdc
Copy link

vmpjdc commented May 26, 2020

Per https://bugs.launchpad.net/juju/+bug/1880637, pod-spec-set ignores --k8s-resources when the supplied files are JSON. The operator framework creates the files that it passes to pod-spec-set in JSON format.

One of the Juju developers tells me that pod-spec-set concatenates the files internally before parsing, which would explain why JSON doesn't work but YAML does work.

Please consider writing the files as YAML instead, which should work properly.

In the meantime, this can be worked around by placing the Kubernetes resources in the "kubernetesResources" slot of the pod spec itself.

@jameinel
Copy link
Member

I believe we can create a YAML file and pass that in instead. Right now we have:

    def pod_spec_set(self, spec, k8s_resources):
        tmpdir = Path(tempfile.mkdtemp('-pod-spec-set'))
        try:
            spec_path = tmpdir / 'spec.json'
            spec_path.write_text(json.dumps(spec))
            args = ['--file', str(spec_path)]
            if k8s_resources:
                k8s_res_path = tmpdir / 'k8s-resources.json'
                k8s_res_path.write_text(json.dumps(k8s_resources))
                args.extend(['--k8s-resources', str(k8s_res_path)])
            self._run('pod-spec-set', *args)
        finally:
            shutil.rmtree(str(tmpdir))

we already depend on YAML being installed, so we can use that instead.

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 a pull request may close this issue.

3 participants