From 64eb33cb0c63b5f5ef2e3339c6e48596e0553686 Mon Sep 17 00:00:00 2001 From: Fraser Waters Date: Mon, 7 Nov 2022 13:15:36 +0000 Subject: [PATCH] Disable auto stack parenting --- .vscode/settings.json | 2 +- ...-parenting-to-see-if-that-fixes-10950.yaml | 4 ++++ pkg/engine/lifecycletest/pulumi_test.go | 1 + pkg/resource/deploy/step_generator.go | 21 ++++++++++++++----- tests/integration/integration_nodejs_test.go | 5 +++-- 5 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 changelog/pending/20221107--engine--disable-auto-parenting-to-see-if-that-fixes-10950.yaml diff --git a/.vscode/settings.json b/.vscode/settings.json index 219e84047247..aaf023f5ed55 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "go.buildTags": "all,smoke", + "go.buildTags": "all", "go.testTimeout": "1h", "gopls": { // A couple of modules get copied as part of builds and this confuse gopls as it sees the module name twice, just ignore the copy in the build folders. diff --git a/changelog/pending/20221107--engine--disable-auto-parenting-to-see-if-that-fixes-10950.yaml b/changelog/pending/20221107--engine--disable-auto-parenting-to-see-if-that-fixes-10950.yaml new file mode 100644 index 000000000000..f20f6cb7a97c --- /dev/null +++ b/changelog/pending/20221107--engine--disable-auto-parenting-to-see-if-that-fixes-10950.yaml @@ -0,0 +1,4 @@ +changes: +- type: fix + scope: engine + description: "Disable auto parenting to see if that fixes #10950." diff --git a/pkg/engine/lifecycletest/pulumi_test.go b/pkg/engine/lifecycletest/pulumi_test.go index 156f494fdbd2..c6a04830a787 100644 --- a/pkg/engine/lifecycletest/pulumi_test.go +++ b/pkg/engine/lifecycletest/pulumi_test.go @@ -4116,6 +4116,7 @@ func TestAdditionalSecretOutputs(t *testing.T) { func TestDefaultParents(t *testing.T) { t.Parallel() + t.Skipf("Default parents disabled due to https://github.com/pulumi/pulumi/issues/10950") loaders := []*deploytest.ProviderLoader{ deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) { diff --git a/pkg/resource/deploy/step_generator.go b/pkg/resource/deploy/step_generator.go index feccbc752cf7..cfe63eb3ca79 100644 --- a/pkg/resource/deploy/step_generator.go +++ b/pkg/resource/deploy/step_generator.go @@ -140,11 +140,22 @@ func (sg *stepGenerator) checkParent(parent resource.URN, resourceType tokens.Ty } } else { // Else try and set it to the root stack - for urn := range sg.urns { - if urn.Type() == resource.RootStackType { - return urn, nil - } - } + + // TODO: It looks like this currently has some issues with state ordering (see + // https://github.com/pulumi/pulumi/issues/10950). Best I can guess is the stack resource is + // hitting the step generator and so saving it's URN to sg.urns and issuing a Create step but not + // actually getting to writing it's state to the snapshot. Then in parallel with this something + // else is causing a pulumi:providers:pulumi default provider to be created, this picks up the + // stack URN from sg.urns and so sets it's parent automatically, but then races the step executor + // to write itself to state before the stack resource manages to. Long term we want to ensure + // there's always a stack resource present, and so that all resources (except the stack) have a + // parent (this will save us some work in each SDK), but for now lets just turn this support off. + + //for urn := range sg.urns { + // if urn.Type() == resource.RootStackType { + // return urn, nil + // } + //} } } diff --git a/tests/integration/integration_nodejs_test.go b/tests/integration/integration_nodejs_test.go index 27a4e861eea8..a927169d6102 100644 --- a/tests/integration/integration_nodejs_test.go +++ b/tests/integration/integration_nodejs_test.go @@ -306,8 +306,9 @@ func TestStackParenting(t *testing.T) { case "g": assert.Equal(t, urns["f"], res.Parent) case "default": - // Default providers should have the stack as a parent. - assert.Equal(t, stackRes.URN, res.Parent) + // Default providers should have the stack as a parent, but auto-parenting has been + // disabled so they won't have a parent for now. + assert.Equal(t, resource.URN(""), res.Parent) default: t.Fatalf("unexpected name %s", res.URN.Name()) }