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

getResourceProperty not working with a specified namespace #419

Closed
lblackstone opened this issue Feb 12, 2019 · 3 comments
Closed

getResourceProperty not working with a specified namespace #419

lblackstone opened this issue Feb 12, 2019 · 3 comments
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec

Comments

@lblackstone
Copy link
Member

import * as k8s from "@pulumi/kubernetes";

const nginx = new k8s.helm.v2.Chart("simple-nginx", {
    // Represents chart `stable/nginx-lego@v0.3.1`.
    repo: "stable",
    chart: "nginx-lego",
    version: "0.3.1",
    values: {
        // Override for the Chart's `values.yml` file. Use `null` to zero out resource requests so it
        // can be scheduled on our (wimpy) CI cluster. (Setting these values to `null` is the "normal"
        // way to delete values.)
        nginx: { resources: null },
        default: { resources: null },
        lego: { resources: null }
    },
});

// Export the (cluster-private) IP address of the Guestbook frontend.
export const frontendClusterIp = nginx.getResourceProperty("v1/Service",
    "default",
    "simple-nginx-nginx-lego", "spec")
    .apply(spec => spec.clusterIP);

produces the following error:

    error: TypeError: Cannot read property 'spec' of undefined
        at getResourceImpl.apply.r (/opt/pulumi/node_modules/@pulumi/kubernetes/provider.js:70:30)
        at Output.<anonymous> (/opt/pulumi/node_modules/@pulumi/kubernetes/node_modules/@pulumi/pulumi/resource.js:277:47)
        at next (native)
        at /opt/pulumi/node_modules/@pulumi/kubernetes/node_modules/@pulumi/pulumi/resource.js:20:71
        at __awaiter (/opt/pulumi/node_modules/@pulumi/kubernetes/node_modules/@pulumi/pulumi/resource.js:16:12)
        at promise.then (/opt/pulumi/node_modules/@pulumi/kubernetes/node_modules/@pulumi/pulumi/resource.js:264:62)
    error: an unhandled error occurred: Program exited with non-zero exit code: 1

    2019/02/12 11:14:42 Warning: Merging destination map for chart 'nginx-lego'. Cannot overwrite table item 'resources', with non table value: map[requests:map[cpu:1 memory:128Mi] limits:map[cpu:1 memory:2Gi]]
    2019/02/12 11:14:42 Warning: Merging destination map for chart 'nginx-lego'. Cannot overwrite table item 'resources', with non table value: map[limits:map[cpu:1 memory:2Gi] requests:map[cpu:1 memory:128Mi]]
    2019/02/12 11:14:42 Warning: Merging destination map for chart 'nginx-lego'. Cannot overwrite table item 'resources', with non table value: map[limits:map[cpu:1 memory:2Gi] requests:map[cpu:1 memory:128Mi]]
    TypeError: Cannot read property 'spec' of undefined
        at getResourceImpl.apply.r (/opt/pulumi/node_modules/@pulumi/kubernetes/provider.js:70:30)
        at Output.<anonymous> (/opt/pulumi/node_modules/@pulumi/kubernetes/node_modules/@pulumi/pulumi/resource.js:277:47)
        at next (native)
        at /opt/pulumi/node_modules/@pulumi/kubernetes/node_modules/@pulumi/pulumi/resource.js:20:71
        at __awaiter (/opt/pulumi/node_modules/@pulumi/kubernetes/node_modules/@pulumi/pulumi/resource.js:16:12)
        at promise.then (/opt/pulumi/node_modules/@pulumi/kubernetes/node_modules/@pulumi/pulumi/resource.js:264:62)
    TypeError: Cannot read property 'spec' of undefined
        at getResourceImpl.apply.r (/opt/pulumi/node_modules/@pulumi/kubernetes/provider.js:70:30)
        at Output.<anonymous> (/opt/pulumi/node_modules/@pulumi/kubernetes/node_modules/@pulumi/pulumi/resource.js:277:47)
        at next (native)
        at /opt/pulumi/node_modules/@pulumi/kubernetes/node_modules/@pulumi/pulumi/resource.js:20:71
        at __awaiter (/opt/pulumi/node_modules/@pulumi/kubernetes/node_modules/@pulumi/pulumi/resource.js:16:12)
        at promise.then (/opt/pulumi/node_modules/@pulumi/kubernetes/node_modules/@pulumi/pulumi/resource.js:264:62)

Note that namespace was specified as "default". It works if that parameter is omitted.

@lblackstone lblackstone added the kind/bug Some behavior is incorrect or out of spec label Feb 12, 2019
@lblackstone
Copy link
Member Author

@hausdorff I assigned it to you to see if you had an idea on the fix. I suspect it's a bug in the provider code here:

let id = namespaceOrName;
if (name !== undefined) {
id = `${namespaceOrName}/${name}`;
}
return this.resources.apply(resources => resources[`${groupVersionKind}::${id}`]);

@hausdorff
Copy link
Contributor

This is one of the warts of this API, I'm not sure how to fix it from the SDK alone. The basic problem is that we don't know whether a resource is missing a namespace, or the resource is not namespaced at all. And we can't, unless we talk to the provider, which understands the OpenAPI spec.

So there is some sense in which this is desired behavior. I'd love to fix it, but I'm not sure how we'd do it.

@lblackstone
Copy link
Member Author

This was fixed in #483

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

2 participants