Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1933130

Summary: foreman-rake templates:sync task undocumented lock parameter change causes import failure
Product: Red Hat Satellite Reporter: Jason Dickerson <jdickers>
Component: Templates PluginAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED WONTFIX QA Contact: Ondrej Gajdusek <ogajduse>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.8.0CC: jdickers, jredman, mhulan
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-10-28 18:04: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:
Attachments:
Description Flags
Hammer output when importing templates
none
Hammer output when importing changed templates
none
API output when importing templates none

Description Jason Dickerson 2021-02-25 18:24:10 UTC
Description of problem:

The following foreman-rake task no longer works after upgrade from 6.7.4 to 6.8.3:

rake_task = [
        '/usr/sbin/foreman-rake',
        'templates:sync',
        'repo=%s' %(repo),
        'branch=%s' %(branch),
        'verbose=true',
        'dirname=%s' %(subdir),
        'prefix=%s' %(prefix),
        'associate=always',
        'lock=true',
        '--trace',
      ]


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

Satellite 6.8.3


How reproducible:

Consistently

Steps to Reproduce:
1. Configure TemplateSync plugin
2. Run the above foreman-rake task

Actual results:

{:name=>"TEMPLATE",
  :id=>nil,
  :changed=>false,
  :imported=>false,
  :additional_errors=>nil,
  :additional_info=>nil,
  :exception=>
   "ERF42-5723 [Foreman::Exception]: Unknown lock option type, expected one of [\"lock\", \"keep_lock_new\", \"keep\", \"unlock\"], got true",
  :validation_errors=>{},
  :file=>"TEMPLATE.erb",
  :type=>nil,
  :diff=>nil},

Expected results:

The template imports correctly

Additional info:

The only documentation I could find for this rake task is located at:  

https://www.rubydoc.info/gems/foreman_templates/Setting/TemplateSync#lock_types-class_method

It seems the lock parameter used to accept:

lock, keep_lock_new, keep, unlock, true, false, 0, 1

but now only accepts:

lock, keep_lock_new, keep, unlock

The Satellite documentation does not even reference this rake task but instead the templates/import api endpoint.  
The endpoint accepts:

lock, keep_lock_new, keep, unlock, true, false, 0, 1

Also, the rake task does not show up in "foreman-rake -T" but rather in "foreman-rake -AT", 
as it is an uncommented task.  

Workaround:  

specify lock=lock in the foreman-rake task.  

rake_task = [
        '/usr/sbin/foreman-rake',
        'templates:sync',
        'repo=%s' %(repo),
        'branch=%s' %(branch),
        'verbose=true',
        'dirname=%s' %(subdir),
        'prefix=%s' %(prefix),
        'associate=always',
        'lock=lock',
        '--trace',
      ]

Questions:  

Is this foreman-rake templates:sync task to be deprecated?  
Should the documentation be updated?  ie perhaps a deprecation warning?
Should we be using the templates:import api endpoint instead?

Comment 1 Jason Dickerson 2021-02-25 18:39:38 UTC
There is also a hammer command:  

hammer import-templates --associate always --branch MYBRANCH --dirname /mydir --lock true --organization "Default Organization" --prefix "_DEBUG " --repo https://github.com/myrepo --verbose true

This command still accepts the lock=true parameter.

Comment 2 Jason Dickerson 2021-02-25 18:53:29 UTC
The reason we use the foreman-rake templates:sync vs the api endpoint, is for logging and debuging/troubleshooting purposes.  The hammer command and api endpoint to not give details of the sync.  So if there are errors, you really do not know what the error is or where it came from.  

I suspect that the proper way to handle this is to switch to:

hammer import-templates --associate always --branch MYBRANCH --dirname /mydir --lock true --organization "Default Organization" --prefix "_DEBUG " --repo https://github.com/myrepo/mycode.git --verbose true

Comment 4 Jason Dickerson 2021-02-25 19:08:43 UTC
There is also a hammer command:  

hammer import-templates --associate always --branch MYBRANCH --dirname /mydir --lock true --organization "Default Organization" --prefix "_DEBUG " --repo https://github.com/myrepo --verbose true

This command still accepts the lock=true parameter.

Comment 5 Ondřej Pražák 2021-03-18 10:23:48 UTC
The rake task is not mentioned in documentation because it will be removed and CLI/API should be used instead. The new options for lock were added but API and CLI are backwards compatible, so they still accept true/false. Comment#2 mentions that there are not enough details about errors, does '--verbose true' help? Is there any information in particular that is missing in verbose mode?

Comment 8 Ondřej Pražák 2021-03-25 11:39:57 UTC
Created attachment 1766288 [details]
Hammer output when importing templates

Comment 9 Ondřej Pražák 2021-03-25 11:40:49 UTC
Created attachment 1766289 [details]
Hammer output when importing changed templates

Comment 10 Ondřej Pražák 2021-03-25 11:41:24 UTC
Created attachment 1766290 [details]
API output when importing templates

Comment 12 Ondřej Pražák 2021-03-25 11:55:17 UTC
Created redmine issue https://projects.theforeman.org/issues/32207 from this bug

Comment 14 Brad Buckingham 2022-09-02 20:25:18 UTC
Upon review of our valid but aging backlog the Satellite Team has concluded that this Bugzilla does not meet the criteria for a resolution in the near term, and are planning to close in a month. This message may be a repeat of a previous update and the bug is again being considered to be closed. If you have any concerns about this, please contact your Red Hat Account team.  Thank you.

Comment 15 Brad Buckingham 2022-09-02 20:31:56 UTC
Upon review of our valid but aging backlog the Satellite Team has concluded that this Bugzilla does not meet the criteria for a resolution in the near term, and are planning to close in a month. This message may be a repeat of a previous update and the bug is again being considered to be closed. If you have any concerns about this, please contact your Red Hat Account team.  Thank you.

Comment 16 Brad Buckingham 2022-10-28 18:04:20 UTC
Thank you for your interest in Red Hat Satellite. We have evaluated this request, and while we recognize that it is a valid request, we do not expect this to be implemented in the product in the foreseeable future. This is due to other priorities for the product, and not a reflection on the request itself. We are therefore closing this out as WONTFIX. If you have any concerns about this feel free to contact your Red Hat Account Team. Thank you.