Bug 877344 - bkr job-modify and problems with retention tag update
Summary: bkr job-modify and problems with retention tag update
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Beaker
Classification: Retired
Component: command line
Version: 0.9
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: 0.15.3
Assignee: Dan Callaghan
QA Contact: tools-bugs
URL:
Whiteboard: CommandLineEnhancement
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-11-16 10:09 UTC by Petr Šplíchal
Modified: 2018-02-06 00:41 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-02-03 04:52:20 UTC
Embargoed:


Attachments (Terms of Use)

Description Petr Šplíchal 2012-11-16 10:09:16 UTC
Description of problem:

Updating retention tag using 'bkr job-modify' command behaves
inconsistently. It's not possible to reliably set retention to one
of those which do not require product to be associated. It can be
workarounded once using --product '' but succesive command fails.

Version-Release number of selected component (if applicable):
beaker-client-0.9.4-2.el6eng.noarch

Steps to Reproduce:
$ bkr job-modify J:334956 --retention-tag scratch
Successfully modified jobs J:334956

$ bkr job-modify J:334956 --retention-tag 120days
Successfully modified jobs J:334956

$ bkr job-modify J:334956 --retention-tag audit --product cpe:/o:redhat:enterprise_linux:6:update3
Successfully modified jobs J:334956

$ bkr job-modify J:334956 --retention-tag 120days
<Fault 1: "<class 'bkr.common.bexceptions.BeakerException'>:'Job 334956 not updated: Incompatible product and tags'">
No jobs modified

$ bkr job-modify J:334956 --retention-tag 120days --product ''
Successfully modified jobs J:334956

$ bkr job-modify J:334956 --retention-tag 120days --product ''
<Fault 1: "<type 'exceptions.AttributeError'>:'int' object has no attribute '_sa_instance_state'">

Comment 1 Petr Šplíchal 2012-11-16 10:23:42 UTC
Expected results:

When one of 'scratch', '60days', '120days' tags provided, product
is cleared automatically, no option --product is required.

Comment 2 Raymond Mancy 2012-11-20 10:05:36 UTC
(In reply to comment #1)
> Expected results:
> 
> When one of 'scratch', '60days', '120days' tags provided, product
> is cleared automatically, no option --product is required.

We were trying to keep it consistent with how it works via the UI. Via the UI, you need to confirm that you will be removing the product when you go to 'scratch', '60days' etc, and explicitly setting the product to '' in beaker-client is more or less equivalent.

Comment 3 Petr Šplíchal 2012-11-23 10:35:51 UTC
I see. But what would you suggest to do when I want to script
setting the retention to 120days without knowing the current
status? For now the only way I can think of is:

    current = fetch_the_current_retention_from_beaker
    if current in ['audit', 'active', 'active+']:
        bkr job-modify J:334956 --retention-tag 120days --product ''
    else:
        bkr job-modify J:334956 --retention-tag 120days

Which seems to me like quite cumbersone and ineffective way.

Comment 4 Dan Callaghan 2012-11-26 00:47:43 UTC
The bug is this one:

> $ bkr job-modify J:334956 --retention-tag 120days --product ''
> <Fault 1: "<type 'exceptions.AttributeError'>:'int' object has no attribute
> '_sa_instance_state'">

You should be able to just unconditionally use --retention-tag 120days --product ''.

Comment 5 Petr Šplíchal 2012-11-28 18:21:53 UTC
Yes, that would solved the problem. Do you expect this to be fixed
soon? I believe the implementation should not be complicated. Thanks.

Comment 7 xjia 2013-12-10 02:33:56 UTC
When trying modify recipeset with -t and -p options, it will show error message and successful message. Make it confused.

Actual:
[root@dhcp-65-142 ~]# bkr job-modify -r nak RS:119 -t active+1 -p cpe:/o:redhat:rhel_mission_critical:5.6
<Fault 1: <type 'exceptions.AttributeError'>:'RecipeSet' object has no attribute 'can_change_product'>
Successfully modified jobs RS:119


Expected:
Can't change tag or product for RecipeSet.

Comment 8 Raymond Mancy 2013-12-10 02:51:37 UTC
This is a different and separate issue. The original issue is about inconsistent behaviour when setting certain combinations of product and retention tags.

Comment 9 xjia 2013-12-10 03:24:48 UTC
(In reply to Raymond Mancy from comment #8)
Okay, open a bug for comment #7 :
https://bugzilla.redhat.com/show_bug.cgi?id=1039807

Comment 10 Dan Callaghan 2013-12-18 00:45:05 UTC
I fixed this bug while working on bug 1022333.

http://gerrit.beaker-project.org/2623

Comment 12 wangjing 2013-12-20 08:25:33 UTC
verified on beaker-devel(beaker-0.15.3-0.git.5.46f86da)-->pass

Steps:
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag scratch
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag audit --product cpe:/o:redhat:enterprise_linux:6:update3
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# 
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days
<Fault 1: "<class 'bkr.common.bexceptions.BeakerException'>:Job 2546 not updated: Incompatible product and tags">
No jobs modified
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days --product ''
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days --product ''
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days --product ''
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag scratch
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag audit
<Fault 1: "<class 'bkr.common.bexceptions.BeakerException'>:Job 2546 not updated: Incompatible product and tags">
No jobs modified
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag audit --product cpe:/o:redhat:enterprise_linux:6:update3
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag active --product cpe:/a:redhat:rosp:1.0 
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag active --product cpe:/a:redhat:rosp:1.0 
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag active
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days
<Fault 1: "<class 'bkr.common.bexceptions.BeakerException'>:Job 2546 not updated: Incompatible product and tags">
No jobs modified
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days --product ''
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days --product ''
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag active
<Fault 1: "<class 'bkr.common.bexceptions.BeakerException'>:Job 2546 not updated: Incompatible product and tags">
No jobs modified
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag active --product cpe:/a:redhat:rosp:1.0
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag active --product cpe:/a:redhat:rosp:1.0
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days --product ''
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# 
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag scratch
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days --product ''
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days --product ''
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag scratch --product ''
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag 120days
Successfully modified jobs J:2546
[root@dhcp-10-121 beakernew]# bkr job-modify J:2546 --retention-tag scratch
Successfully modified jobs J:2546


Actual results:
same as expected results

Expected results:
Successfully modified jobs in steps above.

Comment 13 Nick Coghlan 2014-02-03 04:52:20 UTC
This change is included in the Beaker 0.15.3 maintenance release:

http://beaker-project.org/docs/whats-new/release-0.15.html#beaker-0-15-3


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