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

Component option propagation (.NET SDK) #2720

Merged
merged 6 commits into from
Jan 4, 2024

Conversation

EronWright
Copy link
Contributor

@EronWright EronWright commented Dec 16, 2023

Proposed changes

Epic: #2254
Fixes: #1214
Fixes: #2345

This PR standardizes the option propagation logic for the component resources in the pulumi-kubernetes .NET 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 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).
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.
Should propagate when child resource is from the same provider type.
pluginDownloadURL yes Influences default provider selection logic during invokes.
Should propagate when child resource is from the same provider type.

Testing

A new test case is provided (test case, test program) that exercises option propagation across the component resources:

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

Upgrade Considerations

In previous versions, the ConfigFile and ConfigGroup component resources inadvertently assigned the wrong parent to the child resource(s). This would happen when the component resource itself had a parent; the child would be assigned that same parent. This also had the effect of disregarding the component resource's provider in favor of the parent's provider.

For example, here's a before/after look at the component hierarchy:
Before:

├─ pkg:index:MyComponent            parent                                               
│  ├─ kubernetes:core/v1:ConfigMap  cg-options-cg-options-cm-1                           
│  ├─ kubernetes:yaml:ConfigFile    cg-options-testdata/options/configgroup/manifest.yaml
│  ├─ kubernetes:core/v1:ConfigMap  cg-options-configgroup-cm-1                          
│  ├─ kubernetes:yaml:ConfigFile    cg-options-testdata/options/configgroup/empty.yaml   
│  └─ kubernetes:yaml:ConfigGroup   cg-options                                                                                     

After:

└─ pkg:index:MyComponent                  parent                                               
   └─ kubernetes:yaml:ConfigGroup         cg-options                                           
      ├─ kubernetes:yaml:ConfigFile       cg-options-testdata/options/configgroup/manifest.yaml
      │  └─ kubernetes:core/v1:ConfigMap  cg-options-configgroup-cm-1                          
      └─ kubernetes:core/v1:ConfigMap     cg-options-cg-options-cm-1      

This PR addresses this issue and attempts to heal existing stacks using aliases. This is effective at avoiding a replacement except in the case where the child was created with the wrong provider. In this case, Pulumi will suggest a replacement of the child resource(s), such that they use the correct provider.

Related issues (optional)

Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

Copy link
Member

@lblackstone lblackstone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Nice work 🎉

tests/sdk/dotnet/options/options-test.csproj Outdated Show resolved Hide resolved
@EronWright EronWright merged commit 8d724be into master Jan 4, 2024
18 checks passed
@EronWright EronWright deleted the eronwright/issue-2254-dotnet branch January 4, 2024 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants