Bug 851712

Summary: Sync history event state not correct when cancelled.
Product: [Retired] Pulp Reporter: Justin Sherrill <jsherril>
Component: async/tasksAssignee: Jason Connor <jconnor>
Status: CLOSED CURRENTRELEASE QA Contact: Preethi Thomas <pthomas>
Severity: unspecified Docs Contact:
Priority: low    
Version: 2.0.6CC: jason.dobies, mmccune
Target Milestone: ---Keywords: Triaged
Target Release: Sprint 40   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-01-09 17:09:25 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:
Bug Depends On:    
Bug Blocks: 854726    

Description Justin Sherrill 2012-08-24 19:24:44 UTC
Description of problem:

When cancelling a sync, the sync history event object's state is simply set to 'failed'.

Ideally it would be set to cancelled.


Version-Release number of selected component (if applicable):
pulp-server-2.0.1-1.fc16.noarch


How reproducible:
always

Steps to Reproduce:
1. Sync a repo
2. Cancel the sync
3. Request the sync history for that repo (i.e.):
  /pulp/api/v2/repositories/ACME_Corporation-RHEL-6_2_x86_64//history/sync/
  
Actual results:
"Result" of the sync history event is "failed"

Expected results:
"Result" of the sync history event is "cancelled"

Additional info:

Comment 1 Jason Connor 2012-10-05 16:33:58 UTC
Added mapping of task state to result code for cancelled (and other) task states

Comment 2 Jason Connor 2012-10-05 19:22:59 UTC
Fix merged into master in revision:
763ef174020e2cfcb7e681653c48b463e569ffb5

Comment 3 Jeff Ortel 2012-10-05 21:43:13 UTC
build: 0.331

Comment 4 Preethi Thomas 2012-11-07 21:13:50 UTC
Failing
[root@preethi ~]# rpm -q pulp-rpm-server
pulp-rpm-server-0.0.335-1.fc17.noarch
[root@preethi ~]# 


1. Created a repo and ran repo sync



[root@preethi oauth]# pulp-admin -u admin -p admin rpm repo create  --repo-id scientific --feed http://ftp1.scientificlinux.org/linux/scientific/6x/x86_64/updates/security/
Successfully created repository [scientific]

[root@preethi oauth]# 
[root@preethi oauth]# 
[root@preethi oauth]# 
[root@preethi oauth]# pulp-admin rpm repo sync run --repo-id scientific
+----------------------------------------------------------------------+
                 Synchronizing Repository [scientific]
+----------------------------------------------------------------------+

This command may be exited by pressing ctrl+c without affecting the actual
operation on the server.

Downloading metadata...
[-]
... completed

Downloading repository content...
[                                                  ] 0%
RPMs:       1/517 items
Delta RPMs: 0/0 items
Tree Files: 0/0 items
Files:      0/0 items



At the start of downloading repository content I cancelled the sync

[root@preethi ~]# pulp-admin tasks list
+----------------------------------------------------------------------+
                                 Tasks
+----------------------------------------------------------------------+

Operations:  create
Resources:   scientific (repository)
State:       Successful
Start Time:  Unstarted
Finish Time: 2012-11-07T20:50:37Z
Result:      
  Content Unit Count: 0
  Description:        None
  Display Name:       scientific
  Id:                 scientific
  Notes:              
  Scratchpad:         
Task Id:     ee30b90a-3696-4619-adfa-3d120664cb25

Operations:  sync
Resources:   scientific (repository)
State:       Running
Start Time:  2012-11-07T20:51:16Z
Finish Time: Incomplete
Result:      Incomplete
Task Id:     c6a67aad-4fa8-48b6-8894-6f9d17c30a0a

Operations:  auto_publish, publish
Resources:   scientific (repository)
State:       Waiting
Start Time:  Unstarted
Finish Time: Incomplete
Result:      Incomplete
Task Id:     fc05f1ef-5218-4e11-b914-4e90a8dbf57d


[root@preethi ~]# curl -k -u "admin:admin" --request DELETE https://preethi.usersys.redhat.com/pulp/api/v2/tasks/c6a67aad-4fa8-48b6-8894-6f9d17c30a0a/
{"_href": "/pulp/api/v2/tasks/c6a67aad-4fa8-48b6-8894-6f9d17c30a0a/"}[root@preethi ~]# 
[root@preethi ~]# 


