ionos-cloud / ionosctl

The IONOS Cloud CLI (ionosctl) gives the ability to manage IONOS Cloud infrastructure directly from Command Line.
Apache License 2.0
28 stars 6 forks source link

Unable to create a volume with a backup plan (leads to internal server error) #356

Open mrndev opened 1 year ago

mrndev commented 1 year ago

Description

Creating a volume with backup plan fails

ionosctl volume create \
--ssh-key-paths /home/mnylund/.ssh/id_rsa.pub \
--user-data I2Nsb3VkLWNvbmZpZwoKaG9zdG5hbWU6IEJhY2t1cHRlc3QKCg== \
--datacenter-id 5d24749d-02ee-4d0d-9f87-caa0b6afa11b \
--name Backuptest \
--image-alias ubuntu:22.04 \
--type 'SSD Premium' \
--size 80GB \
--password XXXXX \
--backupunit-id 9d0cecc0-eb02-4e83-8ce9-b1aece8321d2 -w

leads to

Error: 500 Internal Server Error {
  "httpStatus" : 500,
  "messages" : [ {
    "errorCode" : "301",
    "message" : "Oops! Something went very wrong. Please contact the administrator"
  } ]

The backup unit does exist

ionosctl backupunit list
BackupUnitId                           Name                  Email                     State
9d0cecc0-eb02-4e83-8ce9-b1aece8321d2   BackupTestServerTmp   xxemailxx   AVAILABLE

am I missing something? The same command works ok without the backup plan option.

Expected behavior

A volume is created with the backup

Environment

ionosctl --version ionosctl version v6.6.8

How to Reproduce

Use command above. If you leave out the --backupunit-id , the command succeeds

avirtopeanu-ionos commented 1 year ago

I can get the error too, % i volume create --datacenter-id <ID> --backupunit-id <ID>

running with IONOS_LOG_LEVEL=trace shows that request is sent as

{"properties":{"availabilityZone":"AUTO","backupunitId":"<ID>","bus":"VIRTIO","licenceType":"LINUX","name":"Unnamed Volume","size":10,"type":"HDD"}}

I'm in the process of working out if this request is malformed or not, but looking at API docs I don't see the problem - in any case the API shouldn't return a 500

mrndev commented 1 year ago

here is the trace if it helps

+ IONOS_LOG_LEVEL=trace
+ ionosctl volume create --ssh-key-paths /home/mnylund/.ssh/id_rsa.pub --user-data I2Nsb3VkLWNvbmZpZwoKaG9zdG5hbWU6IEJhY2t1cHRlc3QKCg== --datacenter-id 5d24749d-02ee-4d0d-9f87-caa0b6afa11b --name Backuptest --image-alias ubuntu:22.04 --type 'SSD Premium' --size 80GB --password XXXX--backupunit-id 9d0cecc0-eb02-4e83-8ce9-b1aece8321d2 -w
IONOSLOG 2023/09/05 08:36:28  DumpRequestOut : POST /cloudapi/v6/datacenters/5d24749d-02ee-4d0d-9f87-caa0b6afa11b/volumes?depth=0&pretty=true HTTP/1.1
Host: api.ionos.com
User-Agent: ionosctl/v6.6.8_ionos-cloud-sdk-go/v6.1.8
Content-Length: 853
Accept: application/json
Authorization:XXXX
Content-Type: application/json
Accept-Encoding: gzip

{"properties":{"availabilityZone":"AUTO","backupunitId":"9d0cecc0-eb02-4e83-8ce9-b1aece8321d2","bus":"VIRTIO","imageAlias":"ubuntu:22.04","imagePassword":"XXXX","name":"Backuptest","size":80,"sshKeys":["ssh-rsa xxxxxxx"],"type":"SSD Premium","userData":"I2Nsb3VkLWNvbmZpZwoKaG9zdG5hbWU6IEJhY2t1cHRlc3QKCg=="}}

IONOSLOG 2023/09/05 08:36:28
 try no: 1
IONOSLOG 2023/09/05 08:36:28
 DumpResponse : HTTP/2.0 500 Internal Server Error
Content-Length: 160
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: *
Access-Control-Allow-Methods: *
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: *
Content-Type: application/json
Date: Tue, 05 Sep 2023 08:36:28 GMT
Server: nginx
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Origin
X-Frame-Options: SAMEORIGIN

{
  "httpStatus" : 500,
  "messages" : [ {
    "errorCode" : "301",
    "message" : "Oops! Something went very wrong. Please contact the administrator"
  } ]
}

Error: 500 Internal Server Error {
  "httpStatus" : 500,
  "messages" : [ {
    "errorCode" : "301",
    "message" : "Oops! Something went very wrong. Please contact the administrator"
  } ]
}
avirtopeanu-ionos commented 1 year ago

hi, I could create a volume if providing an image-id to a HDD image in same location as the datacenter, and password: i volume create --datacenter-id <...> --backupunit-id <...> --image-id e84aed99-feba-11ed-86e8-2e7f0689c849 --password <...>

looks like a missed validation check both in ionosctl and in the API-side

mrndev commented 1 year ago

Yes confirmed, using image-id instead of image-alias. But workaround at its best :)