Bug 1427905

Summary: spacecmd - problem when system has the name same as another system's ID
Product: Red Hat Satellite 5 Reporter: Lukáš Hellebrandt <lhellebr>
Component: ServerAssignee: Tomáš Kašpárek <tkasparek>
Status: CLOSED CURRENTRELEASE QA Contact: Lukáš Hellebrandt <lhellebr>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: tlestach
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: spacecmd-2.5.0-8-sat Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-06-21 12:14:29 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: 1358815    

Description Lukáš Hellebrandt 2017-03-01 13:46:47 UTC
Description of problem:
In spacecmd commands that allow you to specify a system by its ID, you hit a problem when system A's NAME is same as system B's ID. In that case, you specify system A by its name and you actually get system B, because the number gets evaluated as ID. Example:

# system_lock 1000010053
# system_details 1000010053
Name:          SystemName
System ID:     1000010053
Locked:        True
# system_unlock 1000010053

This would be fine if ID was the ONLY way to specify the system, but you can also use NAME in this call and this becomes ambiguous if you have a system named "1000010053".

Using "search:name:1000010053" does not help either.

How reproducible:
Deterministic

Steps to Reproduce:
1. Have two systems: one with some name and another with name equal to the first system's ID
2. Try to use some call on the second system using its name
3. Observe a call was actually used on the first system

Actual results:
Ambiguos system selection

Expected results:
There should be clear difference between specifying a system by its ID and its name

Comment 1 Lukáš Hellebrandt 2017-03-01 14:45:31 UTC
Furthermore, I do not see possibility of using ID documented anywhere:

<SYSTEMS> can be any of the following:
name
ssm (see 'help ssm')
search:QUERY (see 'help system_search')
group:GROUP
channel:CHANNEL

Comment 2 Tomáš Kašpárek 2017-03-02 12:39:14 UTC
Closing this BZ as duplicate of 1427938 as 1427938 is clearly a subset of this one.

*** This bug has been marked as a duplicate of bug 1427938 ***

Comment 3 Tomáš Kašpárek 2017-03-02 12:39:38 UTC
Of course I meant this one is subset of 1427938.

Comment 4 Tomáš Kašpárek 2017-03-02 13:05:41 UTC
Reopening as this is really a subset of bz#1427938 a bit but there's something more happening inside of this bug.

Comment 5 Tomáš Kašpárek 2017-03-02 13:31:04 UTC
spacewalk.git(master): 8f29dfc3896a12657adcab913a066c07de20371a

Comment 8 Lukáš Hellebrandt 2017-03-07 13:38:51 UTC
After consulting with tkasparek, I am verifying this and making a follow-up bug.

When there is a system with the same name as other system's ID, the user is now asked to solve the problem by renaming or deleting a system and the command exits. No operations should now happen to the wrong system by accident.

However, this did not solve the problem of clearly specifying the system either by ID or by name: if there are some systems where these are the same, you are prevented from making unintended operations but you are also prevented from doing anything at all:

spacecmd {SSM:0}> system_list
1000010005 : 1000010006
1000010006 : 1000010005
spacecmd {SSM:0}> system_details 1000010005
WARNING: Duplicate system profile names found!
WARNING: Please reference systems by ID or resolve the
WARNING: underlying issue with 'system_delete' or 'system_rename'
WARNING: 
WARNING: 1000010005 = 1000010005, 1000010006
spacecmd {SSM:0}> system_delete 1000010005
WARNING: Duplicate system profile names found!
WARNING: Please reference systems by ID or resolve the
WARNING: underlying issue with 'system_delete' or 'system_rename'
WARNING: 
WARNING: 1000010005 = 1000010005, 1000010006
WARNING: No systems to delete
spacecmd {SSM:0}> system_delete search:id:1000010005
WARNING: Duplicate system profile names found!
WARNING: Please reference systems by ID or resolve the
WARNING: underlying issue with 'system_delete' or 'system_rename'
WARNING: 
WARNING: 1000010006 = 1000010006, 1000010005
WARNING: No systems to delete

There is no way whatsoever of doing anything with these systems, even if merely deleting them.