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

Source image not found when searching by image name #8630

Closed
v0lumehi opened this issue Jan 21, 2020 · 5 comments
Closed

Source image not found when searching by image name #8630

v0lumehi opened this issue Jan 21, 2020 · 5 comments
Labels
builder/openstack community-supported-plugin denotes requests for plugins that are supported by the community, not by HashiCorp engineers question remote-plugin/openstack

Comments

@v0lumehi
Copy link

v0lumehi commented Jan 21, 2020

Hello guys,

I think I discovered a bug in the openstack builder.
I have following packer version:

$ packer --version
1.5.1

This is my packer config and it is working fine:

{
  "variables": {
    "git_username": "",
    "git_password": ""
  },
  "builders": [{
    "type": "openstack",
    "flavor": "m.large",
    "image_name": "jenkins-chef-slave-nightly",
    "source_image": "ubuntu-18.04-x86_64-latest",
    "ssh_username": "ubuntu",
    "identity_endpoint": "https://my.great.cloud:5000/v3",
    "networks": ["6e80f6c6-3a24-44be-b15c-54b1f9d86c6e"],
    "floating_ip_network": "6541b7d0-db72-4a17-9d7e-de5d5b894ead",
    "security_groups": ["97e99840-e6f0-4fff-8f67-2afd3b8a3c43"],
    "use_blockstorage_volume": true,
    "volume_size": 10,
    "volume_name": "jenkins-chef-slave-nightly-volume",
    "image_disk_format": "qcow2",
    "metadata": {
      "image_name": "jenkins-chef-slave-nightly"
    }
  }],
  "provisioners": [{
      "type": "shell",
      "environment_vars": [
        "GIT_USERNAME={{user `git_username`}}",
        "GIT_PASSWORD={{user `git_password`}}"
      ],
      "scripts": [
        "./common/scripts/ubuntu/base.sh",
        "./common/scripts/ubuntu/docker.sh",
        "./common/scripts/ubuntu/chefdk.sh",
        "./common/scripts/ubuntu/users.sh",
        "./common/scripts/ubuntu/cleanup.sh"
      ]
    }
  ]
}

Now if I remove this block:

"use_blockstorage_volume": true,
"volume_size": 10,
"volume_name": "jenkins-chef-slave-nightly-volume",
"image_disk_format": "qcow2",

and run packer, packer throws this error:

$ packer build build.json
openstack output will be in this color.

==> openstack: Loading flavor: m.large
    openstack: Verified flavor. ID: 92506745-0305-4997-a58a-0f1a6be40a08
==> openstack: Creating temporary keypair: packer_5e26cac3-61bd-d7be-f4b1-463cc436cbc4 ...
==> openstack: Created temporary keypair: packer_5e26cac3-61bd-d7be-f4b1-463cc436cbc4
==> openstack: Launching server...
==> openstack: Launching server...
==> openstack: Error launching source server: Bad request with: [POST https://my.great.cloud:8774/v2.1/2b1777b0d2ec4263a6f0a63a0f313670/servers], error message: {"badRequest": {"message": "Invalid input for field/attribute imageRef. Value: ubuntu-18.04-x86_64-latest. u'ubuntu-18.04-x86_64-latest' is not valid under any of the given schemas", "code": 400}}
==> openstack: Terminating the source server:  ...
==> openstack: Error terminating server, may still be around: Resource not found
==> openstack: Deleting temporary keypair: packer_5e26cac3-61bd-d7be-f4b1-463cc436cbc4 ...
Build 'openstack' errored: Error launching source server: Bad request with: [POST https://my.great.cloud:8774/v2.1/2b1777b0d2ec4263a6f0a63a0f313670/servers], error message: {"badRequest": {"message": "Invalid input for field/attribute imageRef. Value: ubuntu-18.04-x86_64-latest. u'ubuntu-18.04-x86_64-latest' is not valid under any of the given schemas", "code": 400}}

==> Some builds didn't complete successfully and had errors:
--> openstack: Error launching source server: Bad request with: [POST https://my.great.cloud:8774/v2.1/2b1777b0d2ec4263a6f0a63a0f313670/servers], error message: {"badRequest": {"message": "Invalid input for field/attribute imageRef. Value: ubuntu-18.04-x86_64-latest. u'ubuntu-18.04-x86_64-latest' is not valid under any of the given schemas", "code": 400}}

==> Builds finished but no artifacts were created.

If I replace the source_image name with its ID, it's working properly:

$ packer build build.json
openstack output will be in this color.

==> openstack: Loading flavor: m.large
    openstack: Verified flavor. ID: 92506745-0305-4997-a58a-0f1a6be40a08
==> openstack: Creating temporary keypair: packer_5e26cb83-cafb-8502-3cd6-727f291199f5 ...
==> openstack: Created temporary keypair: packer_5e26cb83-cafb-8502-3cd6-727f291199f5
==> openstack: Launching server...
==> openstack: Launching server...
    openstack: Server ID: 0c516d5d-d23e-4ee4-8355-b78d28bdc6b3
==> openstack: Waiting for server to become ready...
==> openstack: Creating floating IP using network 6541b7d0-db72-4a17-9d7e-de5d5b894ead ...
    openstack: Created floating IP: 'f58318df-3644-420a-af6b-fdfa3c803549' (10.0.30.38)
==> openstack: Associating floating IP 'f58318df-3644-420a-af6b-fdfa3c803549' (10.0.30.38) with instance port...
    openstack: Added floating IP 'f58318df-3644-420a-af6b-fdfa3c803549' (10.0.30.38) to instance!
==> openstack: Using ssh communicator to connect: 10.0.30.38
==> openstack: Waiting for SSH to become available...
==> openstack: Connected to SSH!
==> openstack: Provisioning with shell script: ./common/scripts/ubuntu/base.sh
...
==> openstack: Deleting temporary keypair: packer_5e26cb83-cafb-8502-3cd6-727f291199f5 ...
Build 'openstack' finished.

==> Builds finished. The artifacts of successful builds are:
--> openstack: An image was created: 0983f994-6de4-4894-8fd1-4f700c2dc644

Do you got any idea what causes this? Am I overseeing something?
Best Regards

@SwampDragons
Copy link
Contributor

The openstack builder turns out to have two different options, source_image and source_image_name: https://www.packer.io/docs/builders/openstack.html#source_image_name

Try changing the var name and seeing if this works for you.

This is an unwieldy behavior, and should probably be changed so one field works for both options. I'm not sure when I'll have a chance to look into implementing this, but I'd definitely accept a PR that did this, to make the configuration less confusing.

@v0lumehi
Copy link
Author

Okay, thanks for your reply. I will try that out.
I'd really like to create a PR but I don't know how to write go code unfortunately. I think someone else has to do it.

@v0lumehi
Copy link
Author

I've just tried it out with this config:

"builders": [{
    "type": "openstack",
    "flavor": "m.xxlarge",
    "image_name": "jenkins-chef-slave-nightly",
    "source_image_name": "ubuntu-18.04-x86_64-latest",
    "ssh_username": "ubuntu",
    "identity_endpoint": "https://my.great.cloud:5000/v3",
    "networks": ["6e80f6c6-3a24-44be-b15c-54b1f9d86c6e"],
    "floating_ip_network": "6541b7d0-db72-4a17-9d7e-de5d5b894ead",
    "security_groups": ["97e99840-e6f0-4fff-8f67-2afd3b8a3c43"],
    "metadata": {
      "image_name": "jenkins-chef-slave-nightly"
    }
  }]

and it works.

I am wondering why using the image name as value with the "source_image" key and "use_block_storage_device" = true is working and when removing "use_block_storage_device" it is not. "use_block_storage_device" seems to cause some weird things. I am unable to write custom metadata using the "metadata" key when "use_block_storage_device" is set to true too.

@nywilken nywilken added the community-supported-plugin denotes requests for plugins that are supported by the community, not by HashiCorp engineers label Nov 18, 2020
@ghost
Copy link

ghost commented Apr 21, 2021

This issue has been automatically migrated to hashicorp/packer-plugin-openstack#14 because it looks like an issue with that plugin. If you believe this is not an issue with the plugin, please reply to hashicorp/packer-plugin-openstack#14.

@ghost ghost closed this as completed Apr 21, 2021
@ghost
Copy link

ghost commented May 22, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators May 22, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
builder/openstack community-supported-plugin denotes requests for plugins that are supported by the community, not by HashiCorp engineers question remote-plugin/openstack
Projects
None yet
Development

No branches or pull requests

4 participants