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

Go: Error when accessing CoreDataOutput of eks.Cluster #537

Closed
bothra90 opened this issue Feb 16, 2021 · 8 comments · Fixed by pulumi/pulumi#6641
Closed

Go: Error when accessing CoreDataOutput of eks.Cluster #537

bothra90 opened this issue Feb 16, 2021 · 8 comments · Fixed by pulumi/pulumi#6641
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Milestone

Comments

@bothra90
Copy link

bothra90 commented Feb 16, 2021

I added the following to my eks cluster setup project:

oidcUrl := eksCluster.Core.OidcProvider().ApplyT(func(oidc *iam.OpenIdConnectProvider) pulumi.StringOutput { return oidc.Url })
ctx.Export("oidcUrl", oidcUrl)

where eksCluster is defined as:

eksCluster, err := eks.NewCluster(ctx, "eks-cluster", &eks.ClusterArgs{
	VpcId:                  pulumi.String(defaultVpc.Id),
	SubnetIds:              toPulumiStringArray(subnet.Ids),
	InstanceType:           pulumi.String("t2.medium"),
	DesiredCapacity:        pulumi.Int(1),
	MaxSize:                pulumi.Int(1),
	MinSize:                pulumi.Int(1),
	EncryptionConfigKeyArn: key.Arn,
	CreateOidcProvider:     pulumi.Bool(true),
})

Current behavior

I'm getting the following error when running pulumi preview:

  pulumi:pulumi:Stack (eks-dev):
    error: program failed: missing one or more required arguments
    exit status 1

    error: an unhandled error occurred: program exited with non-zero exit code: 1

When I run the command with --verbose 6, the logs show:

     pulumi:pulumi:Stack  eks-dev  running..   error: program failed: missing one or more required arguments
I0215 16:57:18.681283   66724 eventsink.go:78] eventSink::Infoerr(<{%reset%}>exit status 1
     pulumi:pulumi:Stack  eks-dev  running..   exit status 1
I0215 16:57:18.700585   66724 source_eval.go:178] EvalSourceIterator ended with an error: an unhandled error occurred: program exited with non-zero exit code: 1

Expected behavior

No error

Context (Environment)

I'm following the instructions here to get IAM roles for my kubernetes services.

Affected feature

Adding OIDC provider to an EKS cluster and accessing its output value.
I get the same error when trying to accomplish this via another output value:

oidcUrl := eksCluster.EksCluster.ApplyT(func(cluster *eks.Cluster) pulumi.StringOutput {
	return cluster.Identities.Index(pulumi.Int(0)).ApplyString(func(c eks.ClusterIdentity) string {
		return *c.Oidcs[0].Issuer
	})
})
ctx.Export("oidcUrl", oidcUrl)
@bothra90 bothra90 changed the title Go: Error when accessing CoreDataOutput of EksCluster Go: Error when accessing CoreDataOutput of eks.Cluster Feb 16, 2021
@lblackstone
Copy link
Member

@justinvp Can you take a look at this?

@bothra90
Copy link
Author

@justinvp: Can you help with this?

@bothra90
Copy link
Author

@lblackstone, @justinvp : Wondering if you can help with a workaround if not a fix. Thanks!

@justinvp
Copy link
Member

Hi @bothra90. Sorry for the trouble here. Thanks for opening the issue and your patience! This appears to be an issue in our Go SDK codegen.

All of our New* functions check for nil args and return an error when that's the case, e.g.:

func NewManagedNodeGroup(ctx *pulumi.Context,
name string, args *ManagedNodeGroupArgs, opts ...pulumi.ResourceOption) (*ManagedNodeGroup, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}

However, to support components that return other resources, we need to be able to "rehydrate" those resources, and we do so by calling its associated New function, passing the resource's URN as a resource option, and nil for the args, e.g.:

case "eks:index:ManagedNodeGroup":
r, err = NewManagedNodeGroup(ctx, name, nil, pulumi.URN_(urn))

Always returning an error for nil args is the problem here. We need to update the codegen to not return an error when a URN is passed-in: https://github.com/pulumi/pulumi/blob/22f332e094c5c2cf4afa1a841c3c3b7971a6952c/pkg/codegen/go/gen.go#L1049-L1055. And then re-run the codegen for EKS.

@bothra90
Copy link
Author

@justinvp : Thanks for getting back. I see various accesses to fields inside args in lines 1058-1126 (https://github.com/pulumi/pulumi/blob/22f332e094c5c2cf4afa1a841c3c3b7971a6952c/pkg/codegen/go/gen.go#L1058-L1126). So my guess is that it's not a simple change to just not return an error if a URN is provided, but instead fetch the registered resource using the URN instead of creating a new one.

@infin8x infin8x added this to the 0.54 milestone Mar 19, 2021
@infin8x
Copy link

infin8x commented Mar 19, 2021

We will get this fixed during the current milestone (which ends April 2)

@justinvp justinvp added kind/bug Some behavior is incorrect or out of spec and removed bug labels Mar 19, 2021
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Mar 31, 2021
@justinvp
Copy link
Member

The Go SDK codegen bug causing this issue has been fixed. Next we'll need to adopt change in pulumi-eks and release a new version containing the fix.

@justinvp
Copy link
Member

The fix is included in v0.30.0 of pulumi-eks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants