Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 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 "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". 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 "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-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 1576285

Summary: atomic uninstall command to remove ipa-server returns error "'NoneType' object has no attribute 'gen_cmd'"
Product: Red Hat Enterprise Linux 7 Reporter: Nikhil Dehadrai <ndehadra>
Component: atomicAssignee: Giuseppe Scrivano <gscrivan>
Status: CLOSED CURRENTRELEASE QA Contact: atomic-bugs <atomic-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.5CC: bbaude, ddarrah, dwalsh, ksiddiqu, lsm5, pvoborni, slaznick, weshen
Target Milestone: rcKeywords: Extras
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: atomic-1.22.1-4.git1895984.el7_5 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-05-05 14:49:36 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:

Description Nikhil Dehadrai 2018-05-09 07:18:38 UTC
Description of problem:
On running "atomic uninstall --name <container-name> rhel7/ipa-server" command to uninstall ipa-server without first stopping the container, then it returns  error "'NoneType' object has no attribute 'gen_cmd'"

Version-Release number of selected component (if applicable):
ipa-server-docker-image: ipa-server-docker-4.5.4-5
atomic-host-version:  Version: 7.5.1 (2018-04-19 14:39:11)


How reproducible:
Allways

Steps to Reproduce:
1. Setup Atomic host ( in my case Version: 7.5.1 (2018-04-19 14:39:11))
2. Pull the latest IPA-server docker image for RHEL 7.5up1. (in my case ipa-server-docker-4.5.4-5)
3. Setup ipa-server using this image
4. Now without stopping the container, directly run command:
# atomic uninstall --name <container-name> rhel7/ipa-server



Actual results:
1. After step4, following error is received

'NoneType' object has no attribute 'gen_cmd'


Expected results:
No error message should be received and and ipa-server should be stopped automatically and uninstalled successfully.

Additional info:
1. From above steps, after step3 when container is first stopped and then ipa-server is uninstalled, then it is uninstalled successfully without any error message.

root@ipadocker ~]# atomic uninstall --name ipadocker rhel7/ipa-server
docker run --rm --privileged -v /:/host -e HOST=/host -e DATADIR=/var/lib/ipadocker rhel7/ipa-server /bin/uninstall.sh
Moved [/var/lib/ipadocker] aside to [/var/lib/ipadocker.backup.20180502-075958].

2. When the same steps are performed for older image for ipa-server-docker RHEL 7.5, then no error message is observed using same atomic host, but it did not stop the container.

[root@ipadocker ~]# atomic uninstall --name ipadocker rhel7/ipa-server
docker run --rm --privileged -v /:/host -e HOST=/host -e DATADIR=/var/lib/ipadocker rhel7/ipa-server /bin/uninstall.sh
Moved [/var/lib/ipadocker] aside to [/var/lib/ipadocker.backup.20180509-065452].
[root@ipadocker ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
b9d6b00f0206        rhel7/ipa-server1   "/usr/local/sbin/init"   24 minutes ago      Up 24 minutes                           ipadocker1
[root@ipadocker ~]#

Comment 3 Giuseppe Scrivano 2018-05-10 16:47:24 UTC
This PR fixes the issue, I could reproduce it locally:

https://github.com/projectatomic/atomic/pull/1235

Comment 7 Nikhil Dehadrai 2018-06-19 04:30:53 UTC
Atomic host Version:
● ostree://rhel75:rhel-atomic-host/7/x86_64/standard
                   Version: 7.5.2 (2018-06-09 02:40:55)



Tested the bug with following observations:

Scenario-1. 
-------------------
When Container is not stopped and 'atomic uninstall' command is run, the error mentioned is not observed, but the uninstallation isn't clean as it does not create the backup copy at path '/var/lib'. (See output in scenario-2)

[root@ipadocker ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
d21c518ee411        rhel7/ipa-server    "/usr/local/sbin/init"   17 hours ago        Up 17 hours                             ipadocker

[root@ipadocker ~]# docker exec -it ipadocker kinit admin
Password for admin: 

[root@ipadocker ~]# docker exec -it ipadocker rpm -q ipa-server
ipa-server-4.5.4-10.el7_5.2.x86_64

[root@ipadocker ~]# atomic uninstall --name ipadocker rhel7/ipa-server
docker stop ipadocker
ipadocker

[root@ipadocker ~]# ls -l /var/lib/ipadocker/
total 20
-rw-r--r--.  1 root root   37 Jun 11 05:56 build-id
-rw-r--r--.  1 root root   41 Jun 18 06:01 docker-run-opts
drwxr-xr-x. 15 root root 4096 Jun 18 06:12 etc
-rw-r--r--.  1 root root   22 Jun 18 06:01 hostname
drwxr-xr-x.  3 root root   59 Jun 18 06:12 root
drwxr-xr-x.  3 root root   19 Jun 11 05:56 usr
drwxr-xr-x.  6 root root   57 Jun 11 05:56 var
-rw-r--r--.  1 root root    4 Jun 18 06:12 volume-version

[root@ipadocker ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES


Scenario-2
-----------------
When Container is stopped and then 'atomic uninstall' command is run, the error mentioned is not observed, but the uninstallation process is complete with the backup copy at path '/var/lib'.

[root@ipadocker ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS               NAMES
f6badcd01aba        rhel7/ipa-server    "/usr/local/sbin/init"   About a minute ago   Up About a minute                       ipadocker

[root@ipadocker ~]# docker stop ipadocker
ipadocker

[root@ipadocker ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

[root@ipadocker ~]# atomic uninstall --name ipadocker rhel7/ipa-server
docker run --rm --privileged -v /:/host -e HOST=/host -e DATADIR=/var/lib/ipadocker rhel7/ipa-server /bin/uninstall.sh
Moved [/var/lib/ipadocker] aside to [/var/lib/ipadocker.backup.20180619-042114].

[root@ipadocker ~]# ls -l /var/lib/ipadocker.backup.20180619-042114/
total 20
-rw-r--r--.  1 root root   37 Jun 11 05:56 build-id
-rw-r--r--.  1 root root   41 Jun 18 06:01 docker-run-opts
drwxr-xr-x. 15 root root 4096 Jun 18 06:12 etc
-rw-r--r--.  1 root root   22 Jun 18 06:01 hostname
drwxr-xr-x.  3 root root   59 Jun 18 06:12 root
drwxr-xr-x.  3 root root   19 Jun 11 05:56 usr
drwxr-xr-x.  6 root root   57 Jun 11 05:56 var
-rw-r--r--.  1 root root    4 Jun 18 06:12 volume-version


There needs to be consistency in the output / behaviour of the command when run across different scenarios, thus on the basis of above observation changing status to 'ASSIGNED'.

Comment 8 Giuseppe Scrivano 2018-06-19 09:21:24 UTC
I think the INSTALL label in the image must be fixed for the second scenario to work:

"install": "docker run -ti --rm --privileged -v /:/host -e HOST=/host -e DATADIR=/var/lib/${NAME} -e NAME=${NAME} -e IMAGE=${IMAGE} ${IMAGE} /bin/install.sh"

If there is an `--rm` in the install label then the container is automatically deleted by Docker on a "stop" thus there is no container left after it is stopped.

Comment 9 Giuseppe Scrivano 2018-06-19 10:26:46 UTC
nevermind my last comment, it is a bug in atomic that I am looking into..

Comment 10 Giuseppe Scrivano 2018-06-19 10:56:07 UTC
Could you check if https://github.com/projectatomic/atomic/pull/1242 fixes the issue you have reported?

Comment 15 Edward Shen 2018-09-12 14:15:53 UTC
I tested this on atomic host installing latest atomic rpm, this bug seems not fixed, I got the same result as Nikhil had in Comment 7.
Versions:
[root@atomic-00 cloud-user]# rpm -q atomic
atomic-1.22.1-25.git5a342e3.el7.x86_64

root@atomic-00 cloud-user]# atomic host status
State: idle; auto updates disabled
Deployments:
● ostree://rhel-atomic-host-ostree:rhel-atomic-host/7/x86_64/standard
                   Version: 7.5.2 (2018-06-09 02:40:55)
                    Commit: db4a302e874cdd9cc9517a63133cfdf05e23cb684faae166b444c74cf7c146e8
                  Unlocked: hotfix

  ostree://rhel-atomic-host-ostree:rhel-atomic-host/7/x86_64/standard
                   Version: 7.5.2 (2018-06-09 02:40:55)
                    Commit: db4a302e874cdd9cc9517a63133cfdf05e23cb684faae166b444c74cf7c146e8



Basically, I follow the guide[1] to set up the environment:

Scenario-1, uninstall without stop the container:
————————————————
1. pull the latest ipa-server image
2. atomic install --name server-container rhel7/ipa-server publish --hostname $hostname ipa-server-install --ip-address 2001:DB8::1111
3. atomic run --name server-container rhel7/ipa-server
4. On another terminal: 
    1. docker exec -it server-container kinit admin
    2. atomic uninstall --name server-container rhel7/ipa-server

Expect:
The container can be stopped, and the backup copy should be created.

Actual result:
If I execute the uninstall command once, the container can be stopped but the backup copy can NOT be created. But if I execute it again, the backup copy can be created:
[root@atomic-00 cloud-user]# atomic uninstall --name server-container rhel7/ipa-server
docker stop server-container
server-container

[root@atomic-00 cloud-user]# atomic uninstall --name server-container rhel7/ipa-server
docker run --rm --privileged -v /:/host -e HOST=/host -e DATADIR=/var/lib/server-container rhel7/ipa-server /bin/uninstall.sh
Moved [/var/lib/server-container] aside to [/var/lib/server-container.backup.20180912-132434].

Scenario-2, uninstall after stop the container:
———————————————————
Uninstall command can successfully stop the container and create the backup copy.
[root@atomic-00 cloud-user]# atomic uninstall --name server-container rhel7/ipa-server
docker run --rm --privileged -v /:/host -e HOST=/host -e DATADIR=/var/lib/server-container rhel7/ipa-server /bin/uninstall.sh
Moved [/var/lib/server-container] aside to [/var/lib/server-container.backup.20180912-140031].


[1] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html-single/using_containerized_identity_management_services/index#using-the-ipa-server-container

Comment 17 Giuseppe Scrivano 2018-09-18 20:39:15 UTC
I think the patch didn't get into a build yet.  I've tried to reproduce locally but I see the uninstall label is honored with the latest version from git:

$ sudo ./atomic uninstall --name ipa-server registry.access.redhat.com/rhel7/ipa-server 
docker stop ipa-server
ipa-server
docker run --rm --privileged -v /:/host -e HOST=/host -e DATADIR=/var/lib/ipa-server registry.access.redhat.com/rhel7/ipa-server /bin/uninstall.sh
Moved [/var/lib/ipa-server] aside to [/var/lib/ipa-server.backup.20180918-203618].
Unable to find 1650979e359c2398d43a03b8c3b053c2e09a9a75387d51bd6530040fa16a9d3f in the installed containers

Would it be possible for you to try with the git version?

Comment 19 Edward Shen 2018-11-16 10:15:34 UTC
I'm afraid the patch is still not going into the build?
I do the same test for atomic-1.22.1-26.gitb507039.el7.x86_64 as Comment 15, and I have the same result too. It doesn't work.
Then I try the git version as Giuseppe recommended, this issue is not seen. Any ideas, Fero?

Comment 21 Frantisek Kluknavsky 2018-11-21 12:10:34 UTC
Hi,

the patch says:
diff --git a/Atomic/backends/_docker.py b/Atomic/backends/_docker.py
index 6030078..56d7a80 100644
--- a/Atomic/backends/_docker.py
+++ b/Atomic/backends/_docker.py
@@ -455,7 +455,6 @@ class DockerBackend(Backend):
             # have deleted it
             if self.has_container(name):
                 self.delete_container(con_obj.id)
-            return
 
         if args.force:
             self.delete_containers_by_image(iobject, force=True)



Looking at the code in the built package atomic-1.22.1-26.gitb507039.el7.x86_64.rpm, the little "return" statement is indeed missing and thus the patch is applied and the issue is supposed to be fixed. Maybe it is time to admit that the fix may not fix the supposed-to-be-fixed fixable issue and that we have a problem somewhere.

First idea: Please check the code you are running whether it has the patch applied. It is in /usr/lib/python2.7/site_packages/Atomic/backends/_docker.py

Second idea: The rpm does not work but the git version does, what exactly is the difference between them? Maybe we have a packaging problem?

Comment 22 Edward Shen 2018-11-23 10:09:55 UTC
Yes, the patch is applied. I change a server to test this again. This issue is not seen either for the atomic rpm or github source code. Probably there was some files I messed up on the first machine I had. Sorry about this. I make it verified now.