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

Unable to handle scaleway_image due to returned more than one result problem #81

Closed
Edke opened this issue Jul 17, 2018 · 7 comments · Fixed by #82
Closed

Unable to handle scaleway_image due to returned more than one result problem #81

Edke opened this issue Jul 17, 2018 · 7 comments · Fixed by #82
Labels
instance Instance issues, bugs and feature requests

Comments

@Edke
Copy link

Edke commented Jul 17, 2018

Hi there,

trying to create servers with Ubuntu Xenial image but failing as can't find way to define name of image as Ubuntu Xenial throws error

* data.scaleway_image.ubuntu: data.scaleway_image.ubuntu: The query returned more than one result. Please refine your query.

With use of scw can't solve problem either as this tool provides only ID which does not work and other that that there is only Repository field but that is not name used in API query:

$ scw images
REPOSITORY               TAG                 IMAGE ID            CREATED             REGION              ARCH
Ubuntu_Mini_Xenial_25G   latest              bc75c00b            11 weeks            [ams1 par1]         [x86_64]
Ubuntu_Xenial            latest              0aea808f            2 years             [ams1 par1]         [arm arm64 x86_64]

Terraform Version

$ terraform -v
Terraform v0.11.7
+ provider.scaleway v1.5.1

Affected Resource(s)

  • scaleway_image

Terraform Configuration Files

provider "scaleway" {
  organization = ""
  token        = ""
  region       = "ams1"
}

data "scaleway_image" "ubuntu" {
  architecture = "x86_64"
  name         = "Ubuntu Xenial"
}

resource "scaleway_server" "master" {
  name = "master"
  image = "${data.scaleway_image.ubuntu.id}"
  type = "VC1S"
}

Debug Output

$ terraform apply
data.scaleway_image.ubuntu: Refreshing state...

Error: Error refreshing state: 1 error(s) occurred:

* data.scaleway_image.ubuntu: 1 error(s) occurred:

* data.scaleway_image.ubuntu: data.scaleway_image.ubuntu: The query returned no result. Please refine your query.

Expected Behavior

The server instance should be created.

Actual Behavior

Unable to lookup Ubuntu Xenial image

Steps to Reproduce

  1. terraform apply
@nicolai86
Copy link
Contributor

Hey @Edke ,

I'm sorry for this issue.

I've looked at the result of the Scaleway API for images with Ubuntu Xenial in their name -
the API has two images: ca9a9340-92e8-4c5f-8ae1-423466f7ef30 and d52d15d6-1658-4c48-89b0-234a8bb10652:


{
  "image": {
    "creation_date": "2018-07-04T12:35:34.106545+00:00",
    "default_bootscript": {
      "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.4-4.4.127-rev1/vmlinuz-4.4.127",
      "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.4.gz",
      "default": true,
      "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16",
      "architecture": "x86_64",
      "title": "x86_64 mainline 4.4.127 rev1",
      "dtb": "",
      "organization": "11111111-1111-4111-8111-111111111111",
      "id": "6c9a8fa4-acbe-4fd4-b7c9-c5f818783e00",
      "public": true
    },
    "from_server": null,
    "arch": "x86_64",
    "id": "d52d15d6-1658-4c48-89b0-234a8bb10652",
    "root_volume": {
      "size": 50000000000,
      "id": "8129b982-c033-42ea-9fe5-8ebb158704da",
      "volume_type": "l_ssd",
      "name": "snapshot-84e78b32-9aa2-4662-9954-262805b8f72d-2018-07-03_13:35"
    },
    "name": "Ubuntu Xenial",
    "modification_date": "2018-07-04T12:35:34.106545+00:00",
    "state": "available",
    "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db",
    "extra_volumes": [],
    "public": true
  }
}

{
  "image": {
    "creation_date": "2018-07-04T12:50:30.750864+00:00",
    "default_bootscript": {
      "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.4-4.4.127-rev1/vmlinuz-4.4.127",
      "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.4.gz",
      "default": true,
      "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16",
      "architecture": "x86_64",
      "title": "x86_64 mainline 4.4.127 rev1",
      "dtb": "",
      "organization": "11111111-1111-4111-8111-111111111111",
      "id": "6c9a8fa4-acbe-4fd4-b7c9-c5f818783e00",
      "public": true
    },
    "from_server": null,
    "arch": "x86_64",
    "id": "ca9a9340-92e8-4c5f-8ae1-423466f7ef30",
    "root_volume": {
      "size": 50000000000,
      "id": "109f7208-3087-4a7e-8800-f0fc602a7ff9",
      "volume_type": "l_ssd",
      "name": "snapshot-9e57ea92-a408-46d8-903e-6b7755175030-2018-06-28_15:17"
    },
    "name": "Ubuntu Xenial",
    "modification_date": "2018-07-04T12:50:30.750864+00:00",
    "state": "available",
    "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db",
    "extra_volumes": [],
    "public": true
  }
}

I think we should introduce a most_recent flag here to select a specific image, as they seem identical but for a 15 minute difference in build time...

@Edke
Copy link
Author

Edke commented Jul 18, 2018

Hi @nicolai86

Is there a way using terraform itself to see results of API ? Of course one can to an raw API call using any HTTP client but is this possible to do within terraform for easy solving and fetching ID quickly to go on ?

@Edke
Copy link
Author

Edke commented Jul 18, 2018

So even I know ID seems that I can't use it anyway. As in scaleway_server resource as image I can't use UUID of image directly, is that right ?

@nicolai86
Copy link
Contributor

@Edke you can use the UUID directly.
Also right now the terraform provider does not log this information - I'll add this for 1.6.0 so that you can get this information by running TF_LOG=DEBUG terraform apply.

@Edke
Copy link
Author

Edke commented Jul 18, 2018

Trying to apply

resource "scaleway_server" "pharos_master" {
  name = "pharos_master"
  image = "d52d15d6-1658-4c48-89b0-234a8bb10652"
  type = "VC1S"
}

And have response:

$ terraform apply

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  + scaleway_server.pharos_master
      id:           <computed>
      boot_type:    <computed>
      enable_ipv6:  "false"
      image:        "d52d15d6-1658-4c48-89b0-234a8bb10652"
      name:         "pharos_master"
      private_ip:   <computed>
      public_ip:    <computed>
      public_ipv6:  <computed>
      state:        <computed>
      state_detail: <computed>
      type:         "VC1S"


Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

scaleway_server.pharos_master: Creating...
  boot_type:    "" => "<computed>"
  enable_ipv6:  "" => "false"
  image:        "" => "d52d15d6-1658-4c48-89b0-234a8bb10652"
  name:         "" => "pharos_master"
  private_ip:   "" => "<computed>"
  public_ip:    "" => "<computed>"
  public_ipv6:  "" => "<computed>"
  state:        "" => "<computed>"
  state_detail: "" => "<computed>"
  type:         "" => "VC1S"

Error: Error applying plan:

1 error(s) occurred:

* scaleway_server.pharos_master: 1 error(s) occurred:

* scaleway_server.pharos_master: StatusCode: 404, Type: unknown_resource, APIMessage: "d52d15d6-1658-4c48-89b0-234a8bb10652" not found

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

@nicolai86
Copy link
Contributor

nicolai86 commented Jul 18, 2018

@Edke you must be in the par1 region, your above example works for me in ams1

@Edke
Copy link
Author

Edke commented Jul 18, 2018

@nicolai86 oh, got it, every datacentre has it's own images

@remyleone remyleone added the instance Instance issues, bugs and feature requests label Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
instance Instance issues, bugs and feature requests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants