-
Notifications
You must be signed in to change notification settings - Fork 116
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
Support for metadata.generateName (CSA) #2808
Conversation
Does the PR have any schema changes?Looking good! No breaking changes found. |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #2808 +/- ##
==========================================
- Coverage 24.72% 24.64% -0.08%
==========================================
Files 48 48
Lines 9651 9710 +59
==========================================
+ Hits 2386 2393 +7
- Misses 7109 7160 +51
- Partials 156 157 +1 ☔ View full report in Codecov by Sentry. |
bcbc7b0
to
5fa3713
Compare
deb295e
to
1f93e88
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
// This makes it possible to update the program to set `.metadata.name` to the name that was | ||
// made by `.metadata.generateName` without triggering replacement. | ||
if newInputs.GetName() != "" { | ||
oldLivePruned.SetName(oldLive.GetName()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Admittedly, this took me a couple of passes to understand what's happening. Maybe it's worthwhile to expand the comment a bit? Something like, generateName will create and store a name, but the oldLivePruned object drops the name field to match the input, which we now need for diffing.
Though this could just be an artifact of code review only showing small chunks of code without context.
|
||
// | ||
// User has now specified `.metadata.name`, so Pulumi should replace the resource, and NOT allocate | ||
// a name to it. | ||
// User has now specified `.metadata.generateName`, which Pulumi ignores because autonaming has already occurred, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this scenario, could we emit a warning to the user that we won't honor generateName
? I believe we just silently continue right?
const namespace = new k8s.core.v1.Namespace("test-namespace"); | ||
|
||
// | ||
// The `.metadata.generateName` field has changed, but Pulumi does NOT automatically replace in that situation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a warning here too?
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@pulumi/kubernetes](https://pulumi.com) ([source](https://github.com/pulumi/pulumi-kubernetes)) | dependencies | minor | [`4.7.1` -> `4.8.0`](https://renovatebot.com/diffs/npm/@pulumi%2fkubernetes/4.7.1/4.8.0) | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>pulumi/pulumi-kubernetes (@​pulumi/kubernetes)</summary> ### [`v4.8.0`](https://github.com/pulumi/pulumi-kubernetes/blob/HEAD/CHANGELOG.md#480-February-22-2024) [Compare Source](https://github.com/pulumi/pulumi-kubernetes/compare/v4.7.1...v4.8.0) - Fix DiffConfig issue when when provider's kubeconfig is set to file path ([https://github.com/pulumi/pulumi-kubernetes/pull/2771](https://github.com/pulumi/pulumi-kubernetes/pull/2771)) - Fix for replacement having incorrect status messages ([https://github.com/pulumi/pulumi-kubernetes/pull/2810](https://github.com/pulumi/pulumi-kubernetes/pull/2810)) - Use output properties for await logic ([https://github.com/pulumi/pulumi-kubernetes/pull/2790](https://github.com/pulumi/pulumi-kubernetes/pull/2790)) - Support for metadata.generateName (CSA) ([https://github.com/pulumi/pulumi-kubernetes/pull/2808](https://github.com/pulumi/pulumi-kubernetes/pull/2808)) - Fix unmarshalling of Helm values yaml file ([https://github.com/pulumi/pulumi-kubernetes/issues/2815](https://github.com/pulumi/pulumi-kubernetes/issues/2815)) - Handle unknowns in Helm Release resource ([https://github.com/pulumi/pulumi-kubernetes/pull/2822](https://github.com/pulumi/pulumi-kubernetes/pull/2822)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMTAuMCIsInVwZGF0ZWRJblZlciI6IjM3LjIxMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: lumiere-bot[bot] <98047013+lumiere-bot[bot]@users.noreply.github.com>
@EronWright did you test it for ConfigMap?
Maybe I need to change anything in my provider? |
@vavsab I would guess that your provider is configured to use server-side apply mode, which you can disable: |
Is there a reason this is not supported with SSA? Will it be supported in the future? |
The reason that it isn't supported is that, in SSA mode, the provider uses Apply (HTTP PATCH) to both create and update the object (as described here), and one cannot use |
Thanks, I understand now. I will follow the issue over there. |
Proposed changes
This PR implements support for
.metadata.generateName
in CSA mode, based on #2790..metadata.generateName
to be a variant of auto-naming. Pulumi will not assign an auto-name to a new resource that hasgenerateName
, and upon delete will use the replace-then-delete technique.Tests
metadata.generateName
. It tests creation, update, replacement, and promotion from.generateName
to.name
. (ref)generateName
, in the update case. This is to ensure backwards compatibility, e.g. in the edge case that an existing object has agenerateName
field (which Pulumi ignored until now).Related issues (optional)
Closes #2539