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

lastAppliedConfig is tainting entire metadata field #787

Closed
lblackstone opened this issue Sep 6, 2019 · 4 comments
Closed

lastAppliedConfig is tainting entire metadata field #787

lblackstone opened this issue Sep 6, 2019 · 4 comments
Assignees
Labels
area/community Related to ability of community to participate in pulumi-kubernetes development impact/usability Something that impacts users' ability to use the product easily and intuitively kind/bug Some behavior is incorrect or out of spec last-applied-configuration Issues related to the last-applied-configuration annotation resolution/fixed This issue was fixed

Comments

@lblackstone
Copy link
Member

Problem description

  • I saw an issue in the following Pulumi Program:
let googleMapsKey = config.requireSecret('googleMapsKey');
const googleMapsKeySecret = new k8s.core.v1.Secret(`google-maps-key-${stackName}`, {
    metadata: { namespace: namespace },
    stringData: {GOOGLE_MAPS_KEY: googleMapsKey},
}, {provider: provider});

const deployment = new ServiceDeployment(`deployment-${stackName}`, namespace, {
    // ...
    envFrom: [{secretRef: {name: googleMapsKeySecret.metadata.name}}],
}, {provider: provider});

export class ServiceDeployment extends pulumi.ComponentResource {
    constructor(name: string, namespace: pulumi.Output<string>, args: ServiceDeploymentArgs, opts?: pulumi.ComponentResourceOptions) {
        super("vantrix:pulumi-library:ServiceDeployment", name, {}, opts);

        const container: k8stypes.core.v1.Container = {
            // ...
            envFrom: args.envFrom,
        };
        this.deployment = new k8s.apps.v1.Deployment(name, {
            // ...
            spec: {
                template: {
                    spec: {
                        containers: [ container ],
                        imagePullSecrets: args.imagePullSecrets,
                    },
                },
            },
        }, { parent: this });
    }
}

export interface ServiceDeploymentArgs {
    // ...
    imagePullSecrets?: pulumi.Input<k8stypes.core.v1.LocalObjectReference>[],
    envFrom?: pulumi.Input<k8stypes.core.v1.EnvFromSource>[];
}

When the Secret is created, Pulumi is setting .metadata.annotations[kubectl.kubernetes.io/last-applied-configuration] and (correctly) marking it as secret. Unfortunately, this is also marking all of the other .metadata fields as secret, even though they do not contain secret values.

In this program, the Deployment's containers field is being tainted as secret by transitively referring to the Secret's .metadata.name.

This behavior was introduced by #741

Errors & Logs

Affected product version(s)

Reproducing the issue

Suggestions for a fix

We should narrow the scope of the "secretness" so that it doesn't include all of the .metadata fields.

@lblackstone lblackstone added impact/usability Something that impacts users' ability to use the product easily and intuitively area/community Related to ability of community to participate in pulumi-kubernetes development labels Sep 6, 2019
@ellismg
Copy link
Contributor

ellismg commented Sep 6, 2019

We should narrow the scope of the "secretness" so that it doesn't include all of the .metadata fields.

Note that the problem here is sort of orthogonal to the kubernetes provider. The tainting of the top level Output<T> happens inside @pulumi/pulumi when we are deserializing the result of the RPC to register resource. The logic here is in deserializeProperty inside the runtime portion of the SDK.

Indeed - the provider itself is doing the right thing, it's being very explicit about what parts of the overall object are secret, but we just don't have a great way to capture that in the language, since we track everything at the output of T level.

I could imagine ways that this could be made to work (Output<T> could hold on to more information for rich objects about what properties were secret or not) and that would allow us to perhaps make things like foo.bar (where foo is an object with a secret property named baz but bar itself is not secret) by playing games with our proxies.

It may be a little weird because it would mean that foo.bar would be different than foo.apply(f => f.bar) (in this case, we'd have to taint the entire result of the apply since we have no idea of some secret fields have been twiddled with).

As a first step, we should probably just do something like pulumi.runtime.removeSecretness(Output<T>) that lets you remove the secretness bit from an given Output<T>

/cc @pgavlin

@ellismg
Copy link
Contributor

ellismg commented Sep 6, 2019

FWIW - This problem is a more generalized case of what we faced with StackOutput.

@pgavlin pgavlin self-assigned this Sep 6, 2019
@squarebracket
Copy link

FWIW, I was able to work around this like so:

googleMapsKeySecret.metadata.name.apply(n => {
    const deployment = new ServiceDeployment(`deployment-${stackName}`, namespace, {
        // ...
        envFrom: [{secretRef: {name: n}}],
    }, {provider: provider});
});

Doing this showed me the changes for the container. Not pretty, but it works.

@lblackstone lblackstone assigned lblackstone and unassigned pgavlin Jul 14, 2023
@lblackstone lblackstone added kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed labels Jul 14, 2023
@lblackstone
Copy link
Member Author

Fixed by #2445

@lblackstone lblackstone added the last-applied-configuration Issues related to the last-applied-configuration annotation label Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/community Related to ability of community to participate in pulumi-kubernetes development impact/usability Something that impacts users' ability to use the product easily and intuitively kind/bug Some behavior is incorrect or out of spec last-applied-configuration Issues related to the last-applied-configuration annotation resolution/fixed This issue was fixed
Projects
None yet
Development

No branches or pull requests

4 participants