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

Pulumi import of a linode resource results in warnings #373

Open
tgummerer opened this issue Oct 4, 2023 · 2 comments
Open

Pulumi import of a linode resource results in warnings #373

tgummerer opened this issue Oct 4, 2023 · 2 comments
Labels
area/import An issue related to `pulumi import` or the import resource option. kind/bug Some behavior is incorrect or out of spec

Comments

@tgummerer
Copy link

tgummerer commented Oct 4, 2023

What happened?

I tried to import a resource using the Linode provider, which resulted in the following warnings:

    warning: One or more imported inputs failed to validate. This is almost certainly a bug in the `linode` provider. The import will still proceed, but you will need to edit the generated code after copying it into your program.
    warning: linode:index/instance:Instance resource 'tommy' has a problem: Conflicting configuration arguments: "swap_size": conflicts with disk. Examine values at 'tommy.swapSize'.
    warning: linode:index/instance:Instance resource 'tommy' has a problem: Conflicting configuration arguments: "disk": conflicts with swap_size. Examine values at 'tommy.disks'.
    warning: linode:index/instance:Instance resource 'tommy' has a problem: Conflicting configuration arguments: "config": conflicts with swap_size. Examine values at 'tommy.configs'.

It's pretty easy to fix, but I figured opening a bug report would be a good idea anyway.

Example

pulumi import linode:index/instance:Instance tommy

resulted in the following program:

	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := linode.NewInstance(ctx, "tommy", &linode.InstanceArgs{
			Alerts: &linode.InstanceAlertsArgs{
				NetworkIn:     pulumi.Int(5),
				NetworkOut:    pulumi.Int(5),
				TransferQuota: pulumi.Int(80),
			},
			BootConfigLabel: pulumi.String("My Debian 11 Disk Profile"),
			Booted:          pulumi.Bool(true),
			Configs: linode.InstanceConfigArray{
				&linode.InstanceConfigArgs{
					Devices: &linode.InstanceConfigDevicesArgs{
						Sda: &linode.InstanceConfigDevicesSdaArgs{
							DiskId:    pulumi.Int(<id>),
							DiskLabel: pulumi.String("Debian 11 Disk"),
						},
						Sdb: &linode.InstanceConfigDevicesSdbArgs{
							DiskId:    pulumi.Int(<id>),
							DiskLabel: pulumi.String("512 MB Swap Image"),
						},
					},
					Helpers: &linode.InstanceConfigHelpersArgs{
						DevtmpfsAutomount: pulumi.Bool(true),
					},
					Kernel:     pulumi.String("linode/grub2"),
					Label:      pulumi.String("My Debian 11 Disk Profile"),
					RootDevice: pulumi.String("/dev/sda"),
				},
			},
			Disks: linode.InstanceDiskTypeArray{
				&linode.InstanceDiskTypeArgs{
					Filesystem: pulumi.String("ext4"),
					Label:      pulumi.String("Debian 11 Disk"),
					Size:       pulumi.Int(50688),
				},
				&linode.InstanceDiskTypeArgs{
					Filesystem: pulumi.String("swap"),
					Label:      pulumi.String("512 MB Swap Image"),
					Size:       pulumi.Int(512),
				},
			},
			Label:  pulumi.String("tommy"),
			Region: pulumi.String("eu-west"),
			SwapSize: pulumi.Int(512),
		}, pulumi.Protect(true))
		if err != nil {
			return err
		}
		return nil
	})

The SwapSize here seems to conflict with the swap partition defined in the Disks struct.

Output of pulumi about

$ pulumi about    
CLI          
Version      3.86.0
Go Version   go1.21.1
Go Compiler  gc

Plugins
NAME    VERSION
go      unknown
linode  4.6.1

Host     
OS       debian
Version  12.1
Arch     x86_64

This project is written in go: executable='/home/tgummerer/.nix-profile/bin/go' version='go version go1.20.8 linux/amd64'

Current Stack: tgummerer/pulumi-test/dev

TYPE                            URN
pulumi:pulumi:Stack             urn:pulumi:dev::pulumi-test::pulumi:pulumi:Stack::pulumi-test-dev
pulumi:providers:linode         urn:pulumi:dev::pulumi-test::pulumi:providers:linode::default_4_6_1
linode:index/instance:Instance  urn:pulumi:dev::pulumi-test::linode:index/instance:Instance::tommy


Found no pending operations associated with tgummerer/dev

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/tgummerer
User           tgummerer
Organizations  tgummerer
Token type     personal

Dependencies:
NAME                                    VERSION
github.com/pulumi/pulumi-linode/sdk/v4  4.6.1
github.com/pulumi/pulumi/sdk/v3         3.86.0

Pulumi locates its logs in /tmp by default

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).

@tgummerer tgummerer added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Oct 4, 2023
@AaronFriel AaronFriel transferred this issue from pulumi/pulumi Oct 5, 2023
@lukehoban
Copy link
Member

It's plausible this is related to pulumi/pulumi-terraform-bridge#577.

@mikhailshilkov mikhailshilkov added area/import An issue related to `pulumi import` or the import resource option. and removed needs-triage Needs attention from the triage team labels Oct 6, 2023
t0yv0 added a commit to pulumi/pulumi-terraform-bridge that referenced this issue May 9, 2024
Toward #1225 -
this fixes the special case of ConflictsWith warnings. This fixes
spurious warnings on `pulumi import`, popular bugs such as:

- pulumi/pulumi-aws#2318 
- pulumi/pulumi-aws#3670
- pulumi/pulumi-gitlab#293
- pulumi/pulumi-gcp#844
- pulumi/pulumi-linode#373

TF does not guarantee Read results to be compatible with calling Check
on, in particular Read can return results that run afoul of
ConflictsWith constraint. This change compensates by arbitrarily
dropping data from the Read result until it passes ConflictsWith checks.

This affects `pulumi refresh` as well as I think it should although I
have not seen "in the wild" cases where refresh is affected, since it
typically will not copy these properties to the input bag unless they're
present in old inputs, which are usually correct wrt to ConflictsWith.
@t0yv0
Copy link
Member

t0yv0 commented Jun 13, 2024

Still having some issues here:

package main

import (
	"github.com/pulumi/pulumi-linode/sdk/v4/go/linode"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		inst, err := linode.NewInstance(ctx, "web", &linode.InstanceArgs{
			Label:  pulumi.String("simple_instance"),
			Image:  pulumi.String("linode/ubuntu22.04"),
			Region: pulumi.String("us-central"),
			Type:   pulumi.String("g6-standard-1"),
			AuthorizedKeys: pulumi.StringArray{
				pulumi.String("ssh-rsa AAAA...Gw== user@example.local"),
			},
			RootPass: pulumi.String("this-is-not-a-safe-password"),
			Tags: pulumi.StringArray{
				pulumi.String("foo"),
			},
			SwapSize:  pulumi.Int(256),
			PrivateIp: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		ctx.Export("instId", inst.ID())
		return nil
	})
}

And:

anton@anton-mbp-m3> pulumi import linode:index/instance:Instance mylinode $(pulumi stack output instId)                                                                                                                    ~/bugs/pulumi-linode-373
Previewing import (dev)

View in Browser (Ctrl+O): https://app.pulumi.com/anton-pulumi-corp/pulumi-linode-373/dev/previews/68e7c523-6f19-45e1-85c7-2a43e8f8dae8

     Type                      Name                   Plan       Info
     pulumi:pulumi:Stack       pulumi-linode-373-dev             
 =   └─ linode:index:Instance  mylinode               import     8 warnings

Diagnostics:
  linode:index:Instance (mylinode):
    warning: urn:pulumi:dev::pulumi-linode-373::linode:index/instance:Instance::mylinode verification warning: The embedded config is deprecated and scheduled to be removed in the next major version.Please consider migrating it  to linode_instance_config resource.
    warning: urn:pulumi:dev::pulumi-linode-373::linode:index/instance:Instance::mylinode verification warning: The embedded disk block in linode_instance resource is deprecated and scheduled to be removed in the next major version. Please consider migrating it to be the linode_instance_disk resource.
    warning: One or more imported inputs failed to validate. This is almost certainly a bug in the `linode` provider. The import will still proceed, but you will need to edit the generated code after copying it into your program.
    warning: linode:index/instance:Instance resource 'mylinode' has a problem: Value for unconfigurable attribute. Can't configure a value for "config.0.id": its value will be decided automatically based on the result of applying this configuration.. Examine values at 'mylinode.configs[0].id'.
    warning: linode:index/instance:Instance resource 'mylinode' has a problem: Value for unconfigurable attribute. Can't configure a value for "disk.0.id": its value will be decided automatically based on the result of applying this configuration.. Examine values at 'mylinode.disks[0].id'.
    warning: linode:index/instance:Instance resource 'mylinode' has a problem: expected length of disk.0.root_pass to be in the range (11 - 128), got . Examine values at 'mylinode.disks[0].rootPass'.
    warning: linode:index/instance:Instance resource 'mylinode' has a problem: expected length of disk.1.root_pass to be in the range (11 - 128), got . Examine values at 'mylinode.disks[1].rootPass'.
    warning: linode:index/instance:Instance resource 'mylinode' has a problem: Value for unconfigurable attribute. Can't configure a value for "disk.1.id": its value will be decided automatically based on the result of applying this configuration.. Examine values at 'mylinode.disks[1].id'.

Resources:
    = 1 to import
    2 unchanged

Do you want to perform this import?  [Use arrows to move, type to filter]
  yes
  no
> details

About:

CLI          
Version      3.117.0
Go Version   go1.22.3
Go Compiler  gc

Plugins
KIND      NAME    VERSION
language  go      unknown
resource  linode  4.21.0

Host     
OS       darwin
Version  14.5
Arch     arm64

This project is written in go: executable='/Users/anton/bin/go' version='go version go1.22.2 darwin/arm64'

Current Stack: anton-pulumi-corp/pulumi-linode-373/dev

TYPE                            URN
pulumi:pulumi:Stack             urn:pulumi:dev::pulumi-linode-373::pulumi:pulumi:Stack::pulumi-linode-373-dev
pulumi:providers:linode         urn:pulumi:dev::pulumi-linode-373::pulumi:providers:linode::default_4_21_0
linode:index/instance:Instance  urn:pulumi:dev::pulumi-linode-373::linode:index/instance:Instance::web


Found no pending operations associated with dev

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/anton-pulumi-corp
User           anton-pulumi-corp
Organizations  anton-pulumi-corp, moolumi, pulumi
Token type     personal

Dependencies:
NAME                                    VERSION
github.com/pulumi/pulumi-linode/sdk/v4  v4.21.0
github.com/pulumi/pulumi/sdk/v3         v3.118.0

Pulumi locates its logs in /var/folders/gd/3ncjb1lj5ljgk8xl5ssn_gvc0000gn/T/com.apple.shortcuts.mac-helper// by default

Although the bridge made progress on heuristics to automatically resolve ConflictsWith warnings during import, issues remain with imported values not passing validators and perhaps there is more work to be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/import An issue related to `pulumi import` or the import resource option. kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

4 participants