Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update replacing compute instance doesn't maintain instance group membership #284

Open
c2h5oh opened this issue Feb 11, 2020 · 10 comments
Open
Labels
awaiting/core Blocked on a missing bug or feature in pulumi/pulumi (except codegen) kind/bug Some behavior is incorrect or out of spec

Comments

@c2h5oh
Copy link

c2h5oh commented Feb 11, 2020

pulumi v1.10.0 pulumi-gcp v2.2.0

Repro:

  1. create instance and instance group containing that instance
  2. make a change that requires instance to be replaced & apply it

Expected:
replacement instance is part of instance group

Actual:
replacement instance is not part of instance group

pulumi refresh followed by pulumi up fixes the issue (once you export stack, edit, import to deal with #273 ...)

const ubuntu1804LTS = gcp.compute.getImage(
    {
        family: "ubuntu-1804-lts",
        project: "gce-uefi-images"
    }
)

const instance = new gcp.compute.Instance(
   `my-instance`,
   {
      name: `my-instance`,
      description: `My Instance
      machineType: `n1-standard-1`,
      bootDisk: {
         autoDelete: true,
         initializeParams: {
            image: ubuntu1804LTS.selfLink
         }
      },
      networkInterfaces: [
         {
            network: my-network,
            subnetwork: my-subnet-cidr
         }
      ],
      zone: zone,
      allowStoppingForUpdate: false,
      deletionProtection: false,
      canIpForward: false,
      tags: [
         `my-tag`
      ],
      metadata: {
         "enable-oslogin": "TRUE"
      }
   },
   {
      ignoreChanges: [
         "bootDisk"
      ],
    }
)

const group = new gcp.compute.InstanceGroup(
   `my-group`,
   {
      name: `my-group`,
      namedPorts: [
         {
            name: "https",
            port: 443,
         }
      ],
      network: my-network,
      zone: zone,
      instances: [
         instance.selfLink
      ]
   }
)
@c2h5oh c2h5oh changed the title Update that replaces compute instance doesn't add new instance to instance group Update replacing compute instance doesn't maintain instance group membership Feb 11, 2020
@leezen leezen added the kind/bug Some behavior is incorrect or out of spec label Feb 25, 2020
@c2h5oh
Copy link
Author

c2h5oh commented Jun 10, 2022

So... 2 years later and some change we got hit with the exact same issue again - Is there anyone even working on this? All bugs I've reported since I've started using Pulumi with GCP are still open..

@mjeffryes mjeffryes added needs-repro Needs repro steps before it can be triaged or fixed and removed needs-repro Needs repro steps before it can be triaged or fixed labels Sep 25, 2024
@rshade rshade assigned rshade and unassigned rshade Nov 7, 2024
@rshade
Copy link
Contributor

rshade commented Nov 7, 2024

I tested this with the following code and its still broken at of 8.7.0, I swapped hostname. I get a update in preview but not in up.

 pulumi up --yes
The stack's environment does not define the `environmentVariables`, `files`, or `pulumiConfig` properties.
Without at least one of these properties, the environment will not affect the stack's behavior.

Previewing update (dev)

View in Browser (Ctrl+O): https://app.pulumi.com/team-ce/pu_gcp_268/dev/previews/bbea6e58-666b-4f7d-a74c-fa0f4afb15d2

     Type                          Name            Plan        Info
     pulumi:pulumi:Stack           pu_gcp_268-dev
 +-  ├─ gcp:compute:Instance       my-instance     replace     [diff: ~hostname]
 ~   └─ gcp:compute:InstanceGroup  my-group        update      [diff: ~instances]

Resources:
    ~ 1 to update
    +-1 to replace
    2 changes. 1 unchanged

Updating (dev)

View in Browser (Ctrl+O): https://app.pulumi.com/team-ce/pu_gcp_268/dev/updates/22

     Type                     Name            Status             Info
     pulumi:pulumi:Stack      pu_gcp_268-dev
 +-  └─ gcp:compute:Instance  my-instance     replaced (23s)     [diff: ~hostname]

Resources:
    +-1 replaced
    2 unchanged

Duration: 3m35s

Code:

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const pulumiConfig = new pulumi.Config()
const networkSelfLink = pulumiConfig.require("network")
const subnetworkSelfLink = pulumiConfig.require("subnetwork")
const hostName = pulumiConfig.require("hostname")

const instance = new gcp.compute.Instance(
    "my-instance",
    {
        name: "my-instance",
        description: "My Instance",
        machineType: "e2-standard-4",
        hostname: hostName,
        bootDisk: {
            autoDelete: true,
            initializeParams: {
                image: "projects/debian-cloud/global/images/debian-11-bullseye-v20240110"
            }
        },
        networkInterfaces: [
            {
                network: networkSelfLink,
                subnetwork: subnetworkSelfLink
            }
        ],
        zone: "us-west1-a",
        allowStoppingForUpdate: false,
        deletionProtection: false,
        canIpForward: true,
        tags: [
            "my-tag"
        ],
        metadata: {
            "enable-oslogin": "TRUE"
        }
    },
    {
        ignoreChanges: [
            "bootDisk"
        ],
    }
)

const group = new gcp.compute.InstanceGroup(
    "my-group",
    {
        name: "my-group",
        namedPorts: [
            {
                name: "https",
                port: 443,
            }
        ],
        network: networkSelfLink,
        zone: "us-west1-a",
        instances: [
            instance.selfLink
        ]
    }
)

@rshade
Copy link
Contributor

rshade commented Nov 7, 2024

Pulumi About:

CLI
Version      3.138.0
Go Version   go1.23.2
Go Compiler  gc

Plugins
KIND      NAME    VERSION
resource  gcp     8.7.0
language  nodejs  unknown

Host
OS       ubuntu
Version  20.04
Arch     x86_64

This project is written in nodejs: executable='/usr/bin/node' version='v22.11.0'


TYPE                                     URN
pulumi:pulumi:Stack                      urn:pulumi:dev::pu_gcp_268::pulumi:pulumi:Stack::pu_gcp_268-dev
pulumi:providers:gcp                     urn:pulumi:dev::pu_gcp_268::pulumi:providers:gcp::default_8_7_0
gcp:compute/instance:Instance            urn:pulumi:dev::pu_gcp_268::gcp:compute/instance:Instance::my-instance
gcp:compute/instanceGroup:InstanceGroup  urn:pulumi:dev::pu_gcp_268::gcp:compute/instanceGroup:InstanceGroup::my-group


Found no pending operations associated with dev

Backend
Name           pulumi.com

Dependencies:
NAME            VERSION
@pulumi/pulumi  3.138.0
@pulumi/gcp     8.7.0

Pulumi locates its logs in /tmp by default

@rshade rshade self-assigned this Nov 7, 2024
@t0yv0
Copy link
Member

t0yv0 commented Nov 7, 2024

Hi @rshade , it seems that in preview instance.selfLink was unknown so that indicated a preview diff, but during up this unknown resolved to the same value as before, resulting in no changes. CC @VenelinMartinov this is an interesting illustration of a recent conversation we had, on how bridge preview diff has to guess if something is going to be a replacement or not, in the case of an unknown. It appears the bridge makes a guess that this will be a replacement, even in cases where subsequent up is not a replacement.

@t0yv0
Copy link
Member

t0yv0 commented Nov 7, 2024

I'm assuming here that selfLink did not change after the replace. That would be great to double-check. @rshade is it possible to see what the selfLink value was before and after the replace?

@rshade
Copy link
Contributor

rshade commented Nov 7, 2024

Yes, it will be the same selfLink value, as the resourceName didn't change. Although the selfLink is now not present in the array of instances in the cloud while still present in state. Is there a way in our code to tell it, to update things that depend on it?

@rshade rshade added awaiting-feedback Blocked on input from the author and removed awaiting-feedback Blocked on input from the author labels Nov 8, 2024
@t0yv0
Copy link
Member

t0yv0 commented Nov 8, 2024

Cross-linking pulumi/pulumi#838 - this would have been really useful here.

@rshade rshade added the awaiting/core Blocked on a missing bug or feature in pulumi/pulumi (except codegen) label Nov 8, 2024
@rshade rshade removed their assignment Nov 8, 2024
@VenelinMartinov
Copy link
Contributor

I'm not sure if dependsOnWithReplacement is the solution here - in this case the dependent resource should always get replaced it looks like. Perhaps we need a way to mark resources for replacement during preview so that up can't change its mind on that decision

@c2h5oh
Copy link
Author

c2h5oh commented Nov 12, 2024

@VenelinMartinov pulumi up has --skip-preview flag, so relying on preview to decide what up does is not the best idea.

@VenelinMartinov
Copy link
Contributor

VenelinMartinov commented Nov 12, 2024

Thanks for pointing out @c2h5oh. I believe up does an implicit preview when planning what to do so I believe it should still translate well to --skip-preview.

The expected behaviour either way in this case is that the resources should have been replaced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting/core Blocked on a missing bug or feature in pulumi/pulumi (except codegen) kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

6 participants