Skip to content
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

Error loading config: undefined method `unsafe_load' for Psych:Module #2769

Closed
mdiunip opened this issue Apr 26, 2023 · 31 comments · Fixed by #2813 or #2809
Closed

Error loading config: undefined method `unsafe_load' for Psych:Module #2769

mdiunip opened this issue Apr 26, 2023 · 31 comments · Fixed by #2813 or #2809
Assignees

Comments

@mdiunip
Copy link

mdiunip commented Apr 26, 2023

Hi, i get repeated errors loading config when i start the image i built of 0.29.1.

✔ Container oxidized Created 0.0s
Attaching to oxidized
oxidized | *** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
oxidized | *** Running /etc/my_init.d/10_syslog-ng.init...
oxidized | Apr 26 11:54:18 076ea1cf96d2 syslog-ng[14]: syslog-ng starting up; version='3.35.1'
oxidized | *** Booting runit daemon...
oxidized | *** Runit started as PID 22
oxidized | Apr 26 11:54:19 076ea1cf96d2 cron[28]: (CRON) INFO (pidfile fd = 3)
oxidized | Apr 26 11:54:19 076ea1cf96d2 cron[28]: (CRON) INFO (Running @reboot jobs)
oxidized | Error loading config: undefined method 'unsafe_load' for Psych:Module
oxidized | Did you mean? safe_load
oxidized | Error loading config: undefined method 'unsafe_load' for Psych:Module
oxidized | Did you mean? safe_load

@yoakim
Copy link

yoakim commented Apr 26, 2023

What a coincidence, I happened to have the exact same problem today when running my docker container.

After some digging unsafe_load seem to be added to the Psych library in version 3.3.2.
However, the Psych version installed in my container was 3.3.0.

unsafe_load is used in the asetus library since version 0.4.0.

So either you knock asetus down to 0.3.0 or bump Psych up to > 3.3.2, i did the latter and it worked.

inside oxidized.gemspec:

s.add_runtime_dependency 'psych', '~> 3.3.2'

Note:
I have no idea if this is the best workaround, but it works :)

@mdiunip
Copy link
Author

mdiunip commented Apr 26, 2023

Awesome! Thank you so much!

@runeka
Copy link

runeka commented Apr 27, 2023

Thank you!
gem install psych -v 3.3.2 solves the issue if not running in container.

@andrewburke1
Copy link

Thank you.

I'm running this in a docker container and this change resolved the "unsafe_load" from the psych module error.

@aschaber1 aschaber1 self-assigned this Apr 27, 2023
@jsofari
Copy link

jsofari commented May 5, 2023

Thank you! gem install psych -v 3.3.2 solves the issue if not running in container.

Work in ubuntu if not running docker thanks

@K4S1
Copy link

K4S1 commented May 9, 2023

Hi,

Will there be a fix on the docker container it-self ?
Cause I didn't get the fix the work.
Maybe my doing something wrong. but tried to add the line.
s.add_runtime_dependency 'psych', '~> 3.3.2'
in the oxidized container file :
/var/lib/gems/3.0.0/gems/oxidized-0.29.1/oxidized.gemspec
rebooted the container and still the docker logs oxidized are stating

*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/10_syslog-ng.init...
May  9 06:38:59 cd31cc44ed42 syslog-ng[13]: syslog-ng starting up; version='3.35.1'
*** Booting runit daemon...
*** Runit started as PID 23
May  9 06:39:00 cd31cc44ed42 cron[31]: (CRON) INFO (pidfile fd = 3)
May  9 06:39:00 cd31cc44ed42 cron[31]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
Error loading config: undefined method `unsafe_load' for Psych:Module
Did you mean?  safe_load
Error loading config: undefined method `unsafe_load' for Psych:Module
Did you mean?  safe_load

I tried to install manually:

root@cd31cc44ed42:/# gem install psych -v 3.3.2
Building native extensions. This could take a while...
ERROR:  Error installing psych:
	ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/3.0.0/gems/psych-3.3.2/ext/psych
/usr/bin/ruby3.0 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20230509-149-djnqem.rb extconf.rb
checking for yaml.h... no
checking for _WIN32... no
checking for dlfcn.h... yes
checking for inttypes.h... yes
checking for memory.h... yes
checking for stdint.h... yes
checking for stdlib.h... yes
checking for strings.h... yes
checking for string.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for yaml.h... yes
checking for config.h... yes
creating Makefile

current directory: /var/lib/gems/3.0.0/gems/psych-3.3.2/ext/psych
make DESTDIR\= clean
current directory: /var/lib/gems/3.0.0/gems/psych-3.3.2/ext/psych
make DESTDIR\=
make failedNo such file or directory - make

Gem files will remain installed in /var/lib/gems/3.0.0/gems/psych-3.3.2 for inspection.
Results logged to /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/psych-3.3.2/gem_make.out
root@cd31cc44ed42:/#

But getting errors I'm not sure how to fix.
Have read that some are pointing to updating the ruby version.
But would that not break the rest of the setup:
sudo gem update --system

Anyone has some pointers

Thanks.

@K4S1
Copy link

K4S1 commented May 9, 2023

Finally understood the error on
make failedNo such file or directory - make
Sorry for my limit understanding on ruby.

on container :

docker exec -it oxidized /bin/bash
root@eef882eba7f0:/# apt update
root@eef882eba7f0:/# apt install make
root@eef882eba7f0:/# gem install psych -v 3.3.2
   Building native extensions. This could take a while...
   Successfully installed psych-3.3.2
   Parsing documentation for psych-3.3.2
   Installing ri documentation for psych-3.3.2
   Done installing documentation for psych after 0 seconds
   1 gem installed
root@eef882eba7f0:/#

It is ofcause only a workaround, cause if rebuilding the container error will return.

Compose:

  oxidized:
    restart: always
    image: oxidized/oxidized:latest
    container_name: oxidized
    ports:
      - target: 8888
        published: 8888
        protocol: tcp
    environment:
      CONFIG_RELOAD_INTERVAL: 600
    volumes:
      - "./oxidized/config:/home/oxidized/.config/oxidized"
    labels:
      - "diun.enable=true"

@aschaber1 will this be marked as a bug ?

@mdiunip
Copy link
Author

mdiunip commented May 9, 2023

@K4S1 please clone git repo, edit the file oxidized.gemspec as pointed by @yoakim, than build the image, and finally recreate container.

Example:

git clone https://github.com/ytti/oxidized ./oxidized-latest
vi ./oxidized-latest/oxidized.gemspec
docker build -t oxidized/oxidized:latest ./oxidized-latest
docker compose up -d

@K4S1
Copy link

K4S1 commented May 9, 2023

Thanks @mdiunip. will test out.
But I will properly just downgrade the container to the problem is fixed.

@mikegleasonjr
Copy link

This piece of software is the most unstable in my whole stack.. really surprised someone could use that in a production environment..

There are no tests for the Docker box?

loading config: undefined method `unsafe_load' for Psych:Module

@mikegleasonjr
Copy link

Also the fact that there is no sematic versionning makes it even more a pain.. only latest on the Docker image?

@K4S1
Copy link

K4S1 commented May 9, 2023

@mikegleasonjr, Guess that you can use tag "0.29.1"
https://hub.docker.com/r/oxidized/oxidized/tags
Have not have time to test my self yet, sorry.

Well it's always a risk running with latest.
But would be nice with a "stable" tag

But to be fair its a great product that are maintained by quite few people, but a pretty supportive community, I'm not complaining.

@aschaber1
Copy link
Collaborator

Hey,
we're really trying to get reliability back on track. Releasing code that accumulated over 3 years will always unfortunately come with issues.

From what I see this will be closed with the next release that contains updated dependencies. asetus is still an old version in 0.29.1 .

@mikegleasonjr
Copy link

Hi, sorry for my rather direct message earlier, it seems we started tagging the docker boxes recently, that's amazing, will update my environment...

Thanks for the work being done on the project

@rhythmtone rhythmtone mentioned this issue May 10, 2023
@falkheiland
Copy link

falkheiland commented May 10, 2023

just as an info for people running into that as well (anything >=0.29 not working) , a downgrade to 0.25.0 is still possible:

  • downgrade to oxidized/oxidized:0.25.0
  • edit compose file and config to reflect: /home/oxidized -> ~/.config/oxidized/ or /root/.config/oxidized/

also thx for all the work to all involved here !

udienz added a commit to udienz/oxidized that referenced this issue May 16, 2023
add psych dependency, will solve ytti#2769
@jamess60
Copy link

jamess60 commented May 24, 2023

Hi all
Im having a similar issue using the :latest container. (first reported in #2805 )

I tried doing apt update && apt install make -y && gem install psych -v 3.3.2 or gem install asetus -v 0.3.0 or both in the container shell and restarting, I now get this output:

2023-05-24 08:57:46 I, [2023-05-24T06:57:46.902616 #136] INFO -- : Oxidized starting, running as pid 136
2023-05-24 08:57:46 I, [2023-05-24T06:57:46.906550 #136] INFO -- : lib/oxidized/nodes.rb: Loading nodes
2023-05-24 08:57:46 I, [2023-05-24T06:57:46.907128 #136] INFO -- : lib/oxidized/nodes.rb: Loaded 0 nodes
2023-05-24 08:57:46 F, [2023-05-24T06:57:46.907263 #136] FATAL -- : Oxidized crashed, crashfile written in /home/oxidized/.config/oxidized/crash
2023-05-24 08:57:46 source returns no usable nodes

The contents of the crash file is:

2023-05-24 06:58:14 UTC
source returns no usable nodes [Oxidized::Core::NoNodesFound]
/var/lib/gems/3.0.0/gems/oxidized-0.29.1/lib/oxidized/core.rb:15:in initialize' /var/lib/gems/3.0.0/gems/oxidized-0.29.1/lib/oxidized/core.rb:4:in new'
/var/lib/gems/3.0.0/gems/oxidized-0.29.1/lib/oxidized/core.rb:4:in new' /var/lib/gems/3.0.0/gems/oxidized-0.29.1/lib/oxidized/cli.rb:13:in run'
/var/lib/gems/3.0.0/gems/oxidized-0.29.1/bin/oxidized:8:in <top (required)>' /usr/local/bin/oxidized:25:in load'
/usr/local/bin/oxidized:25:in `

'

I have verified that the container can read the router.db (currently empty) and the config file so its not a volume mapping issue - any ideas?

@yoakim
Copy link

yoakim commented May 24, 2023

Hi all Im having a similar issue using the :latest container. (first reported in #2805 )

I tried doing apt update && apt install make -y && gem install psych -v 3.3.2 or gem install asetus -v 0.3.0 or both in the container shell and restarting, I now get this output:

2023-05-24 08:57:46 I, [2023-05-24T06:57:46.902616 #136] INFO -- : Oxidized starting, running as pid 136 2023-05-24 08:57:46 I, [2023-05-24T06:57:46.906550 #136] INFO -- : lib/oxidized/nodes.rb: Loading nodes 2023-05-24 08:57:46 I, [2023-05-24T06:57:46.907128 #136] INFO -- : lib/oxidized/nodes.rb: Loaded 0 nodes 2023-05-24 08:57:46 F, [2023-05-24T06:57:46.907263 #136] FATAL -- : Oxidized crashed, crashfile written in /home/oxidized/.config/oxidized/crash 2023-05-24 08:57:46 source returns no usable nodes

The contents of the crash file is:

2023-05-24 06:58:14 UTC source returns no usable nodes [Oxidized::Core::NoNodesFound] /var/lib/gems/3.0.0/gems/oxidized-0.29.1/lib/oxidized/core.rb:15:in initialize' /var/lib/gems/3.0.0/gems/oxidized-0.29.1/lib/oxidized/core.rb:4:in new' /var/lib/gems/3.0.0/gems/oxidized-0.29.1/lib/oxidized/core.rb:4:in new' /var/lib/gems/3.0.0/gems/oxidized-0.29.1/lib/oxidized/cli.rb:13:in run' /var/lib/gems/3.0.0/gems/oxidized-0.29.1/bin/oxidized:8:in <top (required)>' /usr/local/bin/oxidized:25:in load' /usr/local/bin/oxidized:25:in `

'
I have verified that the container can read the router.db (currently empty) and the config file so its not a volume mapping issue - any ideas?

Wait, you router.db is empty on purpose? That would be the problem

@jamess60
Copy link

Hi

Indeed, the router.db was empty. Given there was no example file or syntax to fill it by hand in the README, I (incorrectly) assumed this was handled via the web interface and was populated automatically.

I googled for an example and found this getting started guide which states the syntax is name:ip:model:group, however, after loading the container/running the gem install I get this output:

I, [2023-05-24T09:43:14.456506 #503] INFO -- : Oxidized starting, running as pid 503
I, [2023-05-24T09:43:14.460444 #503] INFO -- : lib/oxidized/nodes.rb: Loading nodes
E, [2023-05-24T09:43:14.469655 #503] ERROR -- : node {:name=>"swlab-test-01", :model=>"192.168.121.91"} is not resolvable, raised Resolv::ResolvError with message 'no address for swlab-test-01'
I, [2023-05-24T09:43:14.469736 #503] INFO -- : lib/oxidized/nodes.rb: Loaded 0 nodes
F, [2023-05-24T09:43:14.469762 #503] FATAL -- : Oxidized crashed, crashfile written in /home/oxidized/.config/oxidized/crash

This would indicate the name:ip:model:group is incorrect. Please can you give me an example entry?

Cheers

@mdiunip
Copy link
Author

mdiunip commented May 24, 2023

@jamess60 I suggest not doing any modification using the container shell.
Maybe do this instead: #2769 (comment)

The router.db entry is defined in the config file:

source:
  default: csv
  csv:
    file: /home/oxidized/.config/oxidized/router.db
    delimiter: !ruby/regexp /:/
    map:
      name: 0
      ip: 1
      model: 2
      username: 3
      password: 4
    vars_map:
      enable: 5

so

name:ip:model:username:password:optional_enable_password

@jamess60
Copy link

I see! Thank you - that worked perfectly.

Would it be possible to update the README to make this a little clearer? In practice its very simple, but without the documentation its not at all obvious.

@mikegleasonjr
Copy link

For me with the latest box I still have the issue:

*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/10_syslog-ng.init...
May 24 10:07:35 oxidized-ix-chart-866bc7d49c-h8c5z syslog-ng[14]: syslog-ng starting up; version='3.35.1'
*** Booting runit daemon...
*** Runit started as PID 22
May 24 10:07:37 oxidized-ix-chart-866bc7d49c-h8c5z cron[28]: (CRON) INFO (pidfile fd = 3)
May 24 10:07:37 oxidized-ix-chart-866bc7d49c-h8c5z cron[28]: (CRON) INFO (Running @reboot jobs)
Error loading config: undefined method `unsafe_load' for Psych:Module
Did you mean?  safe_load
Error loading config: undefined method `unsafe_load' for Psych:Module
Did you mean?  safe_load
Error loading config: undefined method `unsafe_load' for Psych:Module
Did you mean?  safe_load
Error loading config: undefined method `unsafe_load' for Psych:Module
Did you mean?  safe_load
Error loading config: undefined method `unsafe_load' for Psych:Module
Did you mean?  safe_load
Error loading config: undefined method `unsafe_load' for Psych:Module
Did you mean?  safe_load
Error loading config: undefined method `unsafe_load' for Psych:Module
Did you mean?  safe_load
[...]

@K4S1
Copy link

K4S1 commented May 24, 2023

Still not been updated in the docker release.
But see that the

s.add_runtime_dependency 'psych', '~> 3.3.2'

Have been added to gemspec.
So now we see when its being added to release. 🤞

@K4S1
Copy link

K4S1 commented Jun 8, 2023

Hi,

Any News on this issue ?
Found that the official docker again got updates, without this fix.
What is the reason this is not added to latest release?

Have the same issue: 0.29.1-7-g91994e9

Even a pull request waiting:
365dbfd
And hold up because of an changelog conflict, That was linked a week ago :-(

Just me that is confused here

@K4S1
Copy link

K4S1 commented Jun 20, 2023

Hi @aschaber1,

Sorry for calling you out direct, but things seems to have gone stuck.

Do you have any idea when this pull can be added or have there been found another fix ?
#2813

I see that we only need the change.log single line verified.
Do you know who would be able to do so ?

@AndreyPilipenko
Copy link

any updates on it?

@AndreyPilipenko
Copy link

Still have this mistake when I up docker

xidized-oxidized-1 | Error loading config: undefined method unsafe_load' for Psych:Module oxidized-oxidized-1 | Did you mean? safe_load oxidized-oxidized-1 | Error loading config: undefined method unsafe_load' for Psych:Module
oxidized-oxidized-1 | Did you mean? safe_load

@jamess60
Copy link

jamess60 commented Jul 4, 2023

@AndreyPilipenko Try doing apt update && apt install make -y && gem install psych -v 3.3.2 and see if that fixes the issue. If not, sounds like it was closed prematurely?

@AndreyPilipenko
Copy link

@jamess60 yep I've done it inside the container, but this is a bad way to execute it each restart.

@mikegleasonjr
Copy link

mikegleasonjr commented Jul 4, 2023 via email

@jamess60
Copy link

jamess60 commented Jul 4, 2023

@AndreyPilipenko Fully agree - proves that its a single line in the dockerfile away from being resolved then.
@mortzu Are we able to reopen this? Its clearly unresolved

@waja
Copy link

waja commented Jul 5, 2023

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