Running tasks list showed it as cancelled


[root@preethi ~]# pulp-admin tasks list+----------------------------------------------------------------------+
                                 Tasks
+----------------------------------------------------------------------+

Operations:  auto_publish, publish
Resources:   scientific (repository)
State:       Unknown
Start Time:  Unstarted
Finish Time: Incomplete
Result:      Incomplete
Task Id:     fc05f1ef-5218-4e11-b914-4e90a8dbf57d

Operations:  sync
Resources:   scientific (repository)
State:       Cancelled
Start Time:  Unstarted
Finish Time: 2012-11-07T20:55:04Z
Result:      Incomplete
Task Id:     c6a67aad-4fa8-48b6-8894-6f9d17c30a0a



But sync history does not return anything

[root@preethi ~]# curl -k -u "admin:admin"  https://preethi.usersys.redhat.com/pulp/api/v2/repositories/scientific//history/sync/ |json_reformat
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100     2  100     2    0     0     10      0 --:--:-- --:--:-- --:--:--    10
[

]
[root@preethi ~]# 



I have had a repo syncing successfully in before and the status is showed below



[root@preethi ~]# curl -k -u "admin:admin"  https://preethi.usersys.redhat.com/pulp/api/v2/repositories/scientific//history/sync/ |json_reformat |more
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 17679  100 17679    0     0  95942      0 --:--:-- --:--:-- --:--:-- 96606
[
    {
        "importer_type_id": "yum_importer",
        "importer_id": "yum_importer",
        "exception": null,
        "repo_id": "scientific",
        "removed_count": 0,
        "started": "2012-11-07T15:02:25-05:00",
        "_ns": "repo_sync_results",
        "completed": "2012-11-07T15:06:02-05:00",
        "traceback": null,
        "summary": {
            "comps": {
                "time_total_sec": 0.09594202041625977,
                "num_orphaned_groups": 0,
                "num_available_groups": 0,
                "num_new_groups": 0,
                "num_new_categories": 0,
                "num_orphaned_categories": 0,
                "num_available_categories": 0
            },
            "packages": {
                "num_synced_new_rpms": 0,
                "num_resynced_distribution_files": 0,
                "num_not_synced_srpms": 0,
                "num_synced_new_distributions_files": 0,
                "num_rpms": 515,
                "num_resynced_srpms": 0,
                "num_resynced_rpms": 0,
                "rpm_removal_errors": [

                ],
                "time_total_sec": 212.1712920665741,
                "num_synced_new_drpms": 0,
                "num_synced_new_srpms": 0,
                "num_orphaned_srpms": 0,
                "num_orphaned_rpms": 0,
                "num_synced_new_distributions": 0,
                "num_resynced_drpms": 0,
                "num_resynced_distributions": 0,
                "num_orphaned_drpms": 0,
                "num_not_synced_rpms": 0
            },
            "errata": {
                "errata_time_total_sec": 4.571232080459595,
                "num_new_errata": 0,
                "num_orphaned_errata": 0,
                "num_existing_errata": 0
            }
        },
        "added_count": 0,
        "error_message": null,
        "updated_count": 0,
        "details": {
            "comps": {

            },
            "packages": {
                "time_download_sec": 0.7937390804290771,
                "not_synced": {

                },
                "size_total": 0,
                "time_metadata_sec": 204.17084288597107,
                "sync_report": {
                    "errors": 0,
                    "size_total": 0,
                    "successes": 0,
                    "downloads": 0,
                    "items_left": 0,
                    "items_total": 0,
                    "error_details": [

                    ],
                    "details": {

                    },
                    "size_left": 0
                }
            },
            "errata": {
                "num_bugfix_errata": 0,
                "link_report": {
                    "missing_rpms": [

                    ],
                    "linked_units": [

                    ]
                },
                "num_security_errata": 0,
                "num_enhancement_errata": 0
            }
        },
        "_id": {
            "$oid": "509abf2a758cc9258000001d"
        },
        "id": "509abf2a758cc9258000001d",
        "result": "success"
    },

Comment 5 Jason Connor 2012-12-13 00:45:54 UTC
Unable to reproduce since original fix went in:

[jasonconnor@localhost pulp-local]$ pulp-admin rpm repo create --repo-id pulp --feed http://repos.fedorapeople.org/repos/pulp/pulp/v2/testing/fedora-16/x86_64/
Successfully created repository [pulp]

[jasonconnor@localhost pulp-local]$ pulp-admin rpm repo sync run --bg --repo-id pulp
+----------------------------------------------------------------------+
                    Synchronizing Repository [pulp]
+----------------------------------------------------------------------+

The status of this sync can be displayed using the status command.

[jasonconnor@localhost pulp-local]$ pulp-admin tasks list
+----------------------------------------------------------------------+
                                 Tasks
+----------------------------------------------------------------------+

Operations:  create
Resources:   pulp (repository)
State:       Successful
Start Time:  2012-12-09T00:24:28Z
Finish Time: 2012-12-09T00:24:28Z
Result:      
  Content Unit Count: 0
  Description:        None
  Display Name:       pulp
  Id:                 pulp
  Notes:              
  Scratchpad:         
Task Id:     2fbe9ec6-c8a0-4836-932d-8a3da772691d

Operations:  sync
Resources:   pulp (repository)
State:       Running
Start Time:  2012-12-09T00:25:19Z
Finish Time: Incomplete
Result:      Incomplete
Task Id:     58e591be-804b-42c9-b88f-9944c3a434da

Operations:  auto_publish, publish
Resources:   pulp (repository)
State:       Waiting
Start Time:  Unstarted
Finish Time: Incomplete
Result:      Incomplete
Task Id:     5ec83737-90fe-404e-bfb8-4c6b53ba3ae1


[jasonconnor@localhost pulp-local]$ pulp-admin tasks cancel --task-id 58e591be-804b-42c9-b88f-9944c3a434da

[jasonconnor@localhost pulp-local]$ pulp-admin tasks list
+----------------------------------------------------------------------+
                                 Tasks
+----------------------------------------------------------------------+

Operations:  auto_publish, publish
Resources:   pulp (repository)
State:       Skipped
Start Time:  N/A
Finish Time: N/A
Result:      N/A
Task Id:     5ec83737-90fe-404e-bfb8-4c6b53ba3ae1

Operations:  sync
Resources:   pulp (repository)
State:       Cancelled
Start Time:  2012-12-09T00:25:19Z
Finish Time: 2012-12-09T00:25:50Z
Result:      N/A
Task Id:     58e591be-804b-42c9-b88f-9944c3a434da



In ipython using pic:

In [5]: pic.GET('/v2/repositories/pulp/history/sync/')
Response Body
[
  {
    "result": "canceled", 
    "importer_id": "yum_importer", 
    "exception": null, 
    "repo_id": "pulp", 
    "traceback": null, 
    "started": "2012-12-08T17:25:19-07:00", 
    "_ns": "repo_sync_results", 
    "completed": "2012-12-08T17:25:51-07:00", 
    "importer_type_id": "yum_importer", 
    "error_message": null, 
    "summary": {
      "comps": {}, 
      "packages": {}, 
      "errata": {}
    }, 
    "added_count": 0, 
    "removed_count": 0, 
    "updated_count": 0, 
    "_id": {
      "$oid": "50c3da8fe1382319d000086c"
    }, 
    "id": "50c3da8fe1382319d000086c", 
    "details": {
      "comps": {}, 
      "packages": {}, 
      "errata": {}
    }
  }
]

Comment 6 Jeff Ortel 2012-12-13 15:17:09 UTC
build: 2.0.6-0.15.beta

Comment 7 Preethi Thomas 2012-12-14 14:55:28 UTC
verified

[root@preethi ~]# rpm -q pulp-server
pulp-server-2.0.6-0.17.beta.noarch
[root@preethi ~]# 

[root@preethi ~]# pulp-admin tasks list+----------------------------------------------------------------------+
                                 Tasks
+----------------------------------------------------------------------+

Operations:  auto_publish, publish
Resources:   zoo (repository)
State:       Successful
Start Time:  2012-12-14T14:29:30Z
Finish Time: 2012-12-14T14:29:34Z
Result:      N/A
Task Id:     075de4ab-927c-473a-94b8-aed7eb570ac1

Operations:  sync
Resources:   latest-rpmforge-redhat-el6-en-x86_64 (repository)
State:       Running
Start Time:  2012-12-14T13:44:06Z
Finish Time: Incomplete
Result:      Incomplete
Task Id:     46619f7b-9602-463e-beef-b206c592da8b

Operations:  auto_publish, publish
Resources:   latest-rpmforge-redhat-el6-en-x86_64 (repository)
State:       Waiting
Start Time:  Unstarted
Finish Time: Incomplete
Result:      Incomplete
Task Id:     b6234a74-fee6-4664-bfca-c9cc08ab143b


[root@preethi ~]#  curl -k -u "admin:admin" --request DELETE https://preethi.usersys.redhat.com/pulp/api/v2/tasks/46619f7b-9602-463e-beef-b206c592da8b/ {"_href": "/pulp/api/v2/tasks/46619f7b-9602-463e-beef-b206c592da8b/"}
{"task_group_id": "9fca21c3-51dc-4851-8276-f322d08c9745", "exception": null, "traceback": null, "_href": "/pulp/api/v2/tasks/46619f7b-9602-463e-beef-b206c592da8b/", "task_id": "46619f7b-9602-463e-beef-b206c592da8b", "call_request_tags": ["pulp:repository:latest-rpmforge-redhat-el6-en-x86_64", "pulp:action:sync"], "reasons": [], "start_time": "2012-12-14T13:44:06Z", "tags": ["pulp:repository:latest-rpmforge-redhat-el6-en-x86_64", "pulp:action:sync"], "state": "canceled", "finish_time": "2012-12-14T14:48:41Z", "dependency_failures": {}, "schedule_id": null, "progress": {"yum_importer": {"content": {"num_success": 2219, "size_total": 1105828817, "items_left": 1474, "items_total": 3693, "state": "IN_PROGRESS", "size_left": 501690183, "details": {"tree_file": {"num_success": 0, "size_total": 0, "items_left": 0, "items_total": 0, "size_left": 0, "num_error": 0}, "rpm": {"num_success": 2219, "size_total": 1105828817, "items_left": 1474, "items_total": 3693, "size_left": 501690183, "num_error": 0}, "delta_rpm": {"num_success": 0, "size_total": 0, "items_left": 0, "items_total": 0, "size_left": 0, "num_error": 0}, "file": {"num_success": 0, "size_total": 0, "items_left": 0, "items_total": 0, "size_left": 0, "num_error": 0}}, "error_details": [], "num_error": 0}, "comps": {"state": "NOT_STARTED"}, "errata": {"state": "NOT_STARTED"}, "metadata": {"state": "FINISHED"}}}, "call_request_group_id": "9fca21c3-51dc-4851-8276-f322d08c9745", "call_request_id": "46619f7b-9602-463e-beef-b206c592da8b", "principal_login": "admin", "response": "accepted", "result": null}

[root@preethi ~]# curl -k -u "admin:admin"  https://preethi.usersys.redhat.com/pulp/api/v2/repositories/latest-rpmforge-redhat-el6-en-x86_64/history/sync/ |json_reformat
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   562  100   562    0     0   3272      0 --:--:-- --:--:-- --:--:--  3305
[
    {
        "importer_type_id": "yum_importer",
        "importer_id": "yum_importer",
        "exception": null,
        "repo_id": "latest-rpmforge-redhat-el6-en-x86_64",
        "removed_count": 0,
        "started": "2012-12-14T08:44:06-05:00",
        "_ns": "repo_sync_results",
        "completed": "2012-12-14T09:48:43-05:00",
        "traceback": null,
        "summary": {
            "comps": {

            },
            "packages": {

            },
            "errata": {

            }
        },
        "added_count": 0,
        "error_message": null,
        "updated_count": 0,
        "details": {
            "comps": {

            },
            "packages": {

            },
            "errata": {

            }
        },
        "_id": {
            "$oid": "50cb3c4b758cc92178001577"
        },
        "id": "50cb3c4b758cc92178001577",
        "result": "canceled"
    }
]
[root@preethi ~]#

Comment 8 Preethi Thomas 2013-01-09 17:09:25 UTC
Pulp v2.0 released