Bug 1243140 - When creating a container, errors from docker are not properly reported to the user
Summary: When creating a container, errors from docker are not properly reported to th...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Container Management
Version: 6.0.4
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: Unspecified
Assignee: Daniel Lobato Garcia
QA Contact: Lukas Pramuk
URL: http://projects.theforeman.org/issues...
Whiteboard:
: 1243394 1318641 1319752 1330570 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-07-14 21:02 UTC by Partha Aji
Modified: 2019-09-26 14:46 UTC (History)
10 users (show)

Fixed In Version: rubygem-foreman_docker-2.0.1.10-1,rubygem-foreman_docker-2.0.1.11-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-27 11:22:15 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 9752 0 Normal Closed When creating a container, errors from docker are not properly reported to the user 2020-03-12 22:00:37 UTC
Foreman Issue Tracker 13231 0 Normal Closed error processing throws an error 2020-03-12 22:00:37 UTC

Description Partha Aji 2015-07-14 21:02:35 UTC
When I create a container with a dupe name, Docker properly responds with a 409 to let me know that it conflicts with another container. However, we're only showing "500 server error".

<pre>
❯     hammer -u admin -p changeme docker container create --name crafty_turing \
      --repository-name centos --tag latest --compute-resource DockerCP --command bash
Docker container created
❯     hammer -u admin -p changeme docker container create --name crafty_turing \
      --repository-name centos --tag latest --compute-resource DockerCP --command "ping google.com"
Could not create the container:
  Error: 500 Internal Server Error
</pre>

We need to show a user friendly error.

Comment 1 Partha Aji 2015-07-14 21:02:35 UTC
Created from redmine issue http://projects.theforeman.org/issues/9752

Comment 3 David Davis 2015-07-14 21:19:45 UTC
Note that the original reproducer case is no longer valid as we're checking in the code now for duplicate container names. Here are some potential reproducer cases that might work:

- Try to create a container with name length greater than max
- Try to create a container with invalid options such as an invalid port
- Try to create a while not having enough disk space
- Try to create a container while docker is stopped

Comment 4 Mike McCune 2015-07-15 17:16:38 UTC
*** Bug 1243394 has been marked as a duplicate of this bug. ***

Comment 5 Bryan Kearney 2015-08-25 18:36:05 UTC
Upstream bug component is Container Management

Comment 6 Mike McCune 2016-04-06 13:11:02 UTC
This bug makes determining configuration errors VERY difficult, for example see this related bug:

https://bugzilla.redhat.com/show_bug.cgi?id=1315276

Comment 7 David Davis 2016-04-06 14:04:29 UTC
Here's a good test:

hammer -u admin -p changeme docker container create  --name crafty_ruting$RANDOM --repository-name "THISREPODOESNTEXISTHAHAHAHAHHAHAHAHAHAHA" --tag latest --compute-resource docker --command "bash"

This will return:

Could not create the container:
  undefined method `save' for nil:NilClass

Should probably be something like "Could not find docker repo".

Comment 8 Brad Buckingham 2016-04-07 13:58:26 UTC
*** Bug 1318641 has been marked as a duplicate of this bug. ***

Comment 9 Brad Buckingham 2016-04-07 14:00:55 UTC
Another scenario where the error is not being properly raised to the user is in https://bugzilla.redhat.com/show_bug.cgi?id=1318641#c14.

Scenario: user has docker compute resource on a remote host; however, that host does not have the bootstrap rpm installed.

Comment 10 Lukas Pramuk 2016-04-08 12:46:58 UTC
Another scenario where the error is not being properly raised to the user is in 
https://bugzilla.redhat.com/show_bug.cgi?id=1319752

Scenario: user has specified an invalid image name during container creation

Comment 11 Lukas Pramuk 2016-04-08 12:47:37 UTC
*** Bug 1319752 has been marked as a duplicate of this bug. ***

Comment 12 Brad Buckingham 2016-04-26 18:49:04 UTC
*** Bug 1330570 has been marked as a duplicate of this bug. ***

Comment 13 Brad Buckingham 2016-04-26 18:51:18 UTC
Another scenario where the error is not properly raised to the user is in bug 1330570.

Scenario: user specified custom Memory size without a unit.

Comment 14 Daniel Lobato Garcia 2016-05-24 08:41:33 UTC
Seems like some of these errors have been fixed already in newer versions of foreman_docker, probably because fog returns these errors properly now. I'll update this comment with results for all of these operations

Creating 2 containers with the "same name" throws the error - ' Conflict. The name "noob" is already in use by container f1cc756a3bc6. You have to remove (or rename) that container to be able to reuse that name. ' now.

Creating container with custom memory size without unit:

Creating container with invalid image name during creation:

Creating container when bootstrap rpm has not been installed in docker host yet:

Comment 15 Daniel Lobato Garcia 2016-05-24 08:57:19 UTC
Creating container with name longer than limit: "Data too long for column 'name'" which I guess is understandable enough

Creating a container with less than 4MB memory: "Minimum memory limit allowed is 4MB" - good enough

Creating container with custom memory size without unit (5000000): works, it defaults to bytes.

Creating a container with invalid image name (adsjkklkx):  does not work, 'undefined method save for nil class'. this one has to be fixed.

Creating container when Docker daemon is stopped: does not work, 'undefined method save for nil class'. this one has to be fixed.

Comment 16 Daniel Lobato Garcia 2016-05-24 12:33:42 UTC
Now under review at https://github.com/theforeman/foreman-docker/pull/165

Comment 17 Bryan Kearney 2016-05-30 10:08:54 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/9752 has been closed

Comment 18 Lukas Pramuk 2016-06-28 11:15:04 UTC
FailedQA.

@satellite-6.2.0-17.0.el7sat.noarch

Still errors are not properly reported, UI fails
I tried to set Container Memory: 512

UI:
(x) Oops, we're sorry but something went wrong undefined method `full_messages' for #<Array:0x007f138df24548>

vs. 


journalctl -feu docker:
----------------------
Jun 28 13:01:39 <docker_host> forward-journal[13456]: time="2016-06-28T13:01:39.529117054+02:00" level=error msg="Handler for POST /v1.16/containers/create?name=busybox_cv2 returned error: Minimum memory limit allowed is 4MB"
Jun 28 13:01:39 <docker_host> forward-journal[13456]: time="2016-06-28T13:01:39.529153302+02:00" level=error msg="Handler for POST /v1.16/containers/create returned error: Minimum memory limit allowed is 4MB"

>>> the error message "Minimum memory limit allowed is 4MB" should propagated to the Satellite UI

Comment 19 Lukas Pramuk 2016-06-28 11:28:00 UTC
Failed with tfm-rubygem-foreman_docker-2.0.1.10-2.el7sat.noarch

...app/models/service/containers.rb:
52:    def pull_image(container)
53:      success = container.compute_resource.  < typo? (dot at the end)

Comment 20 Lukas Pramuk 2016-06-28 11:30:45 UTC
    def pull_image(container)
      success = container.compute_resource.
        create_image(:fromImage => container.repository_pull_url)
      errors << container.compute_resource.errors[:base] unless success
    end

not typo, now it makes sense it's only wrapped on another line

Comment 24 Lukas Pramuk 2016-07-11 11:00:29 UTC
VERIFIED.

@satellite-6.2.0-19.1.el7sat.noarch
tfm-rubygem-foreman_docker-2.0.1.11-1.el7sat.noarch

Tried various container misconfigs to reproduce errors:

UI:
(x) Error: Error creating communicating with Docker. Check the Satellite logs: Conflict. The name "/centos" is already in use by container <HASH>...

(x) Error: Error creating communicating with Docker. Check the Satellite logs: Minimum memory limit allowed is 4MB

(x) Error: Error creating communicating with Docker. Check the Satellite logs: Requested CPUs are not available - requested 89278939793, available: 0-3. 

(x) Error: Error creating communicating with Docker. Check the Satellite logs: No such image: <SAT_FQDN>:5000/default_organization-library-docker_view-docker-fedora:24 ,Error creating communicating with Docker. Check the Satellite logs: No such image: <SAT_FQDN>:5000/default_organization-library-docker_view-docker-fedora:24 ,Error creating communicating with Docker. Check the Satellite logs: No such image: <SAT_FQDN>:5000/default_organization-library-docker_view-docker-fedora:24 ,Error creating communicating with Docker. Check the Satellite logs: No such image: <SAT_FQDN>:5000/default_organization-library-docker_view-docker-fedora:24 


CLI:
Could not create the container:
  Error creating communicating with Docker. Check the Satellite logs: Conflict. The name "/centos" is already in use by container <HASH>. You have to remove (or rename) that container to be able to reuse that name.

Could not create the container:
  Error creating communicating with Docker. Check the Satellite logs: Minimum memory limit allowed is 4MB

Could not create the container:
  Error creating communicating with Docker. Check the Satellite logs: Requested CPUs are not available - requested 89278939793, available: 0-3.

>>> reported errors are no more opaque (undefined method `full_messages')

Comment 25 Bryan Kearney 2016-07-27 11:22:15 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, 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/RHBA-2016:1501


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