Bug 2126803 - PUT /katello/api/repositories/:id fails when only updating docker_tags_whitelist
Summary: PUT /katello/api/repositories/:id fails when only updating docker_tags_whitelist
Keywords:
Status: ASSIGNED
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Repositories
Version: 6.11.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: wclark
QA Contact: Satellite QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-09-14 12:52 UTC by Evgeni Golov
Modified: 2023-08-14 13:43 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 36669 0 Normal New PUT /katello/api/repositories/:id fails when only updating docker_tags_whitelist 2023-08-10 13:40:05 UTC
Red Hat Issue Tracker SAT-18302 0 None None None 2023-06-12 19:03:30 UTC

Description Evgeni Golov 2022-09-14 12:52:28 UTC
Description of problem: 
In Satellite 6.12 (Katello 4.5) the "docker_tags_whitelist" parameter of a repository is deprecated in favor of include_tags/exclude_tags. Nevertheless I would expect that parameter to work.

Trivial reproducer is something like the following curl call:
# curl -k -d '{"docker_tags_whitelist":["lol"]}' -u admin:changeme -H 'Content-Type: application/json' -X PUT https://localhost/katello/api/repositories/1
{"displayMessage":"Missing values for repository.","errors":["param is missing or the value is empty: repository"]}

This has worked on 6.11 and works in 6.11 if I replace docker_tags_whitelist with include_tags.

