cdk8s-team/cdk8s-plus

Workload resources fail to synth

iliapolo opened this issue · 2 comments

Description of the bug:

Looks like all workload resources (except Pod) are failing to synth:

  • StatefulSet
  • CronJob
  • Job
  • Deployment
  • DaemonSet

Reproduction Steps:

new kplus.StatefulSet(this, 'DB', {
  containers: [{ image: 'db', portNumber: 8000 }],
});

Error Log:

Synthesizing application
/Users/epolon/dev/src/github.com/cdk8s-team/cdk8s-examples/node_modules/cdk8s/src/metadata.ts:168
    this.name = options.name;
                        ^
TypeError: Cannot read properties of undefined (reading 'name')
    at new ApiObjectMetadataDefinition (/Users/epolon/dev/src/github.com/cdk8s-team/cdk8s-examples/node_modules/cdk8s/src/metadata.ts:168:25)
    at new Workload (/Users/epolon/dev/src/github.com/cdk8s-team/cdk8s-examples/typescript/cdk8s-plus-web-cache-db/node_modules/cdk8s-plus-26/src/workload.ts:82:24)
    at new StatefulSet (/Users/epolon/dev/src/github.com/cdk8s-team/cdk8s-examples/typescript/cdk8s-plus-web-cache-db/node_modules/cdk8s-plus-26/src/stateful-set.ts:130:5)
    at new WebCacheDB (/Users/epolon/dev/src/github.com/cdk8s-team/cdk8s-examples/typescript/cdk8s-plus-web-cache-db/index.ts:12:16)
    at Object.<anonymous> (/Users/epolon/dev/src/github.com/cdk8s-team/cdk8s-examples/typescript/cdk8s-plus-web-cache-db/index.ts:70:1)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module.m._compile (/Users/epolon/dev/src/github.com/cdk8s-team/cdk8s-examples/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/epolon/dev/src/github.com/cdk8s-team/cdk8s-examples/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
Error: command "ts-node index.ts " at /Users/epolon/dev/src/github.com/cdk8s-team/cdk8s-examples/typescript/cdk8s-plus-web-cache-db returned a non-zero exit code 1
    at ChildProcess.<anonymous> (/Users/epolon/dev/src/github.com/cdk8s-team/cdk8s-examples/node_modules/cdk8s-cli/lib/util.js:51:27)
    at Object.onceWrapper (node:events:628:26)
    at ChildProcess.emit (node:events:513:28)
    at ChildProcess._handle.onexit (node:internal/child_process:291:12)

This is 🐛 Bug Report

Resolved by #3016. Specifically, this commit.

@iliapolo I think I'm running into this attempting to update a legacy application to cdk8s-plus-22 (2.0.0-rc.158).

Is it possible to try backporting the fix to cdk8s-plus-22? I tested a patch (using patch-package) using the changes from the commit you linked and it seemed to allow my synth to complete.