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

gsclient-go seem not to follow 301 redirects from the api #183

Open
KervyN opened this issue Feb 15, 2021 · 1 comment
Open

gsclient-go seem not to follow 301 redirects from the api #183

KervyN opened this issue Feb 15, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@KervyN
Copy link

KervyN commented Feb 15, 2021

Hi, I was debugging an Issue with my code that turned out, I've missed the https protocol in the endpoint.

This

func main() {
	token := "XXXXXXXXXXXXXXXXXXXXXX"
	user := "ZZZZZZZZZZZZZZZZZZZZZZZZ"
	endpoint := "http://api.gridscale.io"
	emptyCtx := context.Background()

	// config := gsclient.DefaultConfiguration(user, token)
	config := gsclient.NewConfiguration(endpoint, user, token, true, true, 1000, 5)
	client := gsclient.NewClient(config)

	// err := apiAlive(token, user, endpoint, client)
	serverCreateRequest := gsclient.ServerCreateRequest{
		Name:   "api-tests",
		Memory: 1,
		Cores:  2,
	}
	cServer, err := client.CreateServer(emptyCtx, serverCreateRequest)
	if err != nil {
		panic(err)
	}


	fmt.Printf("%v", cServer)
	if err != nil {
		panic(err)
	}
}

results in

DEBU[2021-02-15T14:47:58+01:00] Preparing POST request sent to URL: http://api.gridscale.io/objects/servers
DEBU[2021-02-15T14:47:58+01:00] Request body: {{"name":"api-tests","memory":1,"cores":2}
}
DEBU[2021-02-15T14:47:58+01:00] Request headers: map[Content-Type:[application/json] User-Agent:[gsclient-go/3.3.2 (darwin)] X-Auth-Token:[XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX] X-Auth-Userid:[XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]]
DEBU[2021-02-15T14:48:00+01:00] Status code: 200. Request UUID: 6e99e9a2-8c19-45d8-a416-c21e550f751d. Headers: map[Access-Control-Allow-Credentials:[true] Access-Control-Allow-Headers:[Origin, X-Requested-With, Content-Type, Accept, X-Auth-UserId, X-Auth-Token, X-Exec-Time, X-API-Version, X-Api-Client, X-API-Identity, X-Auth-ContractId] Access-Control-Allow-Methods:[GET, POST, PUT, PATCH, DELETE, OPTIONS] Access-Control-Allow-Origin:[*] Access-Control-Expose-Headers:[X-Exec-Time, X-API-Version, X-Request-Id, X-API-Identity] Cache-Control:[no-cache] Content-Length:[3708] Content-Type:[application/json] Date:[Mon, 15 Feb 2021 13:48:00 GMT] Etag:["W/e315f3cacb4e7a3a538f7a85dcb5d46f0f245264"] Ratelimit-Limit:[210] Ratelimit-Remaining:[208] Ratelimit-Reset:[1613396894217] X-Api-Identity:[2] X-Request-Id:[6e99e9a2-8c19-45d8-a416-c21e550f751d] X-Time-Provisioning:[0.547547]]
DEBU[2021-02-15T14:48:00+01:00] Response body: {"servers": {"28c1371a-cb47-498c-b852-cadbecbfda89": {"console_token": "e36965689121ac9a80aaaa8f1069edee5df7b5a9cfbaded9c5b9fe9714e9b90e1fe1d45b3923b2d7f217009e532e6bf2", "labels": [], "create_time": "2021-02-01T09:08:18Z", "change_time": "2021-02-01T09:15:14Z", "location_uuid": "45ed677b-3702-4b36-be2a-a2eab9827950", "name": "4dx-dashboard", "hardware_profile": "q35", "availability_zone": null, "memory": 2, "auto_recovery": true, "location_iata": "fra", "cores": 1, "power": true, "location_name": "de/fra", "object_uuid": "28c1371a-cb47-498c-b852-cadbecbfda89", "location_country": "de", "legacy": false, "status": "active", "relations": {"storages": [{"bus": 0, "controller": 0, "create_time": "2021-02-01T09:08:18Z", "target": 0, "bootdevice": true, "last_used_template": "fd65f8ce-e2c6-40af-8fc3-92efa0d4eecb", "lun": 0, "storage_type": "storage", "object_uuid": "79f10e8b-33b2-4973-99ce-40aa20747734", "object_name": "4dx-dashboard", "capacity": 10, "license_product_no": null}], "networks": [{"vxlan": null, "create_time": "2021-02-01T09:08:18Z", "ordering": 0, "public_net": true, "network_uuid": "23e0345d-4313-4307-b7b9-9eb666dfac43", "firewall_template_uuid": null, "bootdevice": false, "vlan": null, "l3security": [], "network_type": "network", "firewall": null, "mac": "16:40:87:d7:f8:01", "mcast": null, "object_uuid": "23e0345d-4313-4307-b7b9-9eb666dfac43", "l2security": true, "partner_uuid": "95a2980b-7012-43dd-81f2-07577cfcb9f0", "object_name": "Public Network"}], "public_ips": [{"create_time": "2021-02-01T09:08:18Z", "object_uuid": "cb47368e-723d-4b06-ac00-3967151a4fcd", "ip": "2a06:2380:0:1::4bb", "family": 6, "prefix": "2a06:2380:0:1::4bb/128"}, {"create_time": "2021-02-01T09:08:18Z", "object_uuid": "c10af4e6-4855-45cb-a56a-93ea7df51d84", "ip": "45.12.51.119", "family": 4, "prefix": "45.12.51.119/32"}], "isoimages": []}, "current_price": 99.99, "usage_in_minutes_cores": 20432, "usage_in_minutes_memory": 40864}, "e3e89eb2-963a-4f73-8090-ca5c97b74941": {"console_token": "5c8f74843e29917b3bf6d7bfe33d99f1d85360fe123062dca9c809ccfa33fe36f4ffc6bf28f714315234399babb74176", "labels": [], "create_time": "2021-01-08T23:24:30Z", "change_time": "2021-02-15T13:47:37Z", "location_uuid": "45ed677b-3702-4b36-be2a-a2eab9827950", "name": "gs-test", "hardware_profile": "q35", "availability_zone": null, "memory": 2, "auto_recovery": true, "location_iata": "fra", "cores": 1, "power": true, "location_name": "de/fra", "object_uuid": "e3e89eb2-963a-4f73-8090-ca5c97b74941", "location_country": "de", "legacy": false, "status": "active", "relations": {"storages": [{"bus": 0, "controller": 0, "create_time": "2021-01-08T23:24:30Z", "target": 0, "bootdevice": true, "last_used_template": "fd65f8ce-e2c6-40af-8fc3-92efa0d4eecb", "lun": 0, "storage_type": "storage_insane", "object_uuid": "6f826003-b32b-46ab-adc0-cccdf4698fa6", "object_name": "gs-test", "capacity": 10, "license_product_no": null}], "networks": [{"vxlan": null, "create_time": "2021-01-08T23:24:30Z", "ordering": 0, "public_net": true, "network_uuid": "23e0345d-4313-4307-b7b9-9eb666dfac43", "firewall_template_uuid": null, "bootdevice": false, "vlan": null, "l3security": [], "network_type": "network", "firewall": null, "mac": "22:cc:c9:3d:52:01", "mcast": null, "object_uuid": "23e0345d-4313-4307-b7b9-9eb666dfac43", "l2security": true, "partner_uuid": "95a2980b-7012-43dd-81f2-07577cfcb9f0", "object_name": "Public Network"}], "public_ips": [{"create_time": "2021-01-08T23:24:30Z", "object_uuid": "d0485231-935c-4ad6-9890-0010e4b35a2e", "ip": "185.201.144.29", "family": 4, "prefix": "185.201.144.29/32"}], "isoimages": []}, "current_price": 99.99, "usage_in_minutes_cores": 54140, "usage_in_minutes_memory": 108280}}}
DEBU[2021-02-15T14:48:01+01:00] Preparing GET request sent to URL: http://api.gridscale.io/requests/6e99e9a2-8c19-45d8-a416-c21e550f751d
DEBU[2021-02-15T14:48:01+01:00] Request body: {}
DEBU[2021-02-15T14:48:01+01:00] Request headers: map[Content-Type:[application/json] User-Agent:[gsclient-go/3.3.2 (darwin)] X-Auth-Token:[XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX] X-Auth-Userid:[XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]]
DEBU[2021-02-15T14:48:02+01:00] Status code: 404. Request UUID: b9f05ddd-e0bf-4e86-9121-6a657bfb9f15. Headers: map[Access-Control-Allow-Credentials:[true] Access-Control-Allow-Headers:[Origin, X-Requested-With, Content-Type, Accept, X-Auth-UserId, X-Auth-Token, X-Exec-Time, X-API-Version, X-Api-Client, X-API-Identity, X-Auth-ContractId] Access-Control-Allow-Methods:[GET, POST, PUT, PATCH, DELETE, OPTIONS] Access-Control-Allow-Origin:[*] Access-Control-Expose-Headers:[X-Exec-Time, X-API-Version, X-Request-Id, X-API-Identity] Cache-Control:[no-cache] Content-Length:[154] Content-Type:[application/json] Date:[Mon, 15 Feb 2021 13:48:03 GMT] Etag:["W/502812e75a4eec35693a6554365702233177fd4f"] Ratelimit-Limit:[210] Ratelimit-Remaining:[207] Ratelimit-Reset:[1613396894217] Vary:[Accept] X-Api-Identity:[2] X-Request-Id:[b9f05ddd-e0bf-4e86-9121-6a657bfb9f15]]
ERRO[2021-02-15T14:48:02+01:00] Error message: {'type': 'HTTPError', 'status_code': 404, 'message': "(404, 'There is no Request for the given Request UUID.')"}. Title: 404 Code. Code: 404. Request UUID: b9f05ddd-e0bf-4e86-9121-6a657bfb9f15.
panic: Status code: 404. Error: {'type': 'HTTPError', 'status_code': 404, 'message': "(404, 'There is no Request for the given Request UUID.')"}. Request UUID: b9f05ddd-e0bf-4e86-9121-6a657bfb9f15.
@nvthongswansea nvthongswansea self-assigned this Feb 15, 2021
@bkircher bkircher added the bug Something isn't working label Feb 18, 2021
@bkircher bkircher added this to the v3.4.1 milestone Feb 18, 2021
@bkircher bkircher removed this from the v3.4.1 milestone Mar 9, 2021
@bkircher
Copy link
Contributor

What's the status here? We decided that backend needs to just allow https scheme URLs or properly redirect. No issue with this library? Or do we need to do something here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants