-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SSA dry-run when an Apply is called on outputs (#2615)
### Proposed changes This PR unsets the empty initialized status subresource from a SSA dry-run to prevent panics during `pulumi preview` when the Pulumi program contains an Apply on a status field. By removing the field completely, the Pulumi engine will be able to defer returning until after the resource is created, which is when the status subresource is populated. ### Related issues (optional) Fixes: #2557 Fixes: #2315
- Loading branch information
Showing
7 changed files
with
197 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: preview-apply-tests | ||
description: Tests SSA previews with apply on status subresource | ||
runtime: nodejs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright 2016-2023, Pulumi Corporation. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import * as k8s from "@pulumi/kubernetes"; | ||
|
||
// Create provider with SSA enabled. | ||
const provider = new k8s.Provider("k8s", { enableServerSideApply: false }); | ||
|
||
const ns = new k8s.core.v1.Namespace("test-preview-apply", undefined, { | ||
provider, | ||
}); | ||
|
||
const dep = new k8s.apps.v1.Deployment( | ||
"nginx-dep", | ||
{ | ||
metadata: { | ||
namespace: ns.metadata.name, | ||
labels: { | ||
app: "nginx", | ||
}, | ||
}, | ||
spec: { | ||
replicas: 1, | ||
selector: { | ||
matchLabels: { | ||
app: "nginx", | ||
}, | ||
}, | ||
template: { | ||
metadata: { | ||
labels: { | ||
app: "nginx", | ||
}, | ||
}, | ||
spec: { | ||
containers: [ | ||
{ | ||
name: "nginx", | ||
image: "nginx:latest", | ||
ports: [ | ||
{ | ||
containerPort: 80, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ provider } | ||
); | ||
|
||
const svc = new k8s.core.v1.Service( | ||
"nginx-svc", | ||
{ | ||
metadata: { | ||
namespace: ns.metadata.name, | ||
labels: { | ||
app: "nginx", | ||
}, | ||
}, | ||
spec: { | ||
type: "LoadBalancer", | ||
ports: [ | ||
{ | ||
port: 80, | ||
targetPort: 80, | ||
}, | ||
], | ||
selector: { | ||
app: "nginx", | ||
}, | ||
}, | ||
}, | ||
{ provider } | ||
); | ||
|
||
export const ip = svc.status.apply((s) => s.loadBalancer.ingress[0].ip); | ||
export const nsName = ns.metadata.name; | ||
export const svcName = svc.metadata.name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "preview-auth", | ||
"version": "0.1.0", | ||
"dependencies": { | ||
"@pulumi/pulumi": "latest", | ||
"@pulumi/random": "latest" | ||
}, | ||
"peerDependencies": { | ||
"@pulumi/kubernetes": "latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "bin", | ||
"target": "es6", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"declaration": true, | ||
"sourceMap": true, | ||
"stripInternal": true, | ||
"experimentalDecorators": true, | ||
"pretty": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitAny": true, | ||
"noImplicitReturns": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strictNullChecks": true | ||
}, | ||
"files": [ | ||
"index.ts" | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters