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

config.Yaml invokes decode but doesn't propagate provider #1938

Closed
rawkode opened this issue Mar 21, 2022 · 12 comments · Fixed by #2005 or #2713
Closed

config.Yaml invokes decode but doesn't propagate provider #1938

rawkode opened this issue Mar 21, 2022 · 12 comments · Fixed by #2005 or #2713
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec language/javascript resolution/fixed This issue was fixed

Comments

@rawkode
Copy link
Contributor

rawkode commented Mar 21, 2022

Hello!

  • Vote on this issue by adding a 👍 reaction
  • To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already)

Issue details

When the default Kubernetes provider is disabled, we cannot use yaml.ConfigFile. It seems that an invoke to yaml::decode is made without propagation of the provider.

Error: Invoke: Default provider for 'kubernetes' disabled. 'kubernetes:yaml:decode' must use an explicit provider

Steps to reproduce

    args.provider.urn.apply((u) => console.log(`Provider URN: ${u}`));

    const crds = new kubernetes.yaml.ConfigFile(
      `${this.name}-crds`,
      { file: this.crdsUrl.replace("${VERSION}", this.version) },
      {
        parent: this,
        provider: args.provider,
        dependsOn: args.dependsOn,
      }
    );

This code fails, even though the URN for my provider is correct.

@rawkode rawkode added the kind/bug Some behavior is incorrect or out of spec label Mar 21, 2022
@rawkode rawkode changed the title config.Yaml invokes decode but dpesn config.Yaml invokes decode but doesn't propagate provider Mar 21, 2022
@protometa
Copy link

Having same issue with helm.v3.Chart with error

Error: Invoke: Default provider for 'kubernetes' disabled. 'kubernetes:helm:template' must use an explicit provider.

@protometa
Copy link

Looks like fix is #1919?

@KaoruDev
Copy link

I updated to 3.18.2 and it appears the bug is still present

@omninonsense
Copy link

omninonsense commented May 12, 2022

It seems like anything under k8s.kustomize/k8s.yaml/similar fails when the default kubernetes provider is disabled, even when you pass in opts.provider.

@KaoruDev
Copy link

hey @lblackstone I just pulled down version 3.19.4 and still am observing the same behavior ☹️

@viveklak
Copy link
Contributor

@KaoruDev are you able to pulumi stack export and make sure the provider for the resource is actually set to v3.19.4 and not using an older version?

@KaoruDev
Copy link

Is this the right place to find the version?

image

The provider field itself didn't have the version. If so, I am misunderstanding how providers work. It looks like I need to recreate the resource in order to pick up the provider changes, is that correct? 😅

@rosskevin
Copy link
Contributor

I'm raising a brand new stack (pre-existing code that previously worked, we are doing a major upgrade) and I ran into this issue. I did just switch to explicit providers in the major update, but it appears that a parented ConfigFile is not receiving the provider. Below is abbreviated for clarity:

Error: Invoke: Default provider for 'kubernetes' disabled. 'kubernetes:yaml:decode' must use an explicit provider.

Invocation:

export const certManager = new CertManager(
  {
    kind: 'ClusterIssuer',
  },
  { providers: { kubernetes, gcp } },
)

Component definition:

import * as k8s from '@pulumi/kubernetes'

export class CertManager extends ComponentResource {
  public readonly version = '1.8.2'
  constructor(args: CertManagerArgs, opts: ComponentResourceOptions) {
    super('af:pulumi:cert-manager:CertManager', 'cert-manager', {}, opts)
    
    const certManager = new k8s.yaml.ConfigFile(
      `https://github.com/cert-manager/cert-manager/releases/download/v${this.version}/cert-manager.yaml`,
      undefined,
      { parent: this },
    )
}

Note that I tried this with both provider and providers args, with the same result. @lblackstone please reopen.

@rosskevin
Copy link
Contributor

...and is there a workaround to pass the providers explicitly inside my ComponentResource?

@viveklak
Copy link
Contributor

@rosskevin you would need to pass the opts to ConfigFile. However, I believe you might run into pulumi/pulumi#9996. Instead you might want to pass the kubernetes provider directly as ConfigFile's provider resource option.

@robertvanhoesel
Copy link

I'm getting this exact runtime error while using https://github.com/pulumi/pulumi-kubernetes-cert-manager . Is that package updated correctly?

@EronWright
Copy link
Contributor

Reopening this to cover the remaining cases in NodeJS SDK, e.g. when using providers as opposed to provider.

@EronWright EronWright reopened this Dec 13, 2023
@EronWright EronWright assigned EronWright and unassigned lblackstone Dec 13, 2023
EronWright added a commit that referenced this issue Jan 3, 2024
<!--Thanks for your contribution. See [CONTRIBUTING](CONTRIBUTING.md)
    for Pulumi's contribution guidelines.

    Help us merge your changes more quickly by adding more details such
    as labels, milestones, and reviewers.-->

### Proposed changes
Epic: #2254
Fixes: #1938
Fixes: #2049
Fixes: #812

This PR standardizes the option propagation logic for the component
resources in the pulumi-kubernetes NodeJS SDK. The general approach is:
1. In the component resource constructor, compute the child options to
be propagated to any children. The child options consist of the
component as parent, and with `version` and `pluginDownloadURL` if
specified.
2. Compute the invoke options by copying the child options.

### Specification
The component resource is responsible for computing sub-options for
invokes and for child resource declarations. This table outlines the
expected behavior for each [resource
option](https://www.pulumi.com/docs/concepts/options/) when presented to
a component resource.

|  | Propagated | Remarks |
|---|---|---|
| `additionalSecretOutputs` | no | "does not apply to component
resources" |
| `aliases` | no | Inherited via parent-child relationship. |
| `customTimeouts` | no | "does not apply to component resources" |
| `deleteBeforeReplace` | no |  |
| `deletedWith` | no |  |
| `dependsOn` | no | The children implicitly wait for the dependency. |
| `ignoreChanges` | no | Nonsensical to apply directly to children (see
[discussion](pulumi/pulumi#8969)). |
| `import` | no |  |
| `parent` | **yes** | The component becomes the parent. |
| `protect` | no | Inherited. |
| `provider` | no | Combined into providers map, then inherited via
parent-child relationship. |
| `providers` | no | Inherited. |
| `replaceOnChanges` | no | "does not apply to component resources" |
| `retainOnDelete` | no | "does not apply to component resources" |
| `transformations` | no | Inherited. |
| `version` | **yes** | Influences default provider selection logic
during invokes.<br/>Should propagate when child resource is from the
same provider type. |
| `pluginDownloadURL` | **yes** | Influences default provider selection
logic during invokes.<br/>Should propagate when child resource is from
the same provider type. |

### Testing
A new test case is provided ([test
case](https://github.com/pulumi/pulumi-kubernetes/blob/e1ad541a9c86e8eb207bd1d8a276822862425109/tests/sdk/nodejs/nodejs_test.go#L2107),
[test
program](https://github.com/pulumi/pulumi-kubernetes/blob/e1ad541a9c86e8eb207bd1d8a276822862425109/tests/sdk/nodejs/options/index.ts))
that exercises option propagation across the component resources:
-
[kubernetes.helm.sh.v3.Chart](https://www.pulumi.com/registry/packages/kubernetes/api-docs/helm/v3/chart/)
-
[kubernetes.kustomize.Directory](https://www.pulumi.com/registry/packages/kubernetes/api-docs/kustomize/directory/)
-
[kubernetes.yaml.ConfigGroup](https://www.pulumi.com/registry/packages/kubernetes/api-docs/yaml/configgroup/)
-
[kubernetes.yaml.ConfigFile](https://www.pulumi.com/registry/packages/kubernetes/api-docs/yaml/configfile/)

Upgrade testing must be done manually, with an emphasis on avoiding
replacement due to reparenting.

### Related issues (optional)

The p/p NodeJS SDK doesn't propagate the `pluginDownloadURL` option to
the Invoke RPC.
pulumi/pulumi#14839
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 language/javascript resolution/fixed This issue was fixed
Projects
None yet
10 participants