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

Expose config to disable upsert behavior #3000

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

blampe
Copy link
Contributor

@blampe blampe commented May 8, 2024

This exposes opt-in provider configuration to disable upsert behavior. When this is set we will use CSA for creation and surface "already exists" errors when we attempt to overwrite something.

I called the config enableUpsert to be consistent with some of our other configs (although I'd prefer disableUpsert since that makes it more obvious what the default behavior is).

An E2E test is included and I'll try to add some units around this as well.

Fixes #2926.

Copy link

github-actions bot commented May 8, 2024

Does the PR have any schema changes?

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

Copy link

codecov bot commented May 8, 2024

Codecov Report

Attention: Patch coverage is 11.76471% with 30 lines in your changes are missing coverage. Please review.

Project coverage is 29.79%. Comparing base (09be004) to head (0006ded).

Files Patch % Lines
provider/pkg/gen/schema.go 0.00% 21 Missing ⚠️
provider/pkg/provider/provider.go 25.00% 7 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3000      +/-   ##
==========================================
- Coverage   29.86%   29.79%   -0.08%     
==========================================
  Files          63       63              
  Lines        8353     8384      +31     
==========================================
+ Hits         2495     2498       +3     
- Misses       5634     5660      +26     
- Partials      224      226       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@EronWright EronWright left a comment

Choose a reason for hiding this comment

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

In an earlier experiment along these lines (i.e. using Create rather than Apply), I observed that metadata.managedFields is significantly different. I was concerned that some migration logic might be needed.

We have CSA-to-SSA logic elsewhere in the provider. Would this be involved on a subsequent update?

@@ -325,6 +325,7 @@ func Test_Creation(t *testing.T) {
DedupLogger: logging.NewLogger(context.Background(), host, urn),
Resources: resources,
ServerSideApply: tt.args.serverSideApply,
EnableUpsert: tt.args.serverSideApply,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
EnableUpsert: tt.args.serverSideApply,
EnableUpsert: tt.args.enableUpsert,

@@ -90,6 +90,16 @@ func PulumiSchema(swagger map[string]any) pschema.PackageSpec {
Description: "BETA FEATURE - If present and set to true, allow ConfigMaps to be mutated.\nThis feature is in developer preview, and is disabled by default.\n\nThis config can be specified in the following ways using this precedence:\n1. This `enableConfigMapMutable` parameter.\n2. The `PULUMI_K8S_ENABLE_CONFIGMAP_MUTABLE` environment variable.",
TypeSpec: pschema.TypeSpec{Type: "boolean"},
},
"enableUpsert": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we reverse the polarity of this field, so that it is false by default?

@@ -177,6 +187,15 @@ func PulumiSchema(swagger map[string]any) pschema.PackageSpec {
Description: "BETA FEATURE - If present and set to true, allow ConfigMaps to be mutated.\nThis feature is in developer preview, and is disabled by default.\n\nThis config can be specified in the following ways using this precedence:\n1. This `enableConfigMapMutable` parameter.\n2. The `PULUMI_K8S_ENABLE_CONFIGMAP_MUTABLE` environment variable.",
TypeSpec: pschema.TypeSpec{Type: "boolean"},
},
"enableUpsert": {
Description: "If present and set to false, the provider will surface errors if a create operation would overwrite existing resources in the cluster.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe should mention that this is for ssa mode only.

@EronWright
Copy link
Contributor

EronWright commented Nov 7, 2024

Let me state my opinion here, that Kubernetes SSA is designed for a multi-party authoring experience (where multiple parties apply their intentions to a given object), but design-wise says nothing about object lifecycle. For example, it doesn't answer the question of "who should delete this object, my party or your party?". An auto-scaler, for example, would not expect to create or to delete a given object, merely to control the replicas field while the object exists.

Pulumi has features like "import" and "retainOnDelete" to control an object's lifecycle, and there's no good reason that SSA should complicate that, in my opinion. I agree with disabling upsert, perhaps opt-in in v4 and always disabled in v5.

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 this pull request may close these issues.

Fail-fast when a program attempts to create an object that already exists.
2 participants