The stacktrace in production.log looks like this:
2022-09-14T11:58:11 [I|app|bbbdb6f8] Started PUT "/katello/api/repositories/1" for 127.0.0.1 at 2022-09-14 11:58:11 +0000
2022-09-14T11:58:11 [I|app|bbbdb6f8] Processing by Katello::Api::V2::RepositoriesController#update as */*
2022-09-14T11:58:11 [I|app|bbbdb6f8]   Parameters: {"docker_tags_whitelist"=>["lol"], "api_version"=>"v2", "id"=>"1", "repository"=>{}}
2022-09-14T11:58:11 [I|app|bbbdb6f8] Authorized user admin(Admin User)
2022-09-14T11:58:11 [E|app|bbbdb6f8] ActionController::ParameterMissing: param is missing or the value is empty: repository
 bbbdb6f8 | /usr/share/gems/gems/actionpack-6.0.4.7/lib/action_controller/metal/strong_parameters.rb:462:in `require'
 bbbdb6f8 | /usr/share/gems/gems/katello-4.5.0.6/app/controllers/katello/api/v2/repositories_controller.rb:534:in `repository_params'
 bbbdb6f8 | /usr/share/gems/gems/katello-4.5.0.6/app/controllers/katello/api/v2/repositories_controller.rb:345:in `update'


Version-Release number of selected component (if applicable):
rubygem-katello-4.5.0.6-1.el8sat.noarch
satellite-6.12.0-2.el8sat.noarch


How reproducible:
100%

Steps to Reproduce:
1. hammer product create --name lol --organization "Default Organization"
2. hammer repository create --name lol --content-type docker --product lol --organization "Default Organization"
3. curl -k -d '{"docker_tags_whitelist":["lol"]}' -u admin:changeme -H 'Content-Type: application/json' -X PUT https://localhost/katello/api/repositories/1

Actual results:
{"displayMessage":"Missing values for repository.","errors":["param is missing or the value is empty: repository"]}

Expected results:
Repository updated

Additional info:
This still works via hammer (hammer -d repository update --name lol --product lol --organization "Default Organization" --docker-tags-whitelist lol) because hammer for some (unnecessary) reason sends a slightly different payload {"name":"lol", "docker_tags_whitelist":["lol"]} and that gets accepted by the API.

Comment 2 wclark 2023-08-10 13:40:04 UTC
Created redmine issue https://projects.theforeman.org/issues/36669 from this bug

Comment 3 wclark 2023-08-10 15:48:28 UTC
I couldn't reproduce this upstream, when I tried the curl command I got the below payload in rails console:

11:12:08 rails.1   | 2023-08-10T11:12:08 [I|app|c87995fd]   Parameters: {"docker_tags_whitelist"=>["lol"], "api_version"=>"v2", "id"=>"1", "repository"=>{"docker_tags_whitelist"=>["lol"]}}

I'll try to reproduce it on Satellite 6.13 in a bit... if it still exists there, I'll figure out what commit fixes it so we can cherry-pick as necessary.

Comment 4 Evgeni Golov 2023-08-10 18:04:49 UTC
I can't get the error on upstream 4.9 either, but I am also not seeing the whitelist being set in the "include_tags" variable.

Same with hammer!

hammer -d repository update --name lol --product lol --organization "Default Organization" --docker-tags-whitelist WHAT -- succeeds
hammer repository info --name lol --product lol --organization "Default Organization" -- doesn't show any "Container Image Tags Filter"

Comment 5 wclark 2023-08-10 20:01:43 UTC
Interesting. I got the same behavior on Satellite 6.13:

The PUT request succeeds, but within that response we have... "docker_tags_whitelist":[],"include_tags":[],"exclude_tags":["*-source"]

And the log:

==> /var/log/foreman/production.log <==
2023-08-10T19:49:39 [I|app|0edf6255] Started PUT "/katello/api/repositories/1" for ::1 at 2023-08-10 19:49:39 +0000
2023-08-10T19:49:39 [I|app|0edf6255] Processing by Katello::Api::V2::RepositoriesController#update as */*
2023-08-10T19:49:39 [I|app|0edf6255]   Parameters: {"docker_tags_whitelist"=>["lol"], "api_version"=>"v2", "id"=>"1", "repository"=>{"docker_tags_whitelist"=>["lol"]}}
2023-08-10T19:49:39 [I|app|0edf6255] Authorized user admin(Admin User)
2023-08-10T19:49:39 [I|bac|0edf6255] Task {label: , execution_plan_id: fd227d59-c9c4-48d4-9fcc-906e59b40de8} state changed: pending 
2023-08-10T19:49:39 [I|bac|0edf6255] Task {label: Actions::Katello::Repository::Update, id: eee45a84-ce3e-4eff-baad-4bd3ed1a9480, execution_plan_id: fd227d59-c9c4-48d4-9fcc-906e59b40de8} state changed: planning 
2023-08-10T19:49:39 [I|aud|0edf6255] Katello::RootRepository (1) update event on docker_tags_whitelist , lol
2023-08-10T19:49:39 [I|bac|0edf6255] Task {label: Actions::Katello::Repository::Update, id: eee45a84-ce3e-4eff-baad-4bd3ed1a9480, execution_plan_id: fd227d59-c9c4-48d4-9fcc-906e59b40de8} state changed: planned 
2023-08-10T19:49:39 [I|bac|0edf6255] Task {label: Actions::Katello::Repository::Update, id: eee45a84-ce3e-4eff-baad-4bd3ed1a9480, execution_plan_id: fd227d59-c9c4-48d4-9fcc-906e59b40de8} state changed: running 
2023-08-10T19:49:39 [I|bac|0edf6255] Task {label: Actions::Katello::Repository::Update, id: eee45a84-ce3e-4eff-baad-4bd3ed1a9480, execution_plan_id: fd227d59-c9c4-48d4-9fcc-906e59b40de8} state changed: stopped  result: success
2023-08-10T19:49:39 [I|app|0edf6255]   Rendered /usr/share/gems/gems/katello-4.7.0.23/app/views/katello/api/v2/repositories/show.json.rabl within katello/api/v2/layouts/resource (Duration: 65.5ms | Allocations: 18753)
2023-08-10T19:49:39 [I|app|0edf6255]   Rendered layout /usr/share/gems/gems/katello-4.7.0.23/app/views/katello/api/v2/layouts/resource.json.erb (Duration: 66.5ms | Allocations: 19020)
2023-08-10T19:49:39 [I|app|0edf6255] Completed 200 OK in 755ms (Views: 50.7ms | ActiveRecord: 80.4ms | Allocations: 89146)


Out of curiosity, I tried with '{"include_tags": ["lol"]}' instead, and the result is different... "docker_tags_whitelist":["lol"],"include_tags":["lol"],"exclude_tags":["*-source"]

Comment 6 Evgeni Golov 2023-08-11 05:40:46 UTC
I think that made it worse?

The reported behaviour is "if I pass this deprecated param, it fails with a stupid error", now it's "if I pass this deprecated param, it's silently discarded and the system pretends success"


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