Bug 1584184 - [RFE] The locked template is getting overridden by default
Summary: [RFE] The locked template is getting overridden by default
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Templates Plugin
Version: 6.4
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: 6.8.0
Assignee: Ondřej Pražák
QA Contact: Jitendra Yejare
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-05-30 12:52 UTC by Jitendra Yejare
Modified: 2020-10-27 12:57 UTC (History)
7 users (show)

Fixed In Version: tfm-rubygem-foreman_templates-8.0.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-10-27 12:57:24 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 24089 0 Normal Closed Improve the usability of lock when importing 2020-10-28 17:14:46 UTC
Red Hat Product Errata RHSA-2020:4366 0 None None None 2020-10-27 12:57:42 UTC

Description Jitendra Yejare 2018-05-30 12:52:50 UTC
Description of problem:
The locked template is getting overridden by default and without setting force option to True.
Interestingly the Locked Template gets unlocked automatically to allow the modification of itself or maybe the new template is getting created.

Version-Release number of selected component (if applicable):
Satellite 6.3.0 snap 5.0

How reproducible:
Always

Steps to Reproduce:
1. Create and import a template from a source
# hammer import-templates --repo localdirectory --filter jack
(I did try with filter and I m not sure how it works without filter)
2. Lock the template
#  hammer template update --id 542 --locked 1
3. Update the template in source but not name.
4. Using hammer try to reimport a template.
hammer import-templates --repo localdirectory --filter jack

Actual results:
1. The template gets updated even though the template is locked
2. The template is unlocked or newly created

Expected results:
1. The template should not be updated by default or without force option when it is locked.
2. The template should not be unlocked or newly created on reimport.

Additional info:

Comment 2 Ondřej Pražák 2018-06-20 08:59:14 UTC
The the update of templates is influenced by 2 settings: force and lock, both are false by default. 'lock' determines whether the imported templates will be locked and prevented from being changed, 'force' determines whether to disregard the template lock and update the template anyway. Note that the template lock is just another template attribute and it can be changed by the options that are used for import.

With that said, steps from comment #1 do not update locked templates. They first unlock the templates (based on default 'lock: false' setting) and then update them. 

If you use the '--lock true' in step 4., then newly created templates will be locked and no existing templates will be updated if they are already locked. If existing templates are unlocked, they will be updated and locked afterwards.

If you use the '--lock true --force true', newly created templates will be locked and all existing will be updated and locked.

Is this behaviour acceptable? Are there any specific changes that you would like to see? Do you think that adding a default option 'do not modify' for lock setting could result in a more expected default behaviour?

Comment 3 Jitendra Yejare 2018-06-20 11:56:39 UTC
Hi ondrej,

What I understand from Lock and Force terms is:

Lock :- 
    For New - Lock the template as soon as the new template is imported
    For Existing Locked and Same name - Don't do anything as its locked untill force is used, keep the template locked
   For Existing Unlocked and Same name - Do update the template regardless of force, and lock the template

Force :-
   For New: NA
   For Existing Locked and Same name - Do update the template, keep locked
   For Existing Unlocked and Same name - NA


But, In this bug,

My template was locked, and on reimporting the template without force option the template was updated. Also the template was unlocked. 

These both behaviors was not accepted in case of locked = True and Force = False.

Comment 4 Ondřej Pražák 2018-06-27 12:18:46 UTC
To sum up the previous discussion:

The behaviour is reproducible as per steps in comment #1. However, it is not bug because the default value for 'lock' option is 'false', which unlocks the template so it can be updated. For various workflows see comment #2.

The fact that this bug was raised shows a possible usability problem. Therefore I would like to turn this into a feature request that would make a locking on import more user friendly, but it may not be ready in 6.4 time frame. Cloning upstream.

Comment 5 Ondřej Pražák 2018-06-27 12:29:07 UTC
Created redmine issue http://projects.theforeman.org/issues/24089 from this bug

Comment 6 Satellite Program 2018-06-28 12:06:54 UTC
Upstream bug assigned to oprazak

Comment 7 Satellite Program 2018-06-28 12:06:57 UTC
Upstream bug assigned to oprazak

Comment 12 Bryan Kearney 2020-02-12 09:01:35 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/24089 has been resolved.

Comment 13 Jitendra Yejare 2020-06-10 14:38:26 UTC
@ondrejk,

I have a query on how does this RFE implemented?

Specifically, I wanted to understand, how does reimporting the "locked template" with some changes in the source template unlocks the template in satellite, updates the changes, and locks back.
In short, I need a correct/sweet path to achieve expected result.


But for me, the expected behavior is working as mentioned in the bug description now.

Comment 14 Ondřej Pražák 2020-06-18 13:57:30 UTC
For updating locked templates, there is 'force import' option.

This RFE extends the lock option for import with additional choices so that the lock attribute on existing templates does not have to be modified.

Comment 15 Jitendra Yejare 2020-06-19 07:23:22 UTC
@oprazak: It would help if you can help understnading these options in detail to verify this RFE -

Options are : 'lock', 'keep_lock_new', 'keep', 'unlock', 'true', 'false', '0', '1'

Comment 16 Ondřej Pražák 2020-06-19 09:50:13 UTC
There are 4 possible options: lock, keep_lock_new, keep, unlock.

0, 1, true and false were kept for backwards compatibility and behave in the same way they used to.

lock is the same as 1 or true - locks all templates
unlock is the same as 0 or false - unlocks all templates
keep_lock_new does not modify the lock for existing templates and locks newly created templates
keep does not modify the lock for existing templates and keeps the newly created templates unlocked

Comment 17 Jitendra Yejare 2020-06-19 11:55:50 UTC
rified!

@Steps for orginal reason of bug:
------------------------
1. Create and import a template from a source
# hammer import-templates --repo localdirectory --filter jack
2. Lock the template
#  hammer template update --id 542 --locked 1
3. Update the template in source but not name.
4. Using hammer try to reimport a template.
hammer import-templates --repo localdirectory --filter jack


Behavior:
----------------------
1. The template is not updated by default or without force option when it is locked.



The RFE is raised for point 2 in expected behavior in Desription of this bug:


Steps for RFE:
------------------
Combinations for options mentioned in comment 16 those are : lock, unlock, keep, keep_lock_new

1. Lock:
- Import new, imports new template as locked  PASS
- Reimport unlocked, reimports template and locks the existing  PASS
- Reimport locked, reimports template and keep locked the existing  PASS

2. Unlock
- Import new, imports new template as unlocked  PASS
- Reimport unlocked, reimports template and keeps unlocked the existing  PASS
- Reimport locked, reimports template and locks the existing  PASS

3. keep_lock_new:
- does not modify the lock(unlocked kept unlocked, locked kept locked) for existing templates and locks newly created templates

4. keep
- does not modify the lock(unlocked kept unlocked, locked kept locked) for existing templates and keeps the newly created templates unlocked

Comment 20 errata-xmlrpc 2020-10-27 12:57:24 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 (Important: Satellite 6.8 release), 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-2020:4366


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