Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 995858 - RHEVM-BACKEND - Force remove DC doesn't work using RESTAPI
Summary: RHEVM-BACKEND - Force remove DC doesn't work using RESTAPI
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: ovirt-engine
Version: 3.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 3.4.0
Assignee: Liran Zelkha
QA Contact: Barak Dagan
URL:
Whiteboard: infra
Depends On:
Blocks: 922504 rhev3.4beta 1142926
TreeView+ depends on / blocked
 
Reported: 2013-08-11 14:38 UTC by Barak Dagan
Modified: 2016-02-10 19:02 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-06-12 14:05:32 UTC
oVirt Team: Infra
Target Upstream Version:


Attachments (Terms of Use)
engine log (deleted)
2013-08-11 14:38 UTC, Barak Dagan
no flags Details
engine log (deleted)
2013-12-25 08:28 UTC, Barak Dagan
no flags Details

Description Barak Dagan 2013-08-11 14:38:23 UTC
Created attachment 785404 [details]
engine log

Description of problem:


Version-Release number of selected component (if applicable):
IS9

How reproducible:
100%

Steps to Reproduce:
1. create DC + cluster
2. force remove DC using RESTAPI / CLI

DELETE /api/datacenters/f2f208b0-cb00-4398-b35a-6f821482d275

<action>
    <force>=true</force>
</action>

remove datacenter MyDC --force

Actual results:
Data Center MyDC was removed by user@domain

Expected results:
Data Center MyDC was forcibly removed by user@domain

Additional info:

Comment 1 Mooli Tayer 2013-08-21 13:08:21 UTC
When executing:
remove datacenter MyDC --force

(only through the cli/api)
The forceDelete parameter is false for some reason.

Comment 2 Mooli Tayer 2013-08-22 08:58:35 UTC
cli expects a boolean argument
(see 'help remove datacenter dc_01')

do
remove datacenter MyDC --force true
and not
remove datacenter MyDC --force 

We should consider opening a new bug for the missing parameter not triggering an error message (not specifically for the --force parameter). I've sent an email to a PM about it.

Comment 3 Arthur Berezin 2013-08-22 12:06:08 UTC
Thanks for noticing.

Yes, this is definitely a bug.

If --force is stated in CLI we should have "true" as default, a success/failure output message and 0/1 exit code accordingly(just like any other linux CLI command standard) 



Arthur

Comment 4 Barak Dagan 2013-12-24 15:59:18 UTC
This bug was about the wrong message recived in th task monitor.
In the RFE (https://bugzilla.redhat.com/show_bug.cgi?id=922504) there should be a different message for forece and regular DC remove. 

Actually, it seems that the force remove DC action is not working using API:


DELETE /api/datacenters/fb3072a9-4ae0-470d-9b3a-4eb17a733d39 HTTP/1.1
Accept: application/xml
Content-type: application/xml

<action>
    <force>true</force>
</action>

Response:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<fault>
<reason>Operation Failed</reason>
<detail>[Cannot remove an active Data Center.]</detail>
</fault>

same response for the CLI, naturally: 

[RHEVM shell (connected@localhost)]# remove datacenter f8835417-ef89-4313-94c6-3560ce5ac678 --force true

error: 
status: 409
reason: Conflict
detail: Cannot remove an active Data Center.

Therefore I re-open the bug.

Comment 5 Yair Zaslavsky 2013-12-25 00:59:42 UTC
Can you please attach engine.log?

Comment 6 Barak Dagan 2013-12-25 08:28:32 UTC
Created attachment 841410 [details]
engine log

Comment 7 Barak 2013-12-26 09:41:06 UTC
Michael,

Did we do some generic work on this issue ?

Comment 9 Michael Pasternak 2013-12-26 09:59:20 UTC
(In reply to Barak Dagan from comment #4)
> This bug was about the wrong message recived in th task monitor.
> In the RFE (https://bugzilla.redhat.com/show_bug.cgi?id=922504) there should
> be a different message for forece and regular DC remove. 
> 
> Actually, it seems that the force remove DC action is not working using API:
> 
> 
> DELETE /api/datacenters/fb3072a9-4ae0-470d-9b3a-4eb17a733d39 HTTP/1.1
> Accept: application/xml
> Content-type: application/xml
> 
> <action>
>     <force>true</force>
> </action>
> 
> Response:
> 
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <fault>
> <reason>Operation Failed</reason>
> <detail>[Cannot remove an active Data Center.]</detail>
> </fault>
> 
> same response for the CLI, naturally: 
> 
> [RHEVM shell (connected@localhost)]# remove datacenter
> f8835417-ef89-4313-94c6-3560ce5ac678 --force true
> 
> error: 
> status: 409
> reason: Conflict
> detail: Cannot remove an active Data Center.
> 
> Therefore I re-open the bug.

i'm not sure your expectations from 'force' are correct,

Iatamar, should we be able removing 'active' DC?, see RemoveStoragePoolCommand#canDoAction

Comment 10 Michael Pasternak 2013-12-26 10:01:28 UTC
(In reply to Arthur Berezin from comment #3)
> Thanks for noticing.
> 
> Yes, this is definitely a bug.
> 
> If --force is stated in CLI we should have "true" as default, a
> success/failure output message and 0/1 exit code accordingly(just like any
> other linux CLI command standard) 
> 
> 
> 
> Arthur

this is not a bug, but current behaviour of cli, we have RFE (bug 1006918) to
treat boolean options as flags.

Comment 11 Yair Zaslavsky 2013-12-26 11:20:57 UTC
Indeed, canDoAction of the command clearly shows that an active data center will not be removed.
the check of the "force" flag is used in other conditions at the canDoAction.
Do we want to change this behavior?

Comment 12 Arthur Berezin 2013-12-26 15:55:08 UTC
Yair, in which cases/conditions do we take "force" under account today?

Force is mostly used to remove an object which is not operational, but has dependencies which prevent the user to issue a standard "delete" command.

Comment 13 Barak Dagan 2013-12-26 19:26:57 UTC
Again, this is not about the boolean of the cli.
it is about not be able to do action, which can be done from the UI, using the API.
As can be seen it doesn't work using the REST xml as well. I added the CLI, since it is easier IMO.

I do think it should be solved in 3.3.0 or 3.3.1.

Comment 15 Yair Zaslavsky 2013-12-27 01:19:51 UTC
(In reply to Arthur Berezin from comment #12)
> Yair, in which cases/conditions do we take "force" under account today?
> 
> Force is mostly used to remove an object which is not operational, but has
> dependencies which prevent the user to issue a standard "delete" command.

Arthur - force will work in all cases except for the following cases where it will fail on validation:

1. DataCenter is up
2. There are active or locked storage domains
3. When one of the host is not in maintainence.

Comment 16 Liran Zelkha 2014-02-18 08:41:06 UTC
(In reply to Yair Zaslavsky from comment #15)
> (In reply to Arthur Berezin from comment #12)
> > Yair, in which cases/conditions do we take "force" under account today?
> > 
> > Force is mostly used to remove an object which is not operational, but has
> > dependencies which prevent the user to issue a standard "delete" command.
> 
> Arthur - force will work in all cases except for the following cases where
> it will fail on validation:
> 
> 1. DataCenter is up
> 2. There are active or locked storage domains
> 3. When one of the host is not in maintainence.

So bottom line - what is the bug here? If server gets the force flag, which behavior should change?

Comment 17 Liran Zelkha 2014-02-18 08:47:08 UTC
(In reply to Yair Zaslavsky from comment #15)
> (In reply to Arthur Berezin from comment #12)
> > Yair, in which cases/conditions do we take "force" under account today?
> > 
> > Force is mostly used to remove an object which is not operational, but has
> > dependencies which prevent the user to issue a standard "delete" command.
> 
> Arthur - force will work in all cases except for the following cases where
> it will fail on validation:
> 
> 1. DataCenter is up
> 2. There are active or locked storage domains
> 3. When one of the host is not in maintainence.

So bottom line - what is the bug here? If server gets the force flag, which behavior should change?

Comment 19 Liran Zelkha 2014-03-10 19:48:21 UTC
Verified by both Juan and myself - this works via API.
Command used:

curl \
-k \
-X DELETE \
-H "Accept: application/xml" \
-H "Content-Type: application/xml" \
-u admin@internal:123456 \
-d '<action><force>true</force></action>' \
http://localhost:8080/ovirt-engine/api/datacenters/329304cb-727e-4db4-b9e1-f749f6a52ffe

Needs JBoss 7.1.1

Comment 20 Eli Mesika 2014-03-10 21:39:45 UTC
Moving to ON-QA

Comment 21 Barak Dagan 2014-03-11 07:27:45 UTC
Verified on av2.1


[oVirt shell (connected)]# list datacenters 

id         : ed2509b5-d32b-4c69-b9a2-ee260e39d90b
name       : MyDC

id         : 00000002-0002-0002-0002-0000000000b2
name       : Default
description: The default Data Center



[oVirt shell (connected)]# show datacenter MyDC

id                              : ed2509b5-d32b-4c69-b9a2-ee260e39d90b
name                            : MyDC
local                           : False
status-state                    : up
storage_format                  : v3
supported_versions-version-major: 3
supported_versions-version-minor: 4
version-major                   : 3
version-minor                   : 4

[oVirt shell (connected)]# list clusters --show-all | egrep 'name|id|data'
id                                                    : 24f48f99-d97d-485d-b181-c099fef572a0
name                                                  : MyCL
data_center-id                                        : ed2509b5-d32b-4c69-b9a2-ee260e39d90b
id                                                    : 00000001-0001-0001-0001-0000000000ea
name                                                  : Default
data_center-id                                        : 00000002-0002-0002-0002-0000000000b2


[oVirt shell (connected)]# list vms --show-all | egrep 'name|cluster'
name                                         : VM-0
cluster-id                                   : 24f48f99-d97d-485d-b181-c099fef572a0
name                                         : VM-1
cluster-id                                   : 24f48f99-d97d-485d-b181-c099fef572a0
name                                         : VM-2
cluster-id                                   : 24f48f99-d97d-485d-b181-c099fef572a0
name                                         : VM-3
cluster-id                                   : 24f48f99-d97d-485d-b181-c099fef572a0
name                                         : VM-4
cluster-id                                   : 24f48f99-d97d-485d-b181-c099fef572a0




[oVirt shell (connected)]# remove datacenter MyDC --force true
  ================================================= ERROR ==============================================
  status: 409
  reason: Conflict
  detail: Cannot remove an active Data Center.
  ======================================================================================================


Log:

2014-03-11 09:12:47,553 INFO  [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (ajp-/127.0.0.1:8702-10) Correlation ID: null, Call Stack: null, Custom Event ID: -1, Message: User admin logged in.
2014-03-11 09:13:39,868 WARN  [org.ovirt.engine.core.bll.storage.RemoveStoragePoolCommand] (ajp-/127.0.0.1:8702-10) [2fdfb6c2] CanDoAction of action RemoveStoragePool failed. Reasons:VAR__TYPE__STORAGE__POOL,VAR__ACTION__REMOVE,ERROR_CANNOT_REMOVE_ACTIVE_STORAGE_POOL
2014-03-11 09:13:39,877 ERROR [org.ovirt.engine.api.restapi.resource.AbstractBackendResource] (ajp-/127.0.0.1:8702-10) Operation Failed: [Cannot remove an active Data Center.]


==============================================================================

Shutting down VM, moving host to maintenance:


[oVirt shell (connected)]# remove datacenter MyDC --force true
job-id      : a0133eac-3e50-4803-801a-b38302629ebc
status-state: complete

Task Monitor: "Data Center DC10 was forcibly removed by admin".

Seems that the Bug was in the UI - datacenter could be force removed when it shouldn't.

Comment 22 Itamar Heim 2014-06-12 14:05:32 UTC
Closing as part of 3.4.0


Note You need to log in before you can comment on or make changes to this bug.