Skip to content

Instantly share code, notes, and snippets.

@t0yv0
Created November 24, 2021 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t0yv0/558f3297c3a477ddc5d2c2bd487721b1 to your computer and use it in GitHub Desktop.
Save t0yv0/558f3297c3a477ddc5d2c2bd487721b1 to your computer and use it in GitHub Desktop.
Reproduce NPE in Pulumi .NET SDK
/*
To reliably hit the race NullPointerException with Pulumi, modify Pulumi.Core Resource.cs constructor to introduce a delay:
+ System.Threading.Thread.Sleep(100);
+ System.Console.WriteLine($"Delaying resource: {name}");
Deployment.InternalInstance.ReadOrRegisterResource(this, remote, urn => new DependencyResource(urn), args, options);
*/
using Pulumi;
using Pulumi.Kubernetes.Yaml;
using Pulumi.Kubernetes.Core.V1;
class MyStack : Stack
{
public MyStack()
{
var yaml = @"
apiVersion: v1
kind: Namespace
metadata:
name: foo
";
// Component Resource with delayed child (defined in yaml).
// The child is provisioned in an apply, introducing
// concurrency here.
var cg = new ConfigGroup("cg",
new ConfigGroupArgs
{
Yaml = yaml
});
// Any resource depending on the Component Resource. This will
// race to find the child introduced in `yaml` before the
// child's constructor completes.
new Namespace("ns", null, new CustomResourceOptions
{
DependsOn = cg
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment