https://pulumi.com logo
#general
Title
# general
r

rhythmic-finland-36256

10/09/2019, 5:55 PM
Using
ComponentResource
with shared
ComponentResourceOptions
passed down to the child resources seems to mutate the options - which leads to confusing error messages of duplicate resource aliases. Do I need to construct a new options object for each child resource?
My idea was to encapsulate some kubernetes deployments inside a
ComponentResource
, constructing the options in the ComponentResource constructor and passing the same instance to all children. Doing so resulted in an error of duplicate aliases for several URNs. When constructing them for each this doesn’t happen.
Copy code
error: Duplicate resource alias 'urn:pulumi:dev::xxxxx::ajaegle:xxxxx:fullservicedeployment$kubernetes:apps/v1:Deployment::whoami' applied to resource with URN 'urn:pulumi:dev::xxxxx::ajaegle:xxxxx:fullservicedeployment$kubernetes:apps/v1:Deployment::processor-deploy' conflicting with resource with URN 'urn:pulumi:dev::xxxxx::ajaegle:xxxxx:fullservicedeployment$kubernetes:core/v1:Service::processor-svc'
This happened when I created a
ComponentResourceOptions
(using deconstruction) in the
ComponentResource
constructor and passing it as third argument like
this.k8sResourceOpts
. Works when using
{parent: this, provider: this.args.k8sProvider}
. Is there some mutation on the object? I’m using kubernetes deployments and services as child resources.
w

white-balloon-205

10/09/2019, 7:40 PM
In principal we should not be mutating these, but it is possible there is a bug somewhere that this is triggering. Could you open an issue, ideally with a smallish repro?
r

rhythmic-finland-36256

10/10/2019, 9:44 AM
I just set up a minimal repository that should cause the same issues and cannot find them. So I reverted the code in my real project to the version containing these shared options and now also there - no more complaints. The difference here is that I’m doing it from zero to full instead of the half/half case before. Could this be the root cause of the issue (maybe some diff method that causes this)? Seems pretty hard to reproduce now.
I assumed that it could be caused by first creating only one deployment and in a next run creating the second deployment which would cause a diff to be run (possibly triggering these problems). So I ran it with just one deployment and one service and when performing the update (not just preview) it failed with just the deployment and the service. I try if this happens reliably and if so, provide a repro repository.
Error after
pulumi up
and applying the changes:
Copy code
panic: fatal: An assertion has failed: Two resources ('urn:pulumi:dev::pulumi-component-resource-mutability-issue::ajaegle:componentres:mutabilityissue$kubernetes:apps/v1:Deployment::whoami-one' and 'urn:pulumi:dev::pulumi-component-resource-mutability-issue::ajaegle:componentres:mutabilityissue$kubernetes:core/v1:Service::whoami') aliased to the same: 'urn:pulumi:dev::pulumi-component-resource-mutability-issue::ajaegle:componentres:mutabilityissue$kubernetes:apps/v1:Deployment::whoami-one'

goroutine 297 [running]:
<http://github.com/pulumi/pulumi/pkg/util/contract.failfast(...)|github.com/pulumi/pulumi/pkg/util/contract.failfast(...)>
	/private/tmp/pulumi-20191001-29115-1u0fjxm/src/github.com/pulumi/pulumi/pkg/util/contract/failfast.go:23
<http://github.com/pulumi/pulumi/pkg/util/contract.Assertf(0xc001162200|github.com/pulumi/pulumi/pkg/util/contract.Assertf(0xc001162200>, 0x22f3765, 0x37, 0xc00174bce0, 0x3, 0x3)
	/private/tmp/pulumi-20191001-29115-1u0fjxm/src/github.com/pulumi/pulumi/pkg/util/contract/assert.go:33 +0x198
<http://github.com/pulumi/pulumi/pkg/resource/deploy.(*Snapshot).NormalizeURNReferences(0xc00109e240)|github.com/pulumi/pulumi/pkg/resource/deploy.(*Snapshot).NormalizeURNReferences(0xc00109e240)>
	/private/tmp/pulumi-20191001-29115-1u0fjxm/src/github.com/pulumi/pulumi/pkg/resource/deploy/snapshot.go:112 +0x6cb
<http://github.com/pulumi/pulumi/pkg/backend.(*SnapshotManager).saveSnapshot(0xc001134480|github.com/pulumi/pulumi/pkg/backend.(*SnapshotManager).saveSnapshot(0xc001134480>, 0xc00174bf30, 0x2)
	/private/tmp/pulumi-20191001-29115-1u0fjxm/src/github.com/pulumi/pulumi/pkg/backend/snapshot.go:565 +0x42
<http://github.com/pulumi/pulumi/pkg/backend.NewSnapshotManager.func1(0xc0010843c0|github.com/pulumi/pulumi/pkg/backend.NewSnapshotManager.func1(0xc0010843c0>, 0xc001134480, 0xc001084420, 0xc001084480)
	/private/tmp/pulumi-20191001-29115-1u0fjxm/src/github.com/pulumi/pulumi/pkg/backend/snapshot.go:608 +0x12e
created by <http://github.com/pulumi/pulumi/pkg/backend.NewSnapshotManager|github.com/pulumi/pulumi/pkg/backend.NewSnapshotManager>
	/private/tmp/pulumi-20191001-29115-1u0fjxm/src/github.com/pulumi/pulumi/pkg/backend/snapshot.go:597 +0x150
18 Views