Skip to content

Fact "docker": undefined method []' for nil:NilClass on RHEL-8(docker-podman) #749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dusharu opened this issue May 20, 2021 · 6 comments
Closed

Comments

@dusharu
Copy link

dusharu commented May 20, 2021

Describe the Bug

Error in facter when use podman-docker.rpm on RHEL-8

puppet agent -t

Info: Using configured environment 'develop'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Facter: error while resolving custom fact "docker": undefined method `[]' for nil:NilClass  #<--- this ERROR
Info: Caching catalog for prod-bis-mmisc1.scartel.dc
Info: Applying configuration version '1621517818'
Notice: Applied catalog in 8.78 seconds

Expected Behavior

Add support for podman to /opt/puppetlabs/puppet/cache/lib/facter/docker.rb

/opt/puppetlabs/puppet/bin/facter  --custom-dir /opt/puppetlabs/puppet/cache/lib/facter/ docker

# Expected - json with docker info
# in fact -  nothing

Steps to Reproduce

install podman-docker.noarch from repo os-rhel8-appstream
run puppet agent -t
or run /opt/puppetlabs/puppet/bin/facter --custom-dir /opt/puppetlabs/puppet/cache/lib/facter/ -d docker

Environment

  • OS: Red Hat Enterprise Linux release 8.3 (Ootpa)
  • puppet: 5.5.22
  • podman version 2.2.1
  • facter: 3.11.14 (commit 2f05c0b208c0848bc0052ac7abf772754f4b79da)

Additional Context

@dusharu dusharu added the bug label May 20, 2021
@BarnumD
Copy link

BarnumD commented Sep 14, 2021

I'm having similar problems on Windows and Ubuntu after upgrading to 4.1.1 from and older version.

@cswarren
Copy link

cswarren commented Sep 17, 2021

I'm also having this error show up on Centos 7 systems that don't have docker installed. New behavior in 4.1.1.

@github-actions
Copy link

This issue has been marked as stale because it has been open for a while and has had no recent activity. If this issue is still important to you please drop a comment below and we will add this to our backlog to complete. Otherwise, it will be closed in 7 days.

@github-actions github-actions bot added the stale label Apr 26, 2022
@silug
Copy link

silug commented Apr 26, 2022

This appears to have been fixed with #773.

@github-actions github-actions bot removed the stale label Apr 27, 2022
@makewhatis
Copy link

This was broken in a different way for us when going from C7 to C8, 773 did not fix. Looks like in the network inspect json output, podman returns a key for "id" in lowercase, and docker returns "Id", pascal case.

This is where I had to change it, fwiw. I'm sure there is a better way of doing this...so I'm just leaving this for anyone that hits this.

index b7cb379b54..d3a674b0c6 100644
--- a/docker/lib/facter/docker.rb
+++ b/docker/lib/facter/docker.rb
@@ -92,7 +92,12 @@ Facter.add(:docker) do
           docker_network_names.each do |network|
             inspect = JSON.parse(Facter::Util::Resolution.exec("#{docker_command} network inspect #{network}"))
             docker['network'][network] = inspect[0]
-            network_id = docker['network'][network]['Id'][0..11]
+            # support docker and podman. Podman outputs lowercase id
+            if docker['network'][network].key?('id')
+              network_id = docker['network'][network]['id'][0..11]
+            else
+              network_id = docker['network'][network]['Id'][0..11]
+            end

@github-actions
Copy link

Hello! 👋

This issue has been open for a while and has had no recent activity. We've labelled it with attention-needed so that we can get a clear view of which issues need our attention.

If you are waiting on a response from us we will try and address your comments on a future Community Day.

Alternatively, if it is no longer relevant to you please close the issue with a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants