having a lot of trouble with pulumi the last few d...
# general
i
having a lot of trouble with pulumi the last few days. pulumi.Ouput({ x: <a pulumi.secret> }) is not resolved in the .apply callback and the CLI is spewing out lines when it tries to render the spinners for
pulumi up
instead of updating the animation in-place anyone else seeing these things?
l
I haven't seen the 2nd problem. Is the first thing unchanged since it was previously working? Or is it new code that has never done what you want? You could post the code here and we can have a go at diagnosing.
i
I think it may be an issue with the kubernetes plugin, and how its treating the values prop
im trying to create a small reproducible but from what I can gather:
Copy code
"foo": pulumi.output("bar")
is resulting in:
Copy code
"foo": "Calling [toJSON] on an [Output<T>] is not supported.\n\nTo get the value of an Output as a JSON value or JSON string consider either:\n    1: o.apply(v => v.toJSON())\n    2: o.apply(v => JSON.stringify(v))\n\nSee <https://www.pulumi.com/docs/concepts/inputs-outputs> for more details.\nThis function may throw in a future version of @pulumi/pulumi."
l
Is that in a resource constructor? If not, that is the expected output. I'd need more code to diagnose further
i
closest thing i have to a isolated test case so far is:
Copy code
new k8s.helm.v4.Chart(
  'dagster',
  {
    repositoryOpts: {
      repo: '<https://dagster-io.github.io/helm>',
    },
    chart: 'dagster',
    values: {
      postgresql: {
        postgresqlPassword: pulumi.output('test'),
      },
    },
  },
  {
    transforms: [
      args => {
        return args
      },
    ],
  },
)
if i use a static string instead of pulumi.output it works or if I remove the transform it works this seems to be a new bug, as it did not behave this way before
if i log
args
i can see that postgresqlPassword is still a
OutputImpl
when it should have been resolved prior to hitting the transform stage
l
Yes I'd look at the way that postgresql property is handled. It may well be a simple toString instead of unwrapping and applying.
i
in a helm chart resource you have the
values
prop which is just a YAML document and shouldn't have any special processing at the pulumi level
l
Then this behaviour is correct, isn't it?
If there's supposed to be no processing, then the output won't be unwrapped
i
it was unwrapped prior to the latest version of the kubernetes plugin
l
There was a change recently that may explain it. Unwrapping nested objects stops at Resource classes now, but it didn't before. So if the values object is implemented in the provider as a resource, that would explain it.
If it is just a simple key:value collection then it should work.
i
oh boy, im relying on unwrapping nested objects in many many places. e.g.
Copy code
pulumi.output(deeplyNestedObject).apply(x => JSON.stringify(x))
where can i find more info?
as an example, this is a common pattern with AWS IAM policies
l
It works for non-resource objects.
Yes, it still works there, because aws.iam.PolicyDocument has special handling.
i
am hoping that wrapping the values object like so will work?
Copy code
values: pulumi.output({ ... })
l
Yes. So long as the object's class isn't Resource, then you should be good. If not, then raise an issue.
i
im looking through the changelog and can't seem to find any info about this new unwrapping behaviour. would you happen to have a link handy?
l
I saw the link in Slack about 10 days ago maybe? Pretty sure I was in the thread, I'll check my history.
Ah. I misread. It hasn't been merged. https://github.com/pulumi/pulumi/pull/13567
So maybe just raise an issue? If it's not working, then I have no explanation for it. And suddenly I feel a lot less inclined to update Pulumi...
i
ok here is my repro code:
Copy code
import * as pulumi from '@pulumi/pulumi'
import * as k8s from '@pulumi/kubernetes'
import * as random from '@pulumi/random'

const uc = {
  env: 'bug'
}

const psql = (() => {
  const host = `dagster-postgresql.dagster-${uc.env}`
  const user = 'dagstersu'
  const rnd = new random.RandomBytes('sasl-password', { length: 32 })
  const pass = pulumi.interpolate`dagster_${rnd.hex}`
  const db = 'dagster'
  return { host, user, pass, db }
})()

new k8s.helm.v4.Chart(
  'dagster',
  {
    repositoryOpts: {
      repo: '<https://dagster-io.github.io/helm>',
    },
    chart: 'dagster',
    values: {
      postgresql: {
        postgresqlHost: psql.host,
        postgresqlUsername: psql.user,
        postgresqlPassword: psql.pass,
        postgresqlDatabase: psql.db,
      },
    }
  },
  {
    transforms: [
      args => {
        console.log(args.props.values.postgresql)
        return args
      }
    ]
  }
)
if i remove the transforms - it suddenly works... so there must be something very strange going on in the pulumi internals
i dont know whats causing the bug here - pulumi, kubernetes plugin or random plugin
l
Is the function needed? Does the issue happen if you replace that with a simple object?
i
things that make the bug go away: • dropping the transform function (i need it for other reasons) • using a static string for
postgresqlPassword
• using any other type of pulumi.output for password, it seems to be if specifically from Random that it causes this bug