pulumi / pulumi-ec

Pulumi provider for the Elasticsearch Service and Elastic Cloud Enterprise
Apache License 2.0
5 stars 1 forks source link

error: objectEncoder failed on property "elasticsearch": objectEncoder failed on property "autoscale": Expected a Boolean #147

Open dermasmid opened 1 year ago

dermasmid commented 1 year ago

What happened?

getting this error since 0.6.0

Example

const esDeployment = new ec.Deployment( 'elasticsearch', { name: es, region: gcp-${location}, version: '8.9.0', deploymentTemplateId: 'gcp-compute-optimized-v2', elasticsearch: { autoscale: true, hot: { size: isProduction ? '16g' : '4g', autoscaling: {}, }, }, kibana: {}, }, );

Output of pulumi about

CLI
Version 3.85.0 Go Version go1.21.1 Go Compiler gc

Plugins NAME VERSION cloudflare 5.11.0 cloudflare 5.9.0 datadog 4.22.0 datadog 4.22.0 ec 0.7.0 ec 0.5.1 gcp 6.66.0 gcp 6.65.0 google-native 0.31.1 google-native 0.31.1 kubernetes 4.3.0 kubernetes 4.1.1 mongodbatlas 3.10.1 mongodbatlas 3.10.0 nodejs unknown random 4.14.0 random 4.13.2 slack 0.4.2 slack 0.4.2

Host
OS darwin Version 14.0 Arch arm64

@pulumi/ec 0.7.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).

mikhailshilkov commented 1 year ago

Hi @dermasmid thank you for reporting this. I tried to reproduce the issue with

import * as pulumi from "@pulumi/pulumi";
import * as ec from "@pulumi/ec";

const esDeployment = new ec.Deployment('elasticsearch', {
    region: "us-east-1",
    version: '8.9.0',
    deploymentTemplateId: 'aws-io-optimized-v2',
    elasticsearch: {
        autoscale: true,
        hot: {
            size: '4g',
            autoscaling: {},
        },
    },
    kibana: {},
});

but it succeeds for me on 0.7.0 version.

Could you please elaborate whether you get the error on preview, up, or some other combination of steps? Are you able to get the same error on my basic repro?

dermasmid commented 1 year ago

could it be because it was created by an older version? prior to 0.6.0 autoscale was a string

mikhailshilkov commented 1 year ago

Indeed! I got it reproduced, thank you.

So the steps are:

  1. Install pulumi/ec version 0.5.0.
  2. Deploy
import * as ec from "@pulumi/ec";

const esDeployment = new ec.Deployment('elasticsearch', {
    region: "us-east-1",
    version: '8.9.0',
    deploymentTemplateId: 'aws-io-optimized-v2',
    elasticsearch: {
        autoscale: "true",
    },
    kibana: {},
});
  1. Install the version 0.7.0.
  2. Change the program to
import * as pulumi from "@pulumi/pulumi";
import * as ec from "@pulumi/ec";

const esDeployment = new ec.Deployment('elasticsearch', {
    region: "us-east-1",
    version: '8.9.0',
    deploymentTemplateId: 'aws-io-optimized-v2',
    elasticsearch: {
        autoscale: true,
        hot: {
            size: '4g',
            autoscaling: {},
        },
    },
    kibana: {},
});
  1. pulumi preview
ec:index:Deployment (elasticsearch):
    error: objectEncoder failed on property "elasticsearch": objectEncoder failed on property "autoscale": Expected a Boolean
dermasmid commented 11 months ago

i tried editing the state to change the autoscale field to a bool, but then i get this ` error: Unable to Upgrade Resource State: This resource was implemented without an UpgradeState() method, however Terraform was expecting an implementation for version 1 upgrade.

This is always an issue with the Terraform Provider and should be reported to the provider developer.`
dermasmid commented 11 months ago

fixed it by changing the schema version in the state to 2

"__meta": "{\"dddd\":{\"create\":2400000000000,\"default\":2400000000000,\"delete\":3600000000000,\"read\":2400000000000,\"update\":3600000000000},\"schema_version\":\"1\"}",

perevernihata commented 9 months ago

fixed it by changing the schema version in the state to 2

"__meta": "{"dddd":{"create":2400000000000,"default":2400000000000,"delete":3600000000000,"read":2400000000000,"update":3600000000000},"schema_version":"1"}",

did you do it by manually tweaking state? would pulumi state upgrade do same job?

dermasmid commented 9 months ago

i did it manually

perevernihata commented 9 months ago

thanks for responding, did not help for me, fails with a different message after I change field to bool and update metadata:

  ec:index:Deployment (ami-search-staging):
    error: ec:index/deployment:Deployment resource '*****' has a problem: Missing required property 'elasticsearch.hot': 'hot' topology element

I upgraded from 0.5.1 to 0.7.0. I guess I will experiment with state until it works. Btw, I am considering removing whole thing from state and then importing using pulumi import https://www.pulumi.com/docs/cli/commands/pulumi_import/. Did you try this? Any pitfalls you know about?

dermasmid commented 9 months ago

there are some other changes that you need to make to the pulumi code, besides this bug, look at my code example above

perevernihata commented 9 months ago

I changed pulumi code, its the old state that causes error.

dermasmid commented 9 months ago

sorry i dont remember exactly what i did

thovden commented 9 months ago

I'm also getting this error going from 0.5.1 to 0.7.0. The following steps worked:

  1. pulumi export --file stack.json
  2. Edit stack.json and change: a. "__meta": "...schema_version to 2 b. Change "autoscale": 'false' to "autoscale": false
  3. pulumi import --file stack.json
mjeffryes commented 1 week ago

Unfortunately, it looks like this issue hasn't seen any updates in a while. If you're still encountering this problem, could you leave a quick comment to let us know so we can prioritize it? (Commenting will bump it back into our triage queue.)

perevernihata commented 1 week ago

I ended up messing up with internal state in some way which I do not remember anymore, but I made the problem go away and we were able to upgrade. Unfortunately as a consequence of doing so, right now we see a diff every time we run pulumi update it gives us false-positive diff with no change: Image and I have no good idea on how to fix it. Pulumu refresh does not help

guineveresaenger commented 1 week ago

hi @perevernihata - that does potentially sound like a different issue.

Would you be able to provide us with your program so we can run some reproductions on our end? Thank you very much!

mjeffryes commented 1 week ago

hi @perevernihata - that does potentially sound like a different issue.

Would you be able to provide us with your program so we can run some reproductions on our end? Thank you very much!

To tag on here, it would be best I think if you can open this as a separate bug report. It looks like an independent problem and the comment history will only get in the way of the new investigation.

perevernihata commented 1 week ago

I am not trying to report the issue, I only mentioned it cause it happened in relation to original problem - but it was me causing it and I will not be able to reproduce this on new repository since I do not remember how exactly state was manually tweaked. Moral of the story is - do not mess with state manually.