You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aurora.apache.org by Poppy <po...@gmail.com> on 2015/01/08 10:59:34 UTC

Getting INVALID_REQUEST for createJob api

I am using createJob api  to create a job but not able to create a job,
getting the following. someone please let me know the correct json
message": "Job configuration does not have instanceCount set."
My aurora schedule running at -> http://myserver.com:8081/apibeta/createJob
Using - Post
Content-Type -> application/json
Json used ->
BODY <http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3>

{
  "description": {
    "instanceCount" : 1,
    "key": {
      "role": "root",
      "environment": "test",
      "name": "abc_1"
    },
    "owner": {
      "role": "root",
      "user": "root"
    },
    "cronSchedule": null,
    "cronCollisionPolicy":"KILL_EXISTING",
    "taskConfig": {
      "owner": {
        "role": "root",
        "user": "root"
      },
      "environment": "test",
      "jobName": "abc_1",
      "isService": true,
      "numCpus": 0.2,
      "ramMb": 1000,
      "diskMb": 1000,
      "priority": 0,
      "maxTaskFailures": 1,
      "production": false,
      "constraints": [],
      "requestedPorts": [],
      "taskLinks": {},
      "contactEmail" : "prdhir@ebay.com",
      "executorConfig": {
        "name": "AuroraExecutor",
        "data": "{\"priority\": 0, \"health_check_config\":
{\"initial_interval_secs\": 15.0, \"interval_secs\": 10.0,
\"timeout_secs\": 1.0, \"max_consecutive_failures\": 0}, \"name\":
\"abc_1\", \"environment\": \"test\", \"max_task_failures\": 1,
\"task\": {\"processes\": [{\"daemon\": false, \"name\":
\"fetch_package\", \"ephemeral\": false, \"max_failures\": 1,
\"min_duration\": 5, \"cmdline\": \"cp
/ci-master-home/ciapi/jenkins-master-config-scripts/create_ci.bash .
\u0026\u0026 chmod +x create_ci.bash\", \"final\": false},
{\"daemon\": false, \"name\": \"jenkins_world\", \"ephemeral\": false,
\"max_failures\": 1, \"min_duration\": 5, \"cmdline\": \"bash
create_ci.bash start abc_1 qa\", \"final\": false}], \"name\":
\"fetch_package\", \"finalization_wait\": 30, \"max_failures\": 1,
\"max_concurrency\": 0, \"resources\": {\"disk\": 1048576000, \"ram\":
1048576000, \"cpu\": 0.2}, \"constraints\": [{\"order\":
[\"fetch_package\", \"jenkins_world\"]}]}, \"enable_hooks\": false,
\"cluster\": \"ciaas\", \"production\": false, \"role\": \"root\"}"
      },
      "metadata": []
    }
  },
  "session": {
    "mechanism": "UNAUTHENTICATED",
    "data": "YW55IGNhcm5hbCBwbGVhcw"
  },
  "lock":null
}


200 OK <http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1>
{
"responseCode": "INVALID_REQUEST",
"messageDEPRECATED": "Job configuration does not have instanceCount set.",
"DEPRECATEDversion":{
"major": 3
},
"serverInfo":{
"clusterName": "ciaas",
"thriftAPIVersion": 3,
"statsUrlPrefix": ""
},
"details":[
{
"message": "Job configuration does not have instanceCount set."
}
]
}

Re: Getting INVALID_REQUEST for createJob api

Posted by Bill Farner <wf...@apache.org>.
Unfortunately this is a known wart in /apibeta, and a symptom of why it
will never graduate from beta in the current form.

The details behind why you see this is that we use Gson to deserialize
JSON, which does not support to the JavaBean convention, using getter and
setter methods.  Thrift, on the other hand, requires use of setter methods
for the __isset_bitfield to be toggled:

(generated thrift code)
  public JobConfiguration setInstanceCount(int instanceCount) {
    this.instanceCount = instanceCount;
    setInstanceCountIsSet(true);
    return this;
  }

Thrift tries to encapsulate this such that the value and the notion of "is
this field set" are coupled, but Gson bypasses that with reflection.
Setting the bit field is important because thrift uses it to decide whether
an field needs to be serialized when we go to put it in storage.

When first putting together /apibeta, i also explored Jackson to sidestep
around these issues, since it can support the JavaBean convention.
Unfortunately, i ran into a wall there as well when deserializing thrift
TUnion objects [1].  If i recall correctly, the Jackson API did not provide
sufficient type information to handle TUnion, but i will be happily proven
wrong.

What this means for you is that /apibeta is really only useful as a
read-only interface.  AURORA-987 [1] tracks defining a true usable API.

[1]
https://github.com/apache/incubator-aurora/blob/b4fea865cce341df22e9eb099798391ca57291bb/src/main/java/org/apache/aurora/scheduler/http/api/GsonMessageBodyHandler.java#L196-L235
[2] https://issues.apache.org/jira/browse/AURORA-987


-=Bill

On Thu, Jan 8, 2015 at 1:59 AM, Poppy <po...@gmail.com> wrote:

> I am using createJob api  to create a job but not able to create a job,
> getting the following. someone please let me know the correct json
> message": "Job configuration does not have instanceCount set."
> My aurora schedule running at ->
> http://myserver.com:8081/apibeta/createJob
> Using - Post
> Content-Type -> application/json
> Json used ->
> BODY <http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3>
>
> {
>   "description": {
>     "instanceCount" : 1,
>     "key": {
>       "role": "root",
>       "environment": "test",
>       "name": "abc_1"
>     },
>     "owner": {
>       "role": "root",
>       "user": "root"
>     },
>     "cronSchedule": null,
>     "cronCollisionPolicy":"KILL_EXISTING",
>     "taskConfig": {
>       "owner": {
>         "role": "root",
>         "user": "root"
>       },
>       "environment": "test",
>       "jobName": "abc_1",
>       "isService": true,
>       "numCpus": 0.2,
>       "ramMb": 1000,
>       "diskMb": 1000,
>       "priority": 0,
>       "maxTaskFailures": 1,
>       "production": false,
>       "constraints": [],
>       "requestedPorts": [],
>       "taskLinks": {},
>       "contactEmail" : "prdhir@ebay.com",
>       "executorConfig": {
>         "name": "AuroraExecutor",
>         "data": "{\"priority\": 0, \"health_check_config\":
> {\"initial_interval_secs\": 15.0, \"interval_secs\": 10.0,
> \"timeout_secs\": 1.0, \"max_consecutive_failures\": 0}, \"name\":
> \"abc_1\", \"environment\": \"test\", \"max_task_failures\": 1,
> \"task\": {\"processes\": [{\"daemon\": false, \"name\":
> \"fetch_package\", \"ephemeral\": false, \"max_failures\": 1,
> \"min_duration\": 5, \"cmdline\": \"cp
> /ci-master-home/ciapi/jenkins-master-config-scripts/create_ci.bash .
> \u0026\u0026 chmod +x create_ci.bash\", \"final\": false},
> {\"daemon\": false, \"name\": \"jenkins_world\", \"ephemeral\": false,
> \"max_failures\": 1, \"min_duration\": 5, \"cmdline\": \"bash
> create_ci.bash start abc_1 qa\", \"final\": false}], \"name\":
> \"fetch_package\", \"finalization_wait\": 30, \"max_failures\": 1,
> \"max_concurrency\": 0, \"resources\": {\"disk\": 1048576000, \"ram\":
> 1048576000, \"cpu\": 0.2}, \"constraints\": [{\"order\":
> [\"fetch_package\", \"jenkins_world\"]}]}, \"enable_hooks\": false,
> \"cluster\": \"ciaas\", \"production\": false, \"role\": \"root\"}"
>       },
>       "metadata": []
>     }
>   },
>   "session": {
>     "mechanism": "UNAUTHENTICATED",
>     "data": "YW55IGNhcm5hbCBwbGVhcw"
>   },
>   "lock":null
> }
>
>
> 200 OK <http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1>
> {
> "responseCode": "INVALID_REQUEST",
> "messageDEPRECATED": "Job configuration does not have instanceCount set.",
> "DEPRECATEDversion":{
> "major": 3
> },
> "serverInfo":{
> "clusterName": "ciaas",
> "thriftAPIVersion": 3,
> "statsUrlPrefix": ""
> },
> "details":[
> {
> "message": "Job configuration does not have instanceCount set."
> }
> ]
> }
>