Skip to content
New issue

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

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

Already on GitHub? # to your account

Bug: goss does not detect tcp ports correctly #506

Closed
dschier-wtd opened this issue Nov 29, 2019 · 6 comments
Closed

Bug: goss does not detect tcp ports correctly #506

dschier-wtd opened this issue Nov 29, 2019 · 6 comments

Comments

@dschier-wtd
Copy link

Hi,

during the last days, I was playing a bit with goss. I am facing the situation:

OS = Fedora 31
SELINUX = off
firewalld = off
goss = v0.3.8
$ goss add port 80
Adding Port to './goss.yaml':

tcp:80:
  listening: false
  ip: []

but

[root@ede91ec1d278 /]# ss -tlpn | grep 80
LISTEN    0         0                        *:80                     *:*        users:(("httpd",pid=232,fd=4))

and

[root@ede91ec1d278 /]# goss v
.S

Failures/Skipped:

Port: tcp:80: ip: skipped

Total Duration: 0.006s
Count: 2, Failed: 0, Skipped: 1

Is there something I am doing wrong or can try out to help debgging this behaviour?

@aelsabbahy
Copy link
Member

aelsabbahy commented Nov 29, 2019

I tried testing this on a docker container and failed. I spun up the docker fedora 31 container and ran the following:

$ docker run -it --rm fedora:31 bash

# dnf install httpd iproute net-tools

# httpd -DFOREGROUND &

# curl -I http://localhost:80
HTTP/1.1 403 Forbidden
Date: Fri, 29 Nov 2019 16:05:08 GMT
Server: Apache/2.4.41 (Fedora)
Last-Modified: Thu, 25 Jul 2019 05:18:03 GMT
ETag: "15bc-58e7a8ccdb8c0"
Accept-Ranges: bytes
Content-Length: 5564
Content-Type: text/html; charset=UTF-8

# ss -tlpn
State                           Recv-Q                           Send-Q                                                     Local Address:Port                                                     Peer Address:Port                          LISTEN                          0                                128                                                              0.0.0.0:80                                                            0.0.0.0:*
 users:(("httpd",pid=113,fd=3))

# goss a port 80
Adding Port to './goss.yaml':

tcp:80:
  listening: true
  ip:
  - 0.0.0.0

# netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      113/httpd

# cat /proc/net/tcp
  sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout inode
   0: 00000000:0050 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 414991 1 0000000000000000 100 0 0 10 0
   1: 020011AC:DF8A CEA9D38C:01BB 06 00000000:00000000 03:000003C9 00000000     0        0 0 3 0000000000000000
   2: 020011AC:D002 467CFA40:01BB 06 00000000:00000000 03:00000421 00000000     0        0 0 3 0000000000000000

Goss parses /proc/net/tcp to determine which ports are listening. Can you also send the contents of that.

Are you able to reproduce this on a docker container? If I'm able to reproduce it, I can try to resolve it.

@fbartels
Copy link
Contributor

This is probably a case of ipv4 vs ipv6. While in below example the service was listening on an ipv4 address, on the above example it was listening primarily on ipv6.

@aelsabbahy
Copy link
Member

Does it work with the tcp6 check? doc

@dschier-wtd
Copy link
Author

Hey,
when using tcp6:80: everything works as expected.

# goss v -f tap
1..2
ok 1 - Port: tcp6:80: listening: matches expectation: [true]
ok 2 - Port: tcp6:80: ip: matches expectation: [[]]

Testing is done in podman container with fedora 31 host. Maybe something in the network stack is prioritizing ipv6. From my perspective, this is no longer a bug, but more a low prio feature request for better compatability. 👍

If some other investigation is neeeded, please feel free to reach out to me.

@aelsabbahy
Copy link
Member

Thanks for the update, would it be fair to close this out as a duplicate of this ticket?
#149

@dschier-wtd
Copy link
Author

yup, thanks for the support.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants