Bug 1130084

Summary: Spawned task for the binding removal is not created after repo deletion
Product: [Retired] Pulp Reporter: Ina Panova <ipanova>
Component: consumersAssignee: Chris Duryee <cduryee>
Status: CLOSED CURRENTRELEASE QA Contact: Ina Panova <ipanova>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.4 BetaCC: cduryee, rbarlow
Target Milestone: ---Keywords: Triaged
Target Release: 2.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-11-24 21:33:31 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ina Panova 2014-08-14 10:01:15 UTC
Description of problem:
Deletion of a repository that has consumers bound to it should be done in two steps(as docs state). First step is deletion of the repo and second step is removal of bindings between repo and consumers.
Issue consists in the fact that repo is removed but removal of the repo does not spawn a child task that would be responsible for the removal of the binding itself.


Version-Release number of selected component (if applicable):
2.4.1-0.1.alpha

How reproducible:
always

Steps to Reproduce:
1. create consumer, repo
2. bind consumer to the repo
3. delete the repo 


1) bind consumer to the repo
$ curl -i -H "Accept: application/json" -X POST -k -u admin:admin  -d '{"repo_id":"test_repo","distributor_id":"yum_distributor"}' 'https://example.com/pulp/api/v2/consumers/test_consumer/bindings/'
HTTP/1.1 202 Accepted
Date: Thu, 14 Aug 2014 09:45:35 GMT
Server: Apache/2.4.10 (Fedora) OpenSSL/1.0.1e-fips mod_wsgi/3.5 Python/2.7.5
Content-Encoding: utf-8
Content-Length: 909
Content-Type: application/json

{"spawned_tasks": [{"exception": null, "task_type": null, "_href": "/pulp/api/v2/tasks/99173829-8df7-4a07-936b-e3348de12037/", "task_id": "99173829-8df7-4a07-936b-e3348de12037", "tags": ["pulp:consumer:test_consumer", "pulp:repository:test_repo", "pulp:repository_distributor:yum_distributor", "pulp:action:agent_bind"], "finish_time": null, "_ns": "task_status", "start_time": null, "traceback": null, "spawned_tasks": [], "progress_report": {}, "queue": "agent", "state": "waiting", "result": null, "error": null, "_id": {"$oid": "53ec853fc91e3112065e4c28"}, "id": "53ec853fc91e3112065e4c28"}], "result": {"notify_agent": true, "repo_id": "test_repo", "deleted": false, "_ns": "consumer_bindings", "distributor_id": "yum_distributor", "consumer_id": "test_consumer", "consumer_actions": [], "binding_config": {}, "_id": {"$oid": "53ec853fc91e3112065e4c25"}, "id": "53ec853fc91e3112065e4c25"}, "error": null}


2) check the binding
$ curl -H "Accept: application/json" -X GET  -k -u admin:admin 'https://example.com/pulp/api/v2/consumers/test_consumer/bindings/'|python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   630  100   630    0     0    638      0 --:--:-- --:--:-- --:--:--   637
[
    {
        "_href": "/pulp/api/v2/consumers/test_consumer/bindings/test_repo/yum_distributor/",
        "_id": {
            "$oid": "53ec853fc91e3112065e4c25"
        },
        "_ns": "consumer_bindings",
        "binding_config": {},
        "consumer_actions": [],
        "consumer_id": "test_consumer",
        "deleted": false,
        "details": {
            "ca_cert": null,
            "client_cert": null,
            "gpg_keys": [],
            "protocols": [
                "https"
            ],
            "relative_path": "/pulp/repos/test_repo",
            "repo_name": "test_repo",
            "server_name": "ec2-54-75-154-157.eu-west-1.compute.amazonaws.com"
        },
        "distributor_id": "yum_distributor",
        "id": "53ec853fc91e3112065e4c25",
        "notify_agent": true,
        "repo_id": "test_repo",
        "type_id": "yum_distributor"
    }
]

3) delete repo
$ curl -H "Accept: application/json" -X DELETE  -k -u admin:admin 'https://example.com/pulp/api/v2/repositories/test_repo/'|python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   172  100   172    0     0    104      0  0:00:01  0:00:01 --:--:--   104
{
    "error": null,
    "result": null,
    "spawned_tasks": [
        {
            "_href": "/pulp/api/v2/tasks/b0f002b3-f816-4f90-94c5-b7684595148d/",
            "task_id": "b0f002b3-f816-4f90-94c5-b7684595148d"
        }
    ]
}

$ curl -H "Accept: application/json" -X GET  -k -u admin:admin 'https://example.com/pulp/api/v2/tasks/b0f002b3-f816-4f90-94c5-b7684595148d/'|python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1040  100  1040    0     0    946      0  0:00:01  0:00:01 --:--:--   947
{
    "_href": "/pulp/api/v2/tasks/b0f002b3-f816-4f90-94c5-b7684595148d/",
    "_id": {
        "$oid": "53ec864db4f7604753993f50"
    },
    "_ns": "task_status",
    "error": {
        "code": "PLP0007",
        "data": {
            "repo_id": "test_repo"
        },
        "description": "Error occurred while cascading delete of repository test_repo to distributor bindings associated with it.",
        "sub_errors": [
            {
                "code": "PLP0009",
                "data": {
                    "resources": {
                        "distributor_id": "yum_distributor",
                        "repo_id": "test_repo"
                    }
                },
                "description": "Missing resource(s): repo_id=test_repo, distributor_id=yum_distributor",
                "sub_errors": []
            }
        ]
    },
    "exception": null,
    "finish_time": "2014-08-14T09:50:05Z",
    "id": "53ec864dc91e3112048830c0",
    "progress_report": {},
    "queue": "reserved_resource_worker-0.compute.amazonaws.com.dq",
    "result": null,
    "spawned_tasks": [],
    "start_time": "2014-08-14T09:50:05Z",
    "state": "finished",
    "tags": [
        "pulp:repository:test_repo",
        "pulp:action:delete"
    ],
    "task_id": "b0f002b3-f816-4f90-94c5-b7684595148d",
    "task_type": "pulp.server.tasks.repository.delete",
    "traceback": null
}

Actual results:
"spawned_tasks": []

Expected results:
spawned task should contain the task for the binding removal

Additional info:

Comment 1 Randy Barlow 2014-08-20 16:30:37 UTC
This may be fixed. Please check and make sure. If it is, please move it to ON_QA for QE ACK.

Comment 2 Chris Duryee 2014-08-25 21:57:29 UTC
I tested this and it appears to work now (tested via pulp-admin and confirmed via task list and consumer list). Moving to MODIFIED state.

Comment 3 Chris Duryee 2014-09-30 13:52:38 UTC
build: 2.5.0-0.6.beta

Comment 4 Ina Panova 2014-10-01 15:43:15 UTC
Tested in  2.5.0-0.6.beta.
Spawned task for binding removal created.
Moving to Verified.

# curl -H "Accept: application/json" -X DELETE  -k -u admin:admin 'https://ec2-54-217-44-62.eu-west-1.compute.amazonaws.com/pulp/api/v2/repositories/m1/'|python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   172  100   172    0     0    190      0 --:--:-- --:--:-- --:--:--   190
{
    "error": null,
    "result": null,
    "spawned_tasks": [
        {
            "_href": "/pulp/api/v2/tasks/6359e7ba-f21a-4414-9af3-8723b4e5b760/",
            "task_id": "6359e7ba-f21a-4414-9af3-8723b4e5b760"
        }
    ]
}
[root@ec2-54-217-44-62 ~]# curl -H "Accept: application/json" -X GET  -k -u admin:admin 'https://ec2-54-217-44-62.eu-west-1.compute.amazonaws.com/pulp/api/v2/tasks/6359e7ba-f21a-4414-9af3-8723b4e5b760/'|python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   749  100   749    0     0   2073      0 --:--:-- --:--:-- --:--:--  2080
{
    "_href": "/pulp/api/v2/tasks/6359e7ba-f21a-4414-9af3-8723b4e5b760/",
    "_id": {
        "$oid": "542c20ccad4a68b7cd57fb66"
    },
    "_ns": "task_status",
    "error": null,
    "exception": null,
    "finish_time": "2014-10-01T15:42:05Z",
    "id": "542c20cc908a3a4ee66219c7",
    "progress_report": {},
    "queue": "reserved_resource_worker-0.compute.amazonaws.com.dq",
    "result": null,
    "spawned_tasks": [
        {
            "_href": "/pulp/api/v2/tasks/498ce2c8-2c26-4c0b-83fd-c2c650fa03b6/",
            "task_id": "498ce2c8-2c26-4c0b-83fd-c2c650fa03b6"
        }
    ],
    "start_time": "2014-10-01T15:42:05Z",
    "state": "finished",
    "tags": [
        "pulp:repository:m1",
        "pulp:action:delete"
    ],
    "task_id": "6359e7ba-f21a-4414-9af3-8723b4e5b760",
    "task_type": "pulp.server.tasks.repository.delete",
    "traceback": null
}