Bug 1386688

Summary: Content view errata filter rules with date not shown in UI
Product: Red Hat Satellite Reporter: Peter Vreman <peter.vreman>
Component: Content ViewsAssignee: Brad Buckingham <bbuckingham>
Status: CLOSED ERRATA QA Contact: Walden Raines <walden>
Severity: medium Docs Contact:
Priority: high    
Version: 6.2.2CC: abalakht, bbuckingham, emarquez, jcallaha, walden
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 17:30:20 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: 1122832    
Attachments:
Description Flags
Empty filter rule list none

Description Peter Vreman 2016-10-19 12:50:43 UTC
Created attachment 1212138 [details]
Empty filter rule list

Description of problem:
[crash] root@li-lc-1578:~# sudo -u hoici hammer -c /opt/hoici/etc/sat6/hammer-hoici.yaml content-view filter info --content-view-id=49 --id=15
Filter ID:    15
Name:         product-HOIRHEL-6.8-d20161016 Freeze Date
Type:         erratum
Inclusion:    true
Description:
Repositories:

Rules:
 1) ID:         6
    Start Date: 2000-01-01
    End Date:   2016-10-16
    Created:    2016/10/16 14:01:06
    Updated:    2016/10/16 14:01:06


In the UI the list of filter rules is empty as can be seen in the attached screenshot.



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


How reproducible:


Steps to Reproduce:
1. Create ContentView
2. Add ContentView filter with inclusion with start and end date 
3.

Actual results:
ContentView filter rule list is empty

Expected results:
ContentView filter rule list lists date rules

Additional info:

Comment 1 Peter Vreman 2016-10-19 13:00:26 UTC
The difference with a working UI version is the missing of the types:[] array in the rule:

Failing Rule in the UI:

[crash] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999}" -XGET https://localhost/katello/api/v2/content_view_filters/15 | jq .rules
[
  {
    "content_view_filter_id": 15,
    "start_date": "2000-01-01",
    "end_date": "2016-10-16",
    "date_type": "updated",
    "id": 6,
    "created_at": "2016-10-16 14:01:06 UTC",
    "updated_at": "2016-10-16 14:01:06 UTC"
  }
]


Working Rule in the UI:

[crash] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999}" -XGET https://localhost/katello/api/v2/content_view_filters/25 | jq .rules
[
  {
    "content_view_filter_id": 25,
    "start_date": "2000-01-01",
    "end_date": "2016-10-19",
    "types": [
      "security",
      "enhancement",
      "bugfix"
    ],
    "date_type": "issued",
    "id": 9,
    "created_at": "2016-10-19 12:40:37 UTC",
    "updated_at": "2016-10-19 12:49:37 UTC"
  }
]

That means that the input check from the rules in the API is not correct. It should require also at least 1 type to be set

Comment 2 Peter Vreman 2016-10-19 13:07:53 UTC
The API shall do sanity checking or added reasonable defaults when optional values are missing.
In case of the types with a date filter, when i do not specify it i do not care about it and the default shall then be all types.

Comment 3 Peter Vreman 2016-10-19 13:09:02 UTC
Second note, the UI does not display the time within the day. Is the listed end date the start of the day or 23.59.59? and in which timezone are the dates and times?

Comment 5 Brad Buckingham 2016-10-25 18:22:28 UTC
Hi Peter, the behavior observed in the initial description is actually working as designed.  When creating the filter from the cli, it is created as an 'erratum' filter; however, the rule determines whether it is going to be treated as either 'Erratum - by ID' or 'Erratum - by Date and Type'.  The type would be based upon what parameters are associated with the rule.

For example:

- "Erratum - by Date and Type" - could include the following arguments from the cli:

 --end-date END_DATE                             erratum: end date (YYYY-MM-DD)
 --start-date START_DATE                         erratum: start date (YYYY-MM-DD)
 --types TYPES                                   erratum: types (enhancement, bugfix, security)
                                                 Comma separated list of values.

- "Erratum - by ID" - could include either of the following arguments from the cli:

 --errata-id ERRATA_ID                           erratum: id
    OR
 --errata-ids ERRATA_IDS                         erratum: IDs or a select all object
                                                 Comma separated list of values.

That said, I'll see if it is feasible to default the 'types' value to all types (i.e. security,enhancement,bugfix) to be consistent with the UI for cases where the rule is created without specifying errata IDs.

Comment 6 Brad Buckingham 2016-10-25 18:35:22 UTC
Regarding comment 3, it appears that the date rule would be based upon 'start of day' and timezone would be based on the Satellite server.

Comment 7 Peter Vreman 2016-10-26 05:47:55 UTC
Hi brad,

The issue is about the fact that there are the API allows 3 rules types and the UI only 2

API supports:

"Erratum - by Date"
"Erratum - by Date and Type"
"Erratum - by ID"


UI supports:

"Erratum - by Date and Type"
"Erratum - by ID"

As far as i remember the rule type "Erratum - by Date" without the types is also working fine and selects all types.

There are multiple solutions:
- Fix the UI part in case that when the types field is null that it means all types are set.
- API when creating a rule without types field set then use the default value of all types

Peter

Comment 8 Brad Buckingham 2016-10-26 11:33:06 UTC
Hi Peter,

I was actually implementing your second proposed solution:

- API when creating a rule without types field set then use the default value of all types

One additional note, is that if the user provides 'errata_id' the logic will not set 'types' since it is not applicable for those rules.

Comment 9 Brad Buckingham 2016-10-26 11:40:33 UTC
Created redmine issue http://projects.theforeman.org/issues/17108 from this bug

Comment 10 Brad Buckingham 2016-10-26 11:48:14 UTC
Proposed solution in upstream Katello PR: https://github.com/Katello/katello/pull/6410

Comment 14 Walden Raines 2017-08-02 19:20:05 UTC
Verified on 6.3.0 snap 9

Comment 16 Bryan Kearney 2018-02-21 17:30:20 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.

For information on the advisory, and where to find the updated files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:0336