You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Rakesh Venkatesh <ww...@gmail.com> on 2019/08/08 08:39:51 UTC

Querying async job result

Hello


I want to know what is the best way to query the async job result using
queryAsyncJobResult api. According to the documentation in
http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html
,
the "jobstatus" of 1 means the command completed but im facing an issue
where even though the command is still running, the "jobstatus" is always 1.

Im running "prepareHostForMaintenance" command which returns the jobid.
When I run queryAsyncJobResult for this jobid, the jobstatus will always be
1 even though the hypervisor is still not in maintenance mode.

So can anyone tell me what is the best way to check if the hypervisor is in
maintenance mode or not? Im using 4.11 version


Below are the result which I get


"resourcestate": "PrepareForMaintenance",
"jobresultcode": 0,
  "jobresulttype": "object",
  "jobstatus": 1,

-- 
Thanks and regards
Rakesh venkatesh

Re: Querying async job result

Posted by Anurag Awasthi <An...@shapeblue.com>.
You can also configure event bus (Kafka perhaps) and use that to get events.

Alternately you can also use below API -

(local) 🐵 > list events type="MAINT.PREPARE" listall=true
{
  "count": 6,
  "event": [
    {
      "account": "system",
      "created": "2019-08-08T17:06:23+0530",
      "description": "completed maintenance for host 1",
      "domain": "ROOT",
      "domainid": "712762c6-b2b0-11e9-831d-34e12d5f623e",
      "id": "41c27f1b-ecbf-4e77-8489-6aaaaa5d0456",
      "level": "INFO",
      "state": "Completed",
      "type": "MAINT.PREPARE",
      "username": "system"
    },
    {
      "account": "admin",
      "created": "2019-08-08T17:03:47+0530",
      "description": "preparing host: 1 for maintenance",
      "domain": "ROOT",
      "domainid": "712762c6-b2b0-11e9-831d-34e12d5f623e",
      "id": "8d70cf65-f0ba-4b4c-95de-13612e925cfc",
      "level": "INFO",
      "state": "Scheduled",
      "type": "MAINT.PREPARE",
      "username": "admin"
    },
    {
      "account": "admin",
      "created": "2019-08-08T17:03:47+0530",
      "description": "starting maintenance for host 1",
      "domain": "ROOT",
      "domainid": "712762c6-b2b0-11e9-831d-34e12d5f623e",
      "id": "3e305f6f-d91f-47d3-be74-bcc37c1d6995",
      "level": "INFO",
      "state": "Started",
      "type": "MAINT.PREPARE",
      "username": "admin"
    },
    {
...

The part in red with completed state is published when maintenance mode is completed. Ofcourse filter for the host id you want to track.

Regards,
Anurag

________________________________
From: Rakesh v <ww...@gmail.com>
Sent: Thursday, August 8, 2019 4:31 PM
To: users@cloudstack.apache.org <us...@cloudstack.apache.org>
Cc: dev@cloudstack.apache.org <de...@cloudstack.apache.org>
Subject: Re: Querying async job result

So then I guess the correct way to check if host is in maintenance is through querying DB.

Sent from my iPhone


Anurag.Awasthi@shapeblue.com 
www.shapeblue.com
Amadeus House, Floral Street, London  WC2E 9DPUK
@shapeblue
  
 

> On 08-Aug-2019, at 12:03 PM, Anurag Awasthi <An...@shapeblue.com> wrote:
>
> Hi Rakesh,
>
> Andrija is correct. Internally, all the API call does is move the host to a different state. Periodically (ping.interval duration apart) MS would attempt migration of VMs. Once the host has zero running VMs and no VM in failure/error state it would be marked in maintenance mode.
>
> Regarding your 2nd question - how to track if maintenance state, one option is that you query DB to see the state. The other option could be to see on event bus for "MAINT.PREPARE" in completed state. I haven't seen this in practice but perhaps you can dig in a bit to explore.
>
> Regards,
> Anurag
>
> On 8/8/19, 3:17 PM, "Andrija Panic" <an...@gmail.com> wrote:
>
>    Rakesh,
>
>    I'm not quite sure if this is a bug/misbehaviour, but it is indeed a
>    confusing one.
>
>    When you ask a host to go to maintenance mode, , you are using
>    prepareHostForMaintenance as you said, and this will trigger the host to go
>    into the "PrepareForMaintenance" state... so the job does indeed completes
>    within 2-3sec usually, as you can actually see in the GUI, after a 2-3 secs
>    of spinning circle and confirmation that it has been done.
>
>    Now, after the host has reached the PrepareForMaintenance state, ACS will
>    migrate away VMs, and I can only assume that the mgmt server will mark it
>    as in "Maintenance" state once it has zero VMs.
>    So you can query for the status of the host for the "resourcestate" and
>    observe when it goes into "Maintenance" state.
>
>    Regards
>    Andrija
>
>
> Anurag.Awasthi@shapeblue.com
> www.shapeblue.com<http://www.shapeblue.com>
> Amadeus House, Floral Street, London  WC2E 9DPUK
> @shapeblue
>
>
>
>> On Thu, 8 Aug 2019 at 11:18, Rakesh v <ww...@gmail.com>> wrote:
>>
>> Hello Anurag
>>
>>
>> Thanks for the reply. The host does transit to  maintenance mode
>> eventually but the asynchronous job status never changes. Right now I'm
>> periodically fetching the resource_state from DB to see if it changes to
>> "Maintenance". Is there any better way to do it like using triggers or
>> events instead of periodic polling?
>>
>> Sent from my iPhone
>>
>>> On 08-Aug-2019, at 10:52 AM, Anurag Awasthi <
>> Anurag.Awasthi@shapeblue.com> wrote:
>>>
>>> Hi Rakesh,
>>>
>>> You seem to be doing the right thing. I think what you have encoutered
>> is a bug in prepareForMaintenance API. The host tends to be stuck in that
>> state in some scenarios. Perhaps, when a VM enters an error state. I would
>> advise canceling maintenance mode and examining what states the VMs are in.
>> Ensure there are no unexpected errors on VMs, clean them up manually if
>> needed. Then retry prepare for maintenance mode.
>>>
>>> There is an open PR for fixing this issue as well -
>> https://github.com/apache/cloudstack/pull/3425 . While this got
>> sidetracked as we worked on 4.13.0, this will make it in 4.13.1.
>>>
>>> Kind Regards,
>>> Anurag
>>> ________________________________
>>> From: Rakesh Venkatesh <ww...@gmail.com>>
>>> Sent: Thursday, August 8, 2019 2:09 PM
>>> To: users@cloudstack.apache.org <us...@cloudstack.apache.org>;
>> dev@cloudstack.apache.org <de...@cloudstack.apache.org>
>>> Subject: Querying async job result
>>>
>>> Hello
>>>
>>>
>>> I want to know what is the best way to query the async job result using
>>> queryAsyncJobResult api. According to the documentation in
>>>
>> http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html
>>> ,
>>> the "jobstatus" of 1 means the command completed but im facing an issue
>>> where even though the command is still running, the "jobstatus" is
>> always 1.
>>>
>>> Im running "prepareHostForMaintenance" command which returns the jobid.
>>> When I run queryAsyncJobResult for this jobid, the jobstatus will always
>> be
>>> 1 even though the hypervisor is still not in maintenance mode.
>>>
>>> So can anyone tell me what is the best way to check if the hypervisor is
>> in
>>> maintenance mode or not? Im using 4.11 version
>>>
>>>
>>> Below are the result which I get
>>>
>>>
>>> "resourcestate": "PrepareForMaintenance",
>>> "jobresultcode": 0,
>>> "jobresulttype": "object",
>>> "jobstatus": 1,
>>>
>>> --
>>> Thanks and regards
>>> Rakesh venkatesh
>>>
>>> Anurag.Awasthi@shapeblue.com
>>> www.shapeblue.com<http://www.shapeblue.com>
>>> Amadeus House, Floral Street, London  WC2E 9DPUK
>>> @shapeblue
>>>
>>>
>>>
>>
>
>
>    --
>
>    Andrija Panić
>
>

Re: Querying async job result

Posted by Yiping Zhang <yi...@adobe.com>.
No,  you don't need to query DB directly.  Just make api calls to check host's resource state.

Here is a snippet in my script using cloudmonkey:

             host_state=`$monkey list hosts name=$host filter=resourcestate | grep "resourcestate" | awk '{print $3}'`

Yiping

On 8/8/19, 4:01 AM, "Rakesh v" <ww...@gmail.com> wrote:

    So then I guess the correct way to check if host is in maintenance is through querying DB.
    
    Sent from my iPhone
    
    > On 08-Aug-2019, at 12:03 PM, Anurag Awasthi <An...@shapeblue.com> wrote:
    > 
    > Hi Rakesh,
    > 
    > Andrija is correct. Internally, all the API call does is move the host to a different state. Periodically (ping.interval duration apart) MS would attempt migration of VMs. Once the host has zero running VMs and no VM in failure/error state it would be marked in maintenance mode. 
    > 
    > Regarding your 2nd question - how to track if maintenance state, one option is that you query DB to see the state. The other option could be to see on event bus for "MAINT.PREPARE" in completed state. I haven't seen this in practice but perhaps you can dig in a bit to explore.
    > 
    > Regards,
    > Anurag
    > 
    > On 8/8/19, 3:17 PM, "Andrija Panic" <an...@gmail.com> wrote:
    > 
    >    Rakesh,
    > 
    >    I'm not quite sure if this is a bug/misbehaviour, but it is indeed a
    >    confusing one.
    > 
    >    When you ask a host to go to maintenance mode, , you are using
    >    prepareHostForMaintenance as you said, and this will trigger the host to go
    >    into the "PrepareForMaintenance" state... so the job does indeed completes
    >    within 2-3sec usually, as you can actually see in the GUI, after a 2-3 secs
    >    of spinning circle and confirmation that it has been done.
    > 
    >    Now, after the host has reached the PrepareForMaintenance state, ACS will
    >    migrate away VMs, and I can only assume that the mgmt server will mark it
    >    as in "Maintenance" state once it has zero VMs.
    >    So you can query for the status of the host for the "resourcestate" and
    >    observe when it goes into "Maintenance" state.
    > 
    >    Regards
    >    Andrija
    > 
    > 
    > Anurag.Awasthi@shapeblue.com 
    > https://nam04.safelinks.protection.outlook.com/?url=www.shapeblue.com&amp;data=02%7C01%7Cyipzhang%40adobe.com%7Cd4b30e95d0244e30eab008d71befbe86%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637008588817384705&amp;sdata=TEae3WrtCF2KmocR6ND1v4%2BCDV8UPfx8FabGoZrxSt0%3D&amp;reserved=0
    > Amadeus House, Floral Street, London  WC2E 9DPUK
    > @shapeblue
    > 
    > 
    > 
    >> On Thu, 8 Aug 2019 at 11:18, Rakesh v <ww...@gmail.com> wrote:
    >> 
    >> Hello Anurag
    >> 
    >> 
    >> Thanks for the reply. The host does transit to  maintenance mode
    >> eventually but the asynchronous job status never changes. Right now I'm
    >> periodically fetching the resource_state from DB to see if it changes to
    >> "Maintenance". Is there any better way to do it like using triggers or
    >> events instead of periodic polling?
    >> 
    >> Sent from my iPhone
    >> 
    >>> On 08-Aug-2019, at 10:52 AM, Anurag Awasthi <
    >> Anurag.Awasthi@shapeblue.com> wrote:
    >>> 
    >>> Hi Rakesh,
    >>> 
    >>> You seem to be doing the right thing. I think what you have encoutered
    >> is a bug in prepareForMaintenance API. The host tends to be stuck in that
    >> state in some scenarios. Perhaps, when a VM enters an error state. I would
    >> advise canceling maintenance mode and examining what states the VMs are in.
    >> Ensure there are no unexpected errors on VMs, clean them up manually if
    >> needed. Then retry prepare for maintenance mode.
    >>> 
    >>> There is an open PR for fixing this issue as well -
    >> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fapache%2Fcloudstack%2Fpull%2F3425&amp;data=02%7C01%7Cyipzhang%40adobe.com%7Cd4b30e95d0244e30eab008d71befbe86%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637008588817384705&amp;sdata=Gt5cfJeEZuoO5QCf5PtzGex8cjzeL%2B4WxWVkPl44S9w%3D&amp;reserved=0 . While this got
    >> sidetracked as we worked on 4.13.0, this will make it in 4.13.1.
    >>> 
    >>> Kind Regards,
    >>> Anurag
    >>> ________________________________
    >>> From: Rakesh Venkatesh <ww...@gmail.com>
    >>> Sent: Thursday, August 8, 2019 2:09 PM
    >>> To: users@cloudstack.apache.org <us...@cloudstack.apache.org>;
    >> dev@cloudstack.apache.org <de...@cloudstack.apache.org>
    >>> Subject: Querying async job result
    >>> 
    >>> Hello
    >>> 
    >>> 
    >>> I want to know what is the best way to query the async job result using
    >>> queryAsyncJobResult api. According to the documentation in
    >>> 
    >> https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdocs.cloudstack.apache.org%2Fprojects%2Farchived-cloudstack-getting-started%2Fen%2Flatest%2Fdev.html&amp;data=02%7C01%7Cyipzhang%40adobe.com%7Cd4b30e95d0244e30eab008d71befbe86%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637008588817384705&amp;sdata=7lf3OH94muFLiMXdTUi%2Bo%2FOOpBhyeBS4vXUoqOk%2F1WI%3D&amp;reserved=0
    >>> ,
    >>> the "jobstatus" of 1 means the command completed but im facing an issue
    >>> where even though the command is still running, the "jobstatus" is
    >> always 1.
    >>> 
    >>> Im running "prepareHostForMaintenance" command which returns the jobid.
    >>> When I run queryAsyncJobResult for this jobid, the jobstatus will always
    >> be
    >>> 1 even though the hypervisor is still not in maintenance mode.
    >>> 
    >>> So can anyone tell me what is the best way to check if the hypervisor is
    >> in
    >>> maintenance mode or not? Im using 4.11 version
    >>> 
    >>> 
    >>> Below are the result which I get
    >>> 
    >>> 
    >>> "resourcestate": "PrepareForMaintenance",
    >>> "jobresultcode": 0,
    >>> "jobresulttype": "object",
    >>> "jobstatus": 1,
    >>> 
    >>> --
    >>> Thanks and regards
    >>> Rakesh venkatesh
    >>> 
    >>> Anurag.Awasthi@shapeblue.com
    >>> https://nam04.safelinks.protection.outlook.com/?url=www.shapeblue.com&amp;data=02%7C01%7Cyipzhang%40adobe.com%7Cd4b30e95d0244e30eab008d71befbe86%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637008588817384705&amp;sdata=TEae3WrtCF2KmocR6ND1v4%2BCDV8UPfx8FabGoZrxSt0%3D&amp;reserved=0
    >>> Amadeus House, Floral Street, London  WC2E 9DPUK
    >>> @shapeblue
    >>> 
    >>> 
    >>> 
    >> 
    > 
    > 
    >    -- 
    > 
    >    Andrija Panić
    > 
    > 
    


Re: Querying async job result

Posted by Anurag Awasthi <An...@shapeblue.com>.
You can also configure event bus (Kafka perhaps) and use that to get events.

Alternately you can also use below API -

(local) 🐵 > list events type="MAINT.PREPARE" listall=true
{
  "count": 6,
  "event": [
    {
      "account": "system",
      "created": "2019-08-08T17:06:23+0530",
      "description": "completed maintenance for host 1",
      "domain": "ROOT",
      "domainid": "712762c6-b2b0-11e9-831d-34e12d5f623e",
      "id": "41c27f1b-ecbf-4e77-8489-6aaaaa5d0456",
      "level": "INFO",
      "state": "Completed",
      "type": "MAINT.PREPARE",
      "username": "system"
    },
    {
      "account": "admin",
      "created": "2019-08-08T17:03:47+0530",
      "description": "preparing host: 1 for maintenance",
      "domain": "ROOT",
      "domainid": "712762c6-b2b0-11e9-831d-34e12d5f623e",
      "id": "8d70cf65-f0ba-4b4c-95de-13612e925cfc",
      "level": "INFO",
      "state": "Scheduled",
      "type": "MAINT.PREPARE",
      "username": "admin"
    },
    {
      "account": "admin",
      "created": "2019-08-08T17:03:47+0530",
      "description": "starting maintenance for host 1",
      "domain": "ROOT",
      "domainid": "712762c6-b2b0-11e9-831d-34e12d5f623e",
      "id": "3e305f6f-d91f-47d3-be74-bcc37c1d6995",
      "level": "INFO",
      "state": "Started",
      "type": "MAINT.PREPARE",
      "username": "admin"
    },
    {
...

The part in red with completed state is published when maintenance mode is completed. Ofcourse filter for the host id you want to track.

Regards,
Anurag

________________________________
From: Rakesh v <ww...@gmail.com>
Sent: Thursday, August 8, 2019 4:31 PM
To: users@cloudstack.apache.org <us...@cloudstack.apache.org>
Cc: dev@cloudstack.apache.org <de...@cloudstack.apache.org>
Subject: Re: Querying async job result

So then I guess the correct way to check if host is in maintenance is through querying DB.

Sent from my iPhone


Anurag.Awasthi@shapeblue.com 
www.shapeblue.com
Amadeus House, Floral Street, London  WC2E 9DPUK
@shapeblue
  
 

> On 08-Aug-2019, at 12:03 PM, Anurag Awasthi <An...@shapeblue.com> wrote:
>
> Hi Rakesh,
>
> Andrija is correct. Internally, all the API call does is move the host to a different state. Periodically (ping.interval duration apart) MS would attempt migration of VMs. Once the host has zero running VMs and no VM in failure/error state it would be marked in maintenance mode.
>
> Regarding your 2nd question - how to track if maintenance state, one option is that you query DB to see the state. The other option could be to see on event bus for "MAINT.PREPARE" in completed state. I haven't seen this in practice but perhaps you can dig in a bit to explore.
>
> Regards,
> Anurag
>
> On 8/8/19, 3:17 PM, "Andrija Panic" <an...@gmail.com> wrote:
>
>    Rakesh,
>
>    I'm not quite sure if this is a bug/misbehaviour, but it is indeed a
>    confusing one.
>
>    When you ask a host to go to maintenance mode, , you are using
>    prepareHostForMaintenance as you said, and this will trigger the host to go
>    into the "PrepareForMaintenance" state... so the job does indeed completes
>    within 2-3sec usually, as you can actually see in the GUI, after a 2-3 secs
>    of spinning circle and confirmation that it has been done.
>
>    Now, after the host has reached the PrepareForMaintenance state, ACS will
>    migrate away VMs, and I can only assume that the mgmt server will mark it
>    as in "Maintenance" state once it has zero VMs.
>    So you can query for the status of the host for the "resourcestate" and
>    observe when it goes into "Maintenance" state.
>
>    Regards
>    Andrija
>
>
> Anurag.Awasthi@shapeblue.com
> www.shapeblue.com<http://www.shapeblue.com>
> Amadeus House, Floral Street, London  WC2E 9DPUK
> @shapeblue
>
>
>
>> On Thu, 8 Aug 2019 at 11:18, Rakesh v <ww...@gmail.com>> wrote:
>>
>> Hello Anurag
>>
>>
>> Thanks for the reply. The host does transit to  maintenance mode
>> eventually but the asynchronous job status never changes. Right now I'm
>> periodically fetching the resource_state from DB to see if it changes to
>> "Maintenance". Is there any better way to do it like using triggers or
>> events instead of periodic polling?
>>
>> Sent from my iPhone
>>
>>> On 08-Aug-2019, at 10:52 AM, Anurag Awasthi <
>> Anurag.Awasthi@shapeblue.com> wrote:
>>>
>>> Hi Rakesh,
>>>
>>> You seem to be doing the right thing. I think what you have encoutered
>> is a bug in prepareForMaintenance API. The host tends to be stuck in that
>> state in some scenarios. Perhaps, when a VM enters an error state. I would
>> advise canceling maintenance mode and examining what states the VMs are in.
>> Ensure there are no unexpected errors on VMs, clean them up manually if
>> needed. Then retry prepare for maintenance mode.
>>>
>>> There is an open PR for fixing this issue as well -
>> https://github.com/apache/cloudstack/pull/3425 . While this got
>> sidetracked as we worked on 4.13.0, this will make it in 4.13.1.
>>>
>>> Kind Regards,
>>> Anurag
>>> ________________________________
>>> From: Rakesh Venkatesh <ww...@gmail.com>>
>>> Sent: Thursday, August 8, 2019 2:09 PM
>>> To: users@cloudstack.apache.org <us...@cloudstack.apache.org>;
>> dev@cloudstack.apache.org <de...@cloudstack.apache.org>
>>> Subject: Querying async job result
>>>
>>> Hello
>>>
>>>
>>> I want to know what is the best way to query the async job result using
>>> queryAsyncJobResult api. According to the documentation in
>>>
>> http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html
>>> ,
>>> the "jobstatus" of 1 means the command completed but im facing an issue
>>> where even though the command is still running, the "jobstatus" is
>> always 1.
>>>
>>> Im running "prepareHostForMaintenance" command which returns the jobid.
>>> When I run queryAsyncJobResult for this jobid, the jobstatus will always
>> be
>>> 1 even though the hypervisor is still not in maintenance mode.
>>>
>>> So can anyone tell me what is the best way to check if the hypervisor is
>> in
>>> maintenance mode or not? Im using 4.11 version
>>>
>>>
>>> Below are the result which I get
>>>
>>>
>>> "resourcestate": "PrepareForMaintenance",
>>> "jobresultcode": 0,
>>> "jobresulttype": "object",
>>> "jobstatus": 1,
>>>
>>> --
>>> Thanks and regards
>>> Rakesh venkatesh
>>>
>>> Anurag.Awasthi@shapeblue.com
>>> www.shapeblue.com<http://www.shapeblue.com>
>>> Amadeus House, Floral Street, London  WC2E 9DPUK
>>> @shapeblue
>>>
>>>
>>>
>>
>
>
>    --
>
>    Andrija Panić
>
>

Re: Querying async job result

Posted by Rakesh v <ww...@gmail.com>.
So then I guess the correct way to check if host is in maintenance is through querying DB.

Sent from my iPhone

> On 08-Aug-2019, at 12:03 PM, Anurag Awasthi <An...@shapeblue.com> wrote:
> 
> Hi Rakesh,
> 
> Andrija is correct. Internally, all the API call does is move the host to a different state. Periodically (ping.interval duration apart) MS would attempt migration of VMs. Once the host has zero running VMs and no VM in failure/error state it would be marked in maintenance mode. 
> 
> Regarding your 2nd question - how to track if maintenance state, one option is that you query DB to see the state. The other option could be to see on event bus for "MAINT.PREPARE" in completed state. I haven't seen this in practice but perhaps you can dig in a bit to explore.
> 
> Regards,
> Anurag
> 
> On 8/8/19, 3:17 PM, "Andrija Panic" <an...@gmail.com> wrote:
> 
>    Rakesh,
> 
>    I'm not quite sure if this is a bug/misbehaviour, but it is indeed a
>    confusing one.
> 
>    When you ask a host to go to maintenance mode, , you are using
>    prepareHostForMaintenance as you said, and this will trigger the host to go
>    into the "PrepareForMaintenance" state... so the job does indeed completes
>    within 2-3sec usually, as you can actually see in the GUI, after a 2-3 secs
>    of spinning circle and confirmation that it has been done.
> 
>    Now, after the host has reached the PrepareForMaintenance state, ACS will
>    migrate away VMs, and I can only assume that the mgmt server will mark it
>    as in "Maintenance" state once it has zero VMs.
>    So you can query for the status of the host for the "resourcestate" and
>    observe when it goes into "Maintenance" state.
> 
>    Regards
>    Andrija
> 
> 
> Anurag.Awasthi@shapeblue.com 
> www.shapeblue.com
> Amadeus House, Floral Street, London  WC2E 9DPUK
> @shapeblue
> 
> 
> 
>> On Thu, 8 Aug 2019 at 11:18, Rakesh v <ww...@gmail.com> wrote:
>> 
>> Hello Anurag
>> 
>> 
>> Thanks for the reply. The host does transit to  maintenance mode
>> eventually but the asynchronous job status never changes. Right now I'm
>> periodically fetching the resource_state from DB to see if it changes to
>> "Maintenance". Is there any better way to do it like using triggers or
>> events instead of periodic polling?
>> 
>> Sent from my iPhone
>> 
>>> On 08-Aug-2019, at 10:52 AM, Anurag Awasthi <
>> Anurag.Awasthi@shapeblue.com> wrote:
>>> 
>>> Hi Rakesh,
>>> 
>>> You seem to be doing the right thing. I think what you have encoutered
>> is a bug in prepareForMaintenance API. The host tends to be stuck in that
>> state in some scenarios. Perhaps, when a VM enters an error state. I would
>> advise canceling maintenance mode and examining what states the VMs are in.
>> Ensure there are no unexpected errors on VMs, clean them up manually if
>> needed. Then retry prepare for maintenance mode.
>>> 
>>> There is an open PR for fixing this issue as well -
>> https://github.com/apache/cloudstack/pull/3425 . While this got
>> sidetracked as we worked on 4.13.0, this will make it in 4.13.1.
>>> 
>>> Kind Regards,
>>> Anurag
>>> ________________________________
>>> From: Rakesh Venkatesh <ww...@gmail.com>
>>> Sent: Thursday, August 8, 2019 2:09 PM
>>> To: users@cloudstack.apache.org <us...@cloudstack.apache.org>;
>> dev@cloudstack.apache.org <de...@cloudstack.apache.org>
>>> Subject: Querying async job result
>>> 
>>> Hello
>>> 
>>> 
>>> I want to know what is the best way to query the async job result using
>>> queryAsyncJobResult api. According to the documentation in
>>> 
>> http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html
>>> ,
>>> the "jobstatus" of 1 means the command completed but im facing an issue
>>> where even though the command is still running, the "jobstatus" is
>> always 1.
>>> 
>>> Im running "prepareHostForMaintenance" command which returns the jobid.
>>> When I run queryAsyncJobResult for this jobid, the jobstatus will always
>> be
>>> 1 even though the hypervisor is still not in maintenance mode.
>>> 
>>> So can anyone tell me what is the best way to check if the hypervisor is
>> in
>>> maintenance mode or not? Im using 4.11 version
>>> 
>>> 
>>> Below are the result which I get
>>> 
>>> 
>>> "resourcestate": "PrepareForMaintenance",
>>> "jobresultcode": 0,
>>> "jobresulttype": "object",
>>> "jobstatus": 1,
>>> 
>>> --
>>> Thanks and regards
>>> Rakesh venkatesh
>>> 
>>> Anurag.Awasthi@shapeblue.com
>>> www.shapeblue.com
>>> Amadeus House, Floral Street, London  WC2E 9DPUK
>>> @shapeblue
>>> 
>>> 
>>> 
>> 
> 
> 
>    -- 
> 
>    Andrija Panić
> 
> 

Re: Querying async job result

Posted by Rakesh v <ww...@gmail.com>.
So then I guess the correct way to check if host is in maintenance is through querying DB.

Sent from my iPhone

> On 08-Aug-2019, at 12:03 PM, Anurag Awasthi <An...@shapeblue.com> wrote:
> 
> Hi Rakesh,
> 
> Andrija is correct. Internally, all the API call does is move the host to a different state. Periodically (ping.interval duration apart) MS would attempt migration of VMs. Once the host has zero running VMs and no VM in failure/error state it would be marked in maintenance mode. 
> 
> Regarding your 2nd question - how to track if maintenance state, one option is that you query DB to see the state. The other option could be to see on event bus for "MAINT.PREPARE" in completed state. I haven't seen this in practice but perhaps you can dig in a bit to explore.
> 
> Regards,
> Anurag
> 
> On 8/8/19, 3:17 PM, "Andrija Panic" <an...@gmail.com> wrote:
> 
>    Rakesh,
> 
>    I'm not quite sure if this is a bug/misbehaviour, but it is indeed a
>    confusing one.
> 
>    When you ask a host to go to maintenance mode, , you are using
>    prepareHostForMaintenance as you said, and this will trigger the host to go
>    into the "PrepareForMaintenance" state... so the job does indeed completes
>    within 2-3sec usually, as you can actually see in the GUI, after a 2-3 secs
>    of spinning circle and confirmation that it has been done.
> 
>    Now, after the host has reached the PrepareForMaintenance state, ACS will
>    migrate away VMs, and I can only assume that the mgmt server will mark it
>    as in "Maintenance" state once it has zero VMs.
>    So you can query for the status of the host for the "resourcestate" and
>    observe when it goes into "Maintenance" state.
> 
>    Regards
>    Andrija
> 
> 
> Anurag.Awasthi@shapeblue.com 
> www.shapeblue.com
> Amadeus House, Floral Street, London  WC2E 9DPUK
> @shapeblue
> 
> 
> 
>> On Thu, 8 Aug 2019 at 11:18, Rakesh v <ww...@gmail.com> wrote:
>> 
>> Hello Anurag
>> 
>> 
>> Thanks for the reply. The host does transit to  maintenance mode
>> eventually but the asynchronous job status never changes. Right now I'm
>> periodically fetching the resource_state from DB to see if it changes to
>> "Maintenance". Is there any better way to do it like using triggers or
>> events instead of periodic polling?
>> 
>> Sent from my iPhone
>> 
>>> On 08-Aug-2019, at 10:52 AM, Anurag Awasthi <
>> Anurag.Awasthi@shapeblue.com> wrote:
>>> 
>>> Hi Rakesh,
>>> 
>>> You seem to be doing the right thing. I think what you have encoutered
>> is a bug in prepareForMaintenance API. The host tends to be stuck in that
>> state in some scenarios. Perhaps, when a VM enters an error state. I would
>> advise canceling maintenance mode and examining what states the VMs are in.
>> Ensure there are no unexpected errors on VMs, clean them up manually if
>> needed. Then retry prepare for maintenance mode.
>>> 
>>> There is an open PR for fixing this issue as well -
>> https://github.com/apache/cloudstack/pull/3425 . While this got
>> sidetracked as we worked on 4.13.0, this will make it in 4.13.1.
>>> 
>>> Kind Regards,
>>> Anurag
>>> ________________________________
>>> From: Rakesh Venkatesh <ww...@gmail.com>
>>> Sent: Thursday, August 8, 2019 2:09 PM
>>> To: users@cloudstack.apache.org <us...@cloudstack.apache.org>;
>> dev@cloudstack.apache.org <de...@cloudstack.apache.org>
>>> Subject: Querying async job result
>>> 
>>> Hello
>>> 
>>> 
>>> I want to know what is the best way to query the async job result using
>>> queryAsyncJobResult api. According to the documentation in
>>> 
>> http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html
>>> ,
>>> the "jobstatus" of 1 means the command completed but im facing an issue
>>> where even though the command is still running, the "jobstatus" is
>> always 1.
>>> 
>>> Im running "prepareHostForMaintenance" command which returns the jobid.
>>> When I run queryAsyncJobResult for this jobid, the jobstatus will always
>> be
>>> 1 even though the hypervisor is still not in maintenance mode.
>>> 
>>> So can anyone tell me what is the best way to check if the hypervisor is
>> in
>>> maintenance mode or not? Im using 4.11 version
>>> 
>>> 
>>> Below are the result which I get
>>> 
>>> 
>>> "resourcestate": "PrepareForMaintenance",
>>> "jobresultcode": 0,
>>> "jobresulttype": "object",
>>> "jobstatus": 1,
>>> 
>>> --
>>> Thanks and regards
>>> Rakesh venkatesh
>>> 
>>> Anurag.Awasthi@shapeblue.com
>>> www.shapeblue.com
>>> Amadeus House, Floral Street, London  WC2E 9DPUK
>>> @shapeblue
>>> 
>>> 
>>> 
>> 
> 
> 
>    -- 
> 
>    Andrija Panić
> 
> 

Re: Querying async job result

Posted by Anurag Awasthi <An...@shapeblue.com>.
Hi Rakesh,

Andrija is correct. Internally, all the API call does is move the host to a different state. Periodically (ping.interval duration apart) MS would attempt migration of VMs. Once the host has zero running VMs and no VM in failure/error state it would be marked in maintenance mode. 

Regarding your 2nd question - how to track if maintenance state, one option is that you query DB to see the state. The other option could be to see on event bus for "MAINT.PREPARE" in completed state. I haven't seen this in practice but perhaps you can dig in a bit to explore.

Regards,
Anurag

On 8/8/19, 3:17 PM, "Andrija Panic" <an...@gmail.com> wrote:

    Rakesh,
    
    I'm not quite sure if this is a bug/misbehaviour, but it is indeed a
    confusing one.
    
    When you ask a host to go to maintenance mode, , you are using
    prepareHostForMaintenance as you said, and this will trigger the host to go
    into the "PrepareForMaintenance" state... so the job does indeed completes
    within 2-3sec usually, as you can actually see in the GUI, after a 2-3 secs
    of spinning circle and confirmation that it has been done.
    
    Now, after the host has reached the PrepareForMaintenance state, ACS will
    migrate away VMs, and I can only assume that the mgmt server will mark it
    as in "Maintenance" state once it has zero VMs.
    So you can query for the status of the host for the "resourcestate" and
    observe when it goes into "Maintenance" state.
    
    Regards
    Andrija
    
    
Anurag.Awasthi@shapeblue.com 
www.shapeblue.com
Amadeus House, Floral Street, London  WC2E 9DPUK
@shapeblue
  
 

On Thu, 8 Aug 2019 at 11:18, Rakesh v <ww...@gmail.com> wrote:
    
    > Hello Anurag
    >
    >
    > Thanks for the reply. The host does transit to  maintenance mode
    > eventually but the asynchronous job status never changes. Right now I'm
    > periodically fetching the resource_state from DB to see if it changes to
    > "Maintenance". Is there any better way to do it like using triggers or
    > events instead of periodic polling?
    >
    > Sent from my iPhone
    >
    > > On 08-Aug-2019, at 10:52 AM, Anurag Awasthi <
    > Anurag.Awasthi@shapeblue.com> wrote:
    > >
    > > Hi Rakesh,
    > >
    > > You seem to be doing the right thing. I think what you have encoutered
    > is a bug in prepareForMaintenance API. The host tends to be stuck in that
    > state in some scenarios. Perhaps, when a VM enters an error state. I would
    > advise canceling maintenance mode and examining what states the VMs are in.
    > Ensure there are no unexpected errors on VMs, clean them up manually if
    > needed. Then retry prepare for maintenance mode.
    > >
    > > There is an open PR for fixing this issue as well -
    > https://github.com/apache/cloudstack/pull/3425 . While this got
    > sidetracked as we worked on 4.13.0, this will make it in 4.13.1.
    > >
    > > Kind Regards,
    > > Anurag
    > > ________________________________
    > > From: Rakesh Venkatesh <ww...@gmail.com>
    > > Sent: Thursday, August 8, 2019 2:09 PM
    > > To: users@cloudstack.apache.org <us...@cloudstack.apache.org>;
    > dev@cloudstack.apache.org <de...@cloudstack.apache.org>
    > > Subject: Querying async job result
    > >
    > > Hello
    > >
    > >
    > > I want to know what is the best way to query the async job result using
    > > queryAsyncJobResult api. According to the documentation in
    > >
    > http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html
    > > ,
    > > the "jobstatus" of 1 means the command completed but im facing an issue
    > > where even though the command is still running, the "jobstatus" is
    > always 1.
    > >
    > > Im running "prepareHostForMaintenance" command which returns the jobid.
    > > When I run queryAsyncJobResult for this jobid, the jobstatus will always
    > be
    > > 1 even though the hypervisor is still not in maintenance mode.
    > >
    > > So can anyone tell me what is the best way to check if the hypervisor is
    > in
    > > maintenance mode or not? Im using 4.11 version
    > >
    > >
    > > Below are the result which I get
    > >
    > >
    > > "resourcestate": "PrepareForMaintenance",
    > > "jobresultcode": 0,
    > >  "jobresulttype": "object",
    > >  "jobstatus": 1,
    > >
    > > --
    > > Thanks and regards
    > > Rakesh venkatesh
    > >
    > > Anurag.Awasthi@shapeblue.com
    > > www.shapeblue.com
    > > Amadeus House, Floral Street, London  WC2E 9DPUK
    > > @shapeblue
    > >
    > >
    > >
    >
    
    
    -- 
    
    Andrija Panić
    


Re: Querying async job result

Posted by Anurag Awasthi <An...@shapeblue.com>.
Hi Rakesh,

Andrija is correct. Internally, all the API call does is move the host to a different state. Periodically (ping.interval duration apart) MS would attempt migration of VMs. Once the host has zero running VMs and no VM in failure/error state it would be marked in maintenance mode. 

Regarding your 2nd question - how to track if maintenance state, one option is that you query DB to see the state. The other option could be to see on event bus for "MAINT.PREPARE" in completed state. I haven't seen this in practice but perhaps you can dig in a bit to explore.

Regards,
Anurag

On 8/8/19, 3:17 PM, "Andrija Panic" <an...@gmail.com> wrote:

    Rakesh,
    
    I'm not quite sure if this is a bug/misbehaviour, but it is indeed a
    confusing one.
    
    When you ask a host to go to maintenance mode, , you are using
    prepareHostForMaintenance as you said, and this will trigger the host to go
    into the "PrepareForMaintenance" state... so the job does indeed completes
    within 2-3sec usually, as you can actually see in the GUI, after a 2-3 secs
    of spinning circle and confirmation that it has been done.
    
    Now, after the host has reached the PrepareForMaintenance state, ACS will
    migrate away VMs, and I can only assume that the mgmt server will mark it
    as in "Maintenance" state once it has zero VMs.
    So you can query for the status of the host for the "resourcestate" and
    observe when it goes into "Maintenance" state.
    
    Regards
    Andrija
    
    
Anurag.Awasthi@shapeblue.com 
www.shapeblue.com
Amadeus House, Floral Street, London  WC2E 9DPUK
@shapeblue
  
 

On Thu, 8 Aug 2019 at 11:18, Rakesh v <ww...@gmail.com> wrote:
    
    > Hello Anurag
    >
    >
    > Thanks for the reply. The host does transit to  maintenance mode
    > eventually but the asynchronous job status never changes. Right now I'm
    > periodically fetching the resource_state from DB to see if it changes to
    > "Maintenance". Is there any better way to do it like using triggers or
    > events instead of periodic polling?
    >
    > Sent from my iPhone
    >
    > > On 08-Aug-2019, at 10:52 AM, Anurag Awasthi <
    > Anurag.Awasthi@shapeblue.com> wrote:
    > >
    > > Hi Rakesh,
    > >
    > > You seem to be doing the right thing. I think what you have encoutered
    > is a bug in prepareForMaintenance API. The host tends to be stuck in that
    > state in some scenarios. Perhaps, when a VM enters an error state. I would
    > advise canceling maintenance mode and examining what states the VMs are in.
    > Ensure there are no unexpected errors on VMs, clean them up manually if
    > needed. Then retry prepare for maintenance mode.
    > >
    > > There is an open PR for fixing this issue as well -
    > https://github.com/apache/cloudstack/pull/3425 . While this got
    > sidetracked as we worked on 4.13.0, this will make it in 4.13.1.
    > >
    > > Kind Regards,
    > > Anurag
    > > ________________________________
    > > From: Rakesh Venkatesh <ww...@gmail.com>
    > > Sent: Thursday, August 8, 2019 2:09 PM
    > > To: users@cloudstack.apache.org <us...@cloudstack.apache.org>;
    > dev@cloudstack.apache.org <de...@cloudstack.apache.org>
    > > Subject: Querying async job result
    > >
    > > Hello
    > >
    > >
    > > I want to know what is the best way to query the async job result using
    > > queryAsyncJobResult api. According to the documentation in
    > >
    > http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html
    > > ,
    > > the "jobstatus" of 1 means the command completed but im facing an issue
    > > where even though the command is still running, the "jobstatus" is
    > always 1.
    > >
    > > Im running "prepareHostForMaintenance" command which returns the jobid.
    > > When I run queryAsyncJobResult for this jobid, the jobstatus will always
    > be
    > > 1 even though the hypervisor is still not in maintenance mode.
    > >
    > > So can anyone tell me what is the best way to check if the hypervisor is
    > in
    > > maintenance mode or not? Im using 4.11 version
    > >
    > >
    > > Below are the result which I get
    > >
    > >
    > > "resourcestate": "PrepareForMaintenance",
    > > "jobresultcode": 0,
    > >  "jobresulttype": "object",
    > >  "jobstatus": 1,
    > >
    > > --
    > > Thanks and regards
    > > Rakesh venkatesh
    > >
    > > Anurag.Awasthi@shapeblue.com
    > > www.shapeblue.com
    > > Amadeus House, Floral Street, London  WC2E 9DPUK
    > > @shapeblue
    > >
    > >
    > >
    >
    
    
    -- 
    
    Andrija Panić
    


Re: Querying async job result

Posted by Andrija Panic <an...@gmail.com>.
Rakesh,

I'm not quite sure if this is a bug/misbehaviour, but it is indeed a
confusing one.

When you ask a host to go to maintenance mode, , you are using
prepareHostForMaintenance as you said, and this will trigger the host to go
into the "PrepareForMaintenance" state... so the job does indeed completes
within 2-3sec usually, as you can actually see in the GUI, after a 2-3 secs
of spinning circle and confirmation that it has been done.

Now, after the host has reached the PrepareForMaintenance state, ACS will
migrate away VMs, and I can only assume that the mgmt server will mark it
as in "Maintenance" state once it has zero VMs.
So you can query for the status of the host for the "resourcestate" and
observe when it goes into "Maintenance" state.

Regards
Andrija

On Thu, 8 Aug 2019 at 11:18, Rakesh v <ww...@gmail.com> wrote:

> Hello Anurag
>
>
> Thanks for the reply. The host does transit to  maintenance mode
> eventually but the asynchronous job status never changes. Right now I'm
> periodically fetching the resource_state from DB to see if it changes to
> "Maintenance". Is there any better way to do it like using triggers or
> events instead of periodic polling?
>
> Sent from my iPhone
>
> > On 08-Aug-2019, at 10:52 AM, Anurag Awasthi <
> Anurag.Awasthi@shapeblue.com> wrote:
> >
> > Hi Rakesh,
> >
> > You seem to be doing the right thing. I think what you have encoutered
> is a bug in prepareForMaintenance API. The host tends to be stuck in that
> state in some scenarios. Perhaps, when a VM enters an error state. I would
> advise canceling maintenance mode and examining what states the VMs are in.
> Ensure there are no unexpected errors on VMs, clean them up manually if
> needed. Then retry prepare for maintenance mode.
> >
> > There is an open PR for fixing this issue as well -
> https://github.com/apache/cloudstack/pull/3425 . While this got
> sidetracked as we worked on 4.13.0, this will make it in 4.13.1.
> >
> > Kind Regards,
> > Anurag
> > ________________________________
> > From: Rakesh Venkatesh <ww...@gmail.com>
> > Sent: Thursday, August 8, 2019 2:09 PM
> > To: users@cloudstack.apache.org <us...@cloudstack.apache.org>;
> dev@cloudstack.apache.org <de...@cloudstack.apache.org>
> > Subject: Querying async job result
> >
> > Hello
> >
> >
> > I want to know what is the best way to query the async job result using
> > queryAsyncJobResult api. According to the documentation in
> >
> http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html
> > ,
> > the "jobstatus" of 1 means the command completed but im facing an issue
> > where even though the command is still running, the "jobstatus" is
> always 1.
> >
> > Im running "prepareHostForMaintenance" command which returns the jobid.
> > When I run queryAsyncJobResult for this jobid, the jobstatus will always
> be
> > 1 even though the hypervisor is still not in maintenance mode.
> >
> > So can anyone tell me what is the best way to check if the hypervisor is
> in
> > maintenance mode or not? Im using 4.11 version
> >
> >
> > Below are the result which I get
> >
> >
> > "resourcestate": "PrepareForMaintenance",
> > "jobresultcode": 0,
> >  "jobresulttype": "object",
> >  "jobstatus": 1,
> >
> > --
> > Thanks and regards
> > Rakesh venkatesh
> >
> > Anurag.Awasthi@shapeblue.com
> > www.shapeblue.com
> > Amadeus House, Floral Street, London  WC2E 9DPUK
> > @shapeblue
> >
> >
> >
>


-- 

Andrija Panić

Re: Querying async job result

Posted by Andrija Panic <an...@gmail.com>.
Rakesh,

I'm not quite sure if this is a bug/misbehaviour, but it is indeed a
confusing one.

When you ask a host to go to maintenance mode, , you are using
prepareHostForMaintenance as you said, and this will trigger the host to go
into the "PrepareForMaintenance" state... so the job does indeed completes
within 2-3sec usually, as you can actually see in the GUI, after a 2-3 secs
of spinning circle and confirmation that it has been done.

Now, after the host has reached the PrepareForMaintenance state, ACS will
migrate away VMs, and I can only assume that the mgmt server will mark it
as in "Maintenance" state once it has zero VMs.
So you can query for the status of the host for the "resourcestate" and
observe when it goes into "Maintenance" state.

Regards
Andrija

On Thu, 8 Aug 2019 at 11:18, Rakesh v <ww...@gmail.com> wrote:

> Hello Anurag
>
>
> Thanks for the reply. The host does transit to  maintenance mode
> eventually but the asynchronous job status never changes. Right now I'm
> periodically fetching the resource_state from DB to see if it changes to
> "Maintenance". Is there any better way to do it like using triggers or
> events instead of periodic polling?
>
> Sent from my iPhone
>
> > On 08-Aug-2019, at 10:52 AM, Anurag Awasthi <
> Anurag.Awasthi@shapeblue.com> wrote:
> >
> > Hi Rakesh,
> >
> > You seem to be doing the right thing. I think what you have encoutered
> is a bug in prepareForMaintenance API. The host tends to be stuck in that
> state in some scenarios. Perhaps, when a VM enters an error state. I would
> advise canceling maintenance mode and examining what states the VMs are in.
> Ensure there are no unexpected errors on VMs, clean them up manually if
> needed. Then retry prepare for maintenance mode.
> >
> > There is an open PR for fixing this issue as well -
> https://github.com/apache/cloudstack/pull/3425 . While this got
> sidetracked as we worked on 4.13.0, this will make it in 4.13.1.
> >
> > Kind Regards,
> > Anurag
> > ________________________________
> > From: Rakesh Venkatesh <ww...@gmail.com>
> > Sent: Thursday, August 8, 2019 2:09 PM
> > To: users@cloudstack.apache.org <us...@cloudstack.apache.org>;
> dev@cloudstack.apache.org <de...@cloudstack.apache.org>
> > Subject: Querying async job result
> >
> > Hello
> >
> >
> > I want to know what is the best way to query the async job result using
> > queryAsyncJobResult api. According to the documentation in
> >
> http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html
> > ,
> > the "jobstatus" of 1 means the command completed but im facing an issue
> > where even though the command is still running, the "jobstatus" is
> always 1.
> >
> > Im running "prepareHostForMaintenance" command which returns the jobid.
> > When I run queryAsyncJobResult for this jobid, the jobstatus will always
> be
> > 1 even though the hypervisor is still not in maintenance mode.
> >
> > So can anyone tell me what is the best way to check if the hypervisor is
> in
> > maintenance mode or not? Im using 4.11 version
> >
> >
> > Below are the result which I get
> >
> >
> > "resourcestate": "PrepareForMaintenance",
> > "jobresultcode": 0,
> >  "jobresulttype": "object",
> >  "jobstatus": 1,
> >
> > --
> > Thanks and regards
> > Rakesh venkatesh
> >
> > Anurag.Awasthi@shapeblue.com
> > www.shapeblue.com
> > Amadeus House, Floral Street, London  WC2E 9DPUK
> > @shapeblue
> >
> >
> >
>


-- 

Andrija Panić

Re: Querying async job result

Posted by Rakesh v <ww...@gmail.com>.
Hello Anurag


Thanks for the reply. The host does transit to  maintenance mode eventually but the asynchronous job status never changes. Right now I'm periodically fetching the resource_state from DB to see if it changes to "Maintenance". Is there any better way to do it like using triggers or events instead of periodic polling?

Sent from my iPhone

> On 08-Aug-2019, at 10:52 AM, Anurag Awasthi <An...@shapeblue.com> wrote:
> 
> Hi Rakesh,
> 
> You seem to be doing the right thing. I think what you have encoutered is a bug in prepareForMaintenance API. The host tends to be stuck in that state in some scenarios. Perhaps, when a VM enters an error state. I would advise canceling maintenance mode and examining what states the VMs are in. Ensure there are no unexpected errors on VMs, clean them up manually if needed. Then retry prepare for maintenance mode.
> 
> There is an open PR for fixing this issue as well - https://github.com/apache/cloudstack/pull/3425 . While this got sidetracked as we worked on 4.13.0, this will make it in 4.13.1.
> 
> Kind Regards,
> Anurag
> ________________________________
> From: Rakesh Venkatesh <ww...@gmail.com>
> Sent: Thursday, August 8, 2019 2:09 PM
> To: users@cloudstack.apache.org <us...@cloudstack.apache.org>; dev@cloudstack.apache.org <de...@cloudstack.apache.org>
> Subject: Querying async job result
> 
> Hello
> 
> 
> I want to know what is the best way to query the async job result using
> queryAsyncJobResult api. According to the documentation in
> http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html
> ,
> the "jobstatus" of 1 means the command completed but im facing an issue
> where even though the command is still running, the "jobstatus" is always 1.
> 
> Im running "prepareHostForMaintenance" command which returns the jobid.
> When I run queryAsyncJobResult for this jobid, the jobstatus will always be
> 1 even though the hypervisor is still not in maintenance mode.
> 
> So can anyone tell me what is the best way to check if the hypervisor is in
> maintenance mode or not? Im using 4.11 version
> 
> 
> Below are the result which I get
> 
> 
> "resourcestate": "PrepareForMaintenance",
> "jobresultcode": 0,
>  "jobresulttype": "object",
>  "jobstatus": 1,
> 
> --
> Thanks and regards
> Rakesh venkatesh
> 
> Anurag.Awasthi@shapeblue.com 
> www.shapeblue.com
> Amadeus House, Floral Street, London  WC2E 9DPUK
> @shapeblue
> 
> 
> 

Re: Querying async job result

Posted by Rakesh v <ww...@gmail.com>.
Hello Anurag


Thanks for the reply. The host does transit to  maintenance mode eventually but the asynchronous job status never changes. Right now I'm periodically fetching the resource_state from DB to see if it changes to "Maintenance". Is there any better way to do it like using triggers or events instead of periodic polling?

Sent from my iPhone

> On 08-Aug-2019, at 10:52 AM, Anurag Awasthi <An...@shapeblue.com> wrote:
> 
> Hi Rakesh,
> 
> You seem to be doing the right thing. I think what you have encoutered is a bug in prepareForMaintenance API. The host tends to be stuck in that state in some scenarios. Perhaps, when a VM enters an error state. I would advise canceling maintenance mode and examining what states the VMs are in. Ensure there are no unexpected errors on VMs, clean them up manually if needed. Then retry prepare for maintenance mode.
> 
> There is an open PR for fixing this issue as well - https://github.com/apache/cloudstack/pull/3425 . While this got sidetracked as we worked on 4.13.0, this will make it in 4.13.1.
> 
> Kind Regards,
> Anurag
> ________________________________
> From: Rakesh Venkatesh <ww...@gmail.com>
> Sent: Thursday, August 8, 2019 2:09 PM
> To: users@cloudstack.apache.org <us...@cloudstack.apache.org>; dev@cloudstack.apache.org <de...@cloudstack.apache.org>
> Subject: Querying async job result
> 
> Hello
> 
> 
> I want to know what is the best way to query the async job result using
> queryAsyncJobResult api. According to the documentation in
> http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html
> ,
> the "jobstatus" of 1 means the command completed but im facing an issue
> where even though the command is still running, the "jobstatus" is always 1.
> 
> Im running "prepareHostForMaintenance" command which returns the jobid.
> When I run queryAsyncJobResult for this jobid, the jobstatus will always be
> 1 even though the hypervisor is still not in maintenance mode.
> 
> So can anyone tell me what is the best way to check if the hypervisor is in
> maintenance mode or not? Im using 4.11 version
> 
> 
> Below are the result which I get
> 
> 
> "resourcestate": "PrepareForMaintenance",
> "jobresultcode": 0,
>  "jobresulttype": "object",
>  "jobstatus": 1,
> 
> --
> Thanks and regards
> Rakesh venkatesh
> 
> Anurag.Awasthi@shapeblue.com 
> www.shapeblue.com
> Amadeus House, Floral Street, London  WC2E 9DPUK
> @shapeblue
> 
> 
> 

Re: Querying async job result

Posted by Anurag Awasthi <An...@shapeblue.com>.
Hi Rakesh,

You seem to be doing the right thing. I think what you have encoutered is a bug in prepareForMaintenance API. The host tends to be stuck in that state in some scenarios. Perhaps, when a VM enters an error state. I would advise canceling maintenance mode and examining what states the VMs are in. Ensure there are no unexpected errors on VMs, clean them up manually if needed. Then retry prepare for maintenance mode.

There is an open PR for fixing this issue as well - https://github.com/apache/cloudstack/pull/3425 . While this got sidetracked as we worked on 4.13.0, this will make it in 4.13.1.

Kind Regards,
Anurag
________________________________
From: Rakesh Venkatesh <ww...@gmail.com>
Sent: Thursday, August 8, 2019 2:09 PM
To: users@cloudstack.apache.org <us...@cloudstack.apache.org>; dev@cloudstack.apache.org <de...@cloudstack.apache.org>
Subject: Querying async job result

Hello


I want to know what is the best way to query the async job result using
queryAsyncJobResult api. According to the documentation in
http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html
,
the "jobstatus" of 1 means the command completed but im facing an issue
where even though the command is still running, the "jobstatus" is always 1.

Im running "prepareHostForMaintenance" command which returns the jobid.
When I run queryAsyncJobResult for this jobid, the jobstatus will always be
1 even though the hypervisor is still not in maintenance mode.

So can anyone tell me what is the best way to check if the hypervisor is in
maintenance mode or not? Im using 4.11 version


Below are the result which I get


"resourcestate": "PrepareForMaintenance",
"jobresultcode": 0,
  "jobresulttype": "object",
  "jobstatus": 1,

--
Thanks and regards
Rakesh venkatesh

Anurag.Awasthi@shapeblue.com 
www.shapeblue.com
Amadeus House, Floral Street, London  WC2E 9DPUK
@shapeblue
  
 


Re: Querying async job result

Posted by Anurag Awasthi <An...@shapeblue.com>.
Hi Rakesh,

You seem to be doing the right thing. I think what you have encoutered is a bug in prepareForMaintenance API. The host tends to be stuck in that state in some scenarios. Perhaps, when a VM enters an error state. I would advise canceling maintenance mode and examining what states the VMs are in. Ensure there are no unexpected errors on VMs, clean them up manually if needed. Then retry prepare for maintenance mode.

There is an open PR for fixing this issue as well - https://github.com/apache/cloudstack/pull/3425 . While this got sidetracked as we worked on 4.13.0, this will make it in 4.13.1.

Kind Regards,
Anurag
________________________________
From: Rakesh Venkatesh <ww...@gmail.com>
Sent: Thursday, August 8, 2019 2:09 PM
To: users@cloudstack.apache.org <us...@cloudstack.apache.org>; dev@cloudstack.apache.org <de...@cloudstack.apache.org>
Subject: Querying async job result

Hello


I want to know what is the best way to query the async job result using
queryAsyncJobResult api. According to the documentation in
http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html
,
the "jobstatus" of 1 means the command completed but im facing an issue
where even though the command is still running, the "jobstatus" is always 1.

Im running "prepareHostForMaintenance" command which returns the jobid.
When I run queryAsyncJobResult for this jobid, the jobstatus will always be
1 even though the hypervisor is still not in maintenance mode.

So can anyone tell me what is the best way to check if the hypervisor is in
maintenance mode or not? Im using 4.11 version


Below are the result which I get


"resourcestate": "PrepareForMaintenance",
"jobresultcode": 0,
  "jobresulttype": "object",
  "jobstatus": 1,

--
Thanks and regards
Rakesh venkatesh

Anurag.Awasthi@shapeblue.com 
www.shapeblue.com
Amadeus House, Floral Street, London  WC2E 9DPUK
@shapeblue