pulumi-eks icon indicating copy to clipboard operation
pulumi-eks copied to clipboard

TS: Creating default cluster causing unexpected json error

Open jaskerv opened this issue 3 years ago • 7 comments
trafficstars

What happened?

Creating a default cluster throws failed with an unhandled exception: SyntaxError: Unexpected end of JSON input

Steps to reproduce

Run pulumi up

import { Cluster } from '@pulumi/eks';

  // Create an EKS cluster.
  const cluster = new Cluster('cluster');

Expected Behavior

Creates eks cluster.

Actual Behavior

Fails an throws the following error: failed with an unhandled exception: SyntaxError: Unexpected end of JSON input

Versions used

Pulumi

CLI          
Version      3.35.3
Go Version   go1.17.11
Go Compiler  gc

Host     
OS       darwin
Version  11.6.3
Arch     x86_64

TS

"@pulumi/eks": "^0.41.0",

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

jaskerv avatar Jul 14 '22 06:07 jaskerv

Hi @Jaskerv, I've just successfully created a default cluster (using your code sample above) and found no issues creating the cluster. Please could you let me know which version of the aws provider you are using in this project? Could you also confirm which resouce is throwing the error, and if there are any stack traces available? Thanks!

roothorp avatar Jul 14 '22 13:07 roothorp

I've tried it with the node v18 and v14. Still the same issue.

Providers:

        "@pulumi/aws": "^5.10.0",
        "@pulumi/awsx": "^0.40.0",
        "@pulumi/eks": "^0.41.0",
        "@pulumi/kubernetes": "^3.0.0",
        "@pulumi/kubernetesx": "^0.1.5",
        "@pulumi/pulumi": "^3.0.0"

Running with verbose logging:

❯ pulumi up -v 9
Previewing update (dev)

View Live: xxxx

     Type                  Name                 Plan       Info
 +   pulumi:pulumi:Stack   dev  create     1 error
 +   └─ eks:index:Cluster  cluster              create     
 
Diagnostics:
  pulumi:pulumi:Stack (dev):
    error: Running program 'xxxx' failed with an unhandled exception:
    SyntaxError: Unexpected end of JSON input
        at JSON.parse (<anonymous>)
        at Object.assertCompatibleKubectlVersionExists (xxxx/node_modules/@pulumi/dependencies.ts:46:46)
        at createCore (xxxx/node_modules/@pulumi/cluster.ts:359:5)
        at new Cluster (xxxx/node_modules/@pulumi/cluster.ts:1431:22)
        at Object.<anonymous> (xxxx/index.ts:7:19)
        at Module._compile (internal/modules/cjs/loader.js:1085:14)
        at Module.m._compile (xxxx/node_modules/ts-node/src/index.ts:439:23)
        at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
        at Object.require.extensions.<computed> [as .ts] (xxxx/node_modules/ts-node/src/index.ts:442:12)
        at Module.load (internal/modules/cjs/loader.js:950:32)
 

jaskerv avatar Jul 15 '22 00:07 jaskerv

I've also updated everything. Same issue :(

jaskerv avatar Jul 15 '22 03:07 jaskerv

Thanks for the stack trace - that's super helpful. It looks like the command kubectl version --output=json is returning something that is not JSON. Executing that command on your machine will likely highlight what the issue is.

danielrbradley avatar Jul 18 '22 10:07 danielrbradley

I'll keep this open until we can determine what's causing the parse to fail.

roothorp avatar Jul 19 '22 13:07 roothorp

I just had the same issue. What solved it for me was to select a context for kubectl (I had no selected context the when the error accoured). Maybe this will help :)

Nicarod avatar Jul 27 '22 12:07 Nicarod

Yeah this happened to me as well because of a bad ~/.kube/config even though the associated file was nothing to do with my pulumi stack. Removing that file fixed it.

cdibble avatar Aug 15 '22 19:08 cdibble