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

can't list applications with /v1/projects/${id}/applications #11

Open
jshimko opened this issue Sep 18, 2017 · 4 comments
Open

can't list applications with /v1/projects/${id}/applications #11

jshimko opened this issue Sep 18, 2017 · 4 comments

Comments

@jshimko
Copy link

jshimko commented Sep 18, 2017

I have a project, namespace, cluster, etc. and a single application running. I can query for the single application and successfully get it, but I can't list applications in that same namespace.

# GET the single app

curl http://localhost:8080/v1/projects/77907b06/applications/bb7dd432

{
  "channel": "stable",
  "config": "",
  "created_at": "2017-09-18T13:35:53.981897503Z",
  "deployment_name": "jeremy-mongodb",
  "id": "bb7dd432",
  "json_values": "",
  "name": "mongodb-replicaset",
  "namespace_id": "02678191",
  "registry": "quay.io/samsung_cnct",
  "server": "quay.io",
  "status": {
    "deployed_at": "2017-09-18T13:35:57.832285003Z",
    "state": "DEPLOYED"
  },
  "type": "application",
  "updated_at": "2017-09-18T13:35:57.832285386Z",
  "username": "",
  "version": "latest"
}
# GET all apps in that same namespace

curl http://localhost:8080/v1/projects/77907b06/applications \
     -H "Content-Type: application/json" \
     -d '{ "namespaceid": "02678191" }'


{
  "id": "9PjU+W/E",
  "code": "invalid_request",
  "status": 400,
  "detail": "missing required payload"
}

Yes, I realize my body has namespaceid instead of namespace_id, but that’s what the spec says. Regardless, I tried both ways and got the same result.

swagger_editor

Just to show you that the namespace definitely exists...

curl http://localhost:8080/v1/projects/77907b06/namespaces/02678191

{
  "applications": [
    {
      "oid": "bb7dd432",
      "url": "/v1/projects/77907b06/applications/bb7dd432"
    }
  ],
  "created_at": "2017-09-11T21:49:32.759664083Z",
  "id": "02678191",
  "name": "jeremy",
  "resources": {
    "oid": "e322aa1c",
    "url": "/v1/projects/77907b06/cluster/e322aa1c"
  },
  "type": "namespace"
}
@sostheim
Copy link
Owner

So, I think this is just a peculiarity of curl and the order of arguments on the command line. I was able to reproduce this by putting the header and body arguments after the URL.

Reproduced Failure:

$ curl http://localhost:8080/v1/projects/6f6c206e/applications -H "Content-Type: application/json" -d'{"namespaceid":"fc0c6a6b"}' 
{
	"id": "rFzsPcwX",
	"code": "bad_request",
	"status": 400,
	"detail": "[WSUhRC52] 400 invalid_request: attribute \"name\" of response is missing and required; attribute \"namespace_id\" of response is missing and required, attribute: namespace_id, parent: response"
}

Only change is to add a -XGET parameter after the URL.

Working:

$ curl http://localhost:8080/v1/projects/6f6c206e/applications -XGET -H "Content-Type: application/json" -d'{"namespaceid":"fc0c6a6b"}' 
[{
	"channel": "stable",
	"config": "",
	"created_at": "2017-09-18T22:32:31.325098155-07:00",
	"deployment_name": "illinois-urbana-mongodb",
	"id": "7412131c",
	"json_values": "",
	"name": "mongodb-replicaset",
	"namespace_id": "fc0c6a6b",
	"registry": "samsung_cnct",
	"server": "quay.io",
	"status": {
		"deployed_at": "2017-09-18T22:32:31.325669159-07:00",
		"state": "DEPLOYED"
	},
	"type": "application",
	"updated_at": "2017-09-18T22:32:31.325669175-07:00",
	"username": "",
	"version": "latest"
}]

@sostheim
Copy link
Owner

@jshimko - will leave this open until tomorrow so you have a chance to verify.

@jshimko jshimko closed this as completed Sep 19, 2017
@jshimko
Copy link
Author

jshimko commented Sep 19, 2017

So I guess I'm not exactly sure it this isn't a bug though, because I don't have the same issue with any other API I've just tested (5 different ones). Even doing a GET for a single item on krak8s allows you to have that same header and not use -X GET, so at the very least it's inconsistent.

curl http://localhost:8080/v1/projects/77907b06/applications/bb7dd432 \
     -H "Content-Type: application/json"

{
  "channel": "stable",
  "config": "",
  "created_at": "2017-09-18T13:35:53.981897503Z",
  "deployment_name": "jeremy-mongodb",
  "id": "bb7dd432",
  "json_values": "",
  "name": "mongodb-replicaset",
  "namespace_id": "02678191",
  "registry": "quay.io/samsung_cnct",
  "server": "quay.io",
  "status": {
    "deployed_at": "0001-01-01T00:00:00Z",
    "state": "UNKNOWN"
  },
  "type": "application",
  "updated_at": "2017-09-18T13:35:53.981897503Z",
  "username": "",
  "version": "latest"
}

Anyway, if the API is going to choke on something like this, you may want to add some more useful error handling there. Because the error detail it spit out is completely incorrect. That's not actually what caused the error.

{
  "id": "rFzsPcwX",
  "code": "bad_request",
  "status": 400,
  "detail": "[WSUhRC52] 400 invalid_request: attribute \"name\" of response is missing and required; attribute \"namespace_id\" of response is missing and required, attribute: namespace_id, parent: response"
}

@sostheim
Copy link
Owner

Consideration for future enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants