quay/mirror-registry

Crash on install

Closed this issue ยท 21 comments

During installation (version 1.1.0) on RHEL8 it fails immediately with this error no matter which command is given:

sudo mirror-registry install 


./panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x6d9092]

goroutine 1 [running]:
github.com/sirupsen/logrus.(*Entry).write(0xc0000d60e0)
	/root/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:279 +0x52
github.com/sirupsen/logrus.(*Entry).log(0xc0000d6070, 0x1, 0xc0000ac300, 0x1e)
	/root/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:251 +0x18b
github.com/sirupsen/logrus.(*Entry).Log(0xc0000d6070, 0xc000000001, 0xc00013fc58, 0x1, 0x1)
	/root/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:293 +0x86
github.com/sirupsen/logrus.(*Logger).Log(0x98afa0, 0x1, 0xc00013fc58, 0x1, 0x1)
	/root/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/logger.go:198 +0x7e
github.com/sirupsen/logrus.(*Logger).Fatal(0x98afa0, 0xc00013fc58, 0x1, 0x1)
	/root/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/logger.go:242 +0x51
github.com/quay/mirror-registry/cmd.getFQDN(0x98c140, 0xc000150100)
	/cli/cmd/utils.go:297 +0x92
github.com/quay/mirror-registry/cmd.init.0()
	/cli/cmd/install.go:81 +0x85

Hi, can you try running the command with the --verbose or -v flag and let us know what the output is? Thank you

Does not work either. Also with -v the same error.

@MartijnStraatman Can you post the verbose logs?

How can I do that. As soon as I enter the command above, it logs only that error.

Huh ok, yeah, the command is bombing out getting the fqdn of your host. Are you able to run hostname -f locally as the same user?

Can you confirm which OS you're running and whether there have been any modifications to /etc/hosts?

No issues on version 1.0.0

I can run hostname -f as the same user

No alterations to /etc/hosts


sudo cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 localhost
sudo cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.5 (Ootpa)

Are you able to cat /etc/hosts without sudo?

That's probably the issue...one of the libraries we use simulates hostname -f and tries to read directly from /etc/hosts. If it can't, it'll fallback to a DNS lookup. https://github.com/Showmax/go-fqdn/blob/7301c3ecaf4b9bc371c36ad304270df20a45918d/fqdn.go#L239

Can you configure your system so your user can read from /etc/hosts?

I will have to reinstall. I will get back to you. Thx

@MartijnStraatman I am getting the same error on install, but my user can cat /etc/hosts. I am also running RHEL 8.5. This is on a VM created from the 8.5 KVM image on the RH download page.

[cloud-user@rhel8-mirror-registry ~]$ ./mirror-registry install -v
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x6d9092]

goroutine 1 [running]:
github.com/sirupsen/logrus.(*Entry).write(0xc0000a4af0)
	/root/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:279 +0x52
github.com/sirupsen/logrus.(*Entry).log(0xc0000a4a80, 0x1, 0xc000020780, 0x1e)
	/root/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:251 +0x18b
github.com/sirupsen/logrus.(*Entry).Log(0xc0000a4a80, 0xc000000001, 0xc0000afc58, 0x1, 0x1)
	/root/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:293 +0x86
github.com/sirupsen/logrus.(*Logger).Log(0x98afa0, 0x1, 0xc0000afc58, 0x1, 0x1)
	/root/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/logger.go:198 +0x7e
github.com/sirupsen/logrus.(*Logger).Fatal(0x98afa0, 0xc0000afc58, 0x1, 0x1)
	/root/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/logger.go:242 +0x51
github.com/quay/mirror-registry/cmd.getFQDN(0x98c140, 0xc0000c0100)
	/cli/cmd/utils.go:297 +0x92
github.com/quay/mirror-registry/cmd.init.0()
	/cli/cmd/install.go:81 +0x85
[cloud-user@rhel8-mirror-registry ~]$ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

Sorry, @'ed the wrong person. @HammerMeetNail

Hmm, ok, we'll see what we can do to recreate this. Will keep you updated.

Encountered similar issue as described here.
Able to run hostname -f, but /etc/hosts was similar to MartijnStraatman's.

However, I can confirm that updating /etc/hosts fixes this issue for me.

After adding in the following:

[user@mirror-registry` ~]$ cat /etc/hosts 
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
xx.xx.xx.xx mirror-registry.example.com

I was able to run mirror-registry --help

Just want to add that I find it odd that even running --help also causes this error, when the command cannot retrieve the host's FQDN.

I think we need some better error case handling here. We shouldn't segfault when unable to read a file but quit with a proper error message instead.

I tested a few more error conditions for this and I think its a bit more clear now

Running on AWS EC2 I found that the permissions for /etc/hosts didn't cause the issue by itself. I changed /etc/hosts to 000 and I could still run, ./mirror-registry --help just fine

I then changed /etc/nsswitch.conf from
hosts: files dns
to
hosts: files

so when I run hostname -f it fails to return the hostname

hostname -f
hostname: Name or service not known

so now that I broke DNS, I get the segfault

sudo ./mirror-registry --help
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x6a972a]

@dmc5179 Can you say a little more? I was thinking it was enough to update the requirements to say that /etc/hosts must be accessible, but it sounds like there might be a little more?

I had this same issue, using a Oracle Linux vm
my /etc/hosts file didn't have any entries for my fqdn. adding a line in
xxx.xxx.xxx.xxx fqdn
install now works as expected

I have hit the same issue on RHEL8, OCP4.10.

The issue was resolved when I set the FQDN and re-run the installer. (Unfortunately I do not have the content of /etc/hosts before setting the FQDN, I'll update this comment if I can get my hands on it).

without FQDN

 $ hostname -f
xxxx-yyy
 $ ./mirror-registry install --targetHostname localhost
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x70f1b2]

goroutine 1 [running]:
github.com/sirupsen/logrus.(*Entry).write(0xc0000ce0e0)
        /remote-source/mirror-registry/app/vendor/github.com/sirupsen/logrus/entry.go:279 +0x52
github.com/sirupsen/logrus.(*Entry).log(0xc0000ce070, 0x1, 0xc0000a2660, 0x1e)
        /remote-source/mirror-registry/app/vendor/github.com/sirupsen/logrus/entry.go:251 +0x18b
github.com/sirupsen/logrus.(*Entry).Log(0xc0000ce070, 0xc000000001, 0xc000161e98, 0x1, 0x1)
        /remote-source/mirror-registry/app/vendor/github.com/sirupsen/logrus/entry.go:293 +0x86
github.com/sirupsen/logrus.(*Logger).Log(0xa00b20, 0x1, 0xc000161e98, 0x1, 0x1)
        /remote-source/mirror-registry/app/vendor/github.com/sirupsen/logrus/logger.go:198 +0x7e
github.com/sirupsen/logrus.(*Logger).Fatal(0xa00b20, 0xc000161e98, 0x1, 0x1)
        /remote-source/mirror-registry/app/vendor/github.com/sirupsen/logrus/logger.go:242 +0x51
github.com/quay/mirror-registry/cmd.getFQDN(0xa01ae0, 0xc000136100)
        /remote-source/mirror-registry/app/cmd/utils.go:297 +0x8c
github.com/quay/mirror-registry/cmd.init.0()
        /remote-source/mirror-registry/app/cmd/install.go:81 +0x85

with FQDN

 $ sudo hostnamectl set-hostname xxx.rhocp.example.com
 $ hostname -f
xxx.rhocp.example.com
 $ sudo ./mirror-registry  ...
# no errors

Just wanted to let everyone know that we're planning on changing the implementation of this. No timeline at the moment, but it should resolve the issues being raised here.

We just merged in a change that should resolve this by using hostname -f. We'll have a release out next week containing the fix.

Should be available in 1.2.7.