This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 995858 - RHEVM-BACKEND - Force remove DC doesn't work using RESTAPI
RHEVM-BACKEND - Force remove DC doesn't work using RESTAPI
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: ovirt-engine (Show other bugs)
3.3.0
Unspecified Unspecified
unspecified Severity medium
: ---
: 3.4.0
Assigned To: Liran Zelkha
Barak Dagan
infra
: Reopened
Depends On: 1006918
Blocks: 922504 rhev3.4beta 1142926
  Show dependency treegraph
 
Reported: 2013-08-11 10:38 EDT by Barak Dagan
Modified: 2016-02-10 14:02 EST (History)
11 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-06-12 10:05:32 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: Infra
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
engine log (4.00 KB, application/x-compressed-tar)
2013-08-11 10:38 EDT, Barak Dagan
no flags Details
engine log (13.75 KB, application/x-compressed-tar)
2013-12-25 03:28 EST, Barak Dagan
no flags Details

  None (edit)
Description Barak Dagan 2013-08-11 10:38:23 EDT
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 09:08:21 EDT
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 04:58:35 EDT
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 08:06:08 EDT
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 10:59:18 EST
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-24 19:59:42 EST
Can you please attach engine.log?
Comment 6 Barak Dagan 2013-12-25 03:28:32 EST
Created attachment 841410 [details]
engine log
Comment 7 Barak 2013-12-26 04:41:06 EST
Michael,

Did we do some generic work on this issue ?
Comment 9 Michael Pasternak 2013-12-26 04:59:20 EST
(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 05:01:28 EST
(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 06:20:57 EST
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 10:55:08 EST
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 14:26:57 EST
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-26 20:19:51 EST
(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 03:41:06 EST
(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 03:47:08 EST
(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 15:48:21 EDT
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 17:39:45 EDT
Moving to ON-QA
Comment 21 Barak Dagan 2014-03-11 03:27:45 EDT
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 10:05:32 EDT
Closing as part of 3.4.0

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