Skip to content

dgram.Listener return error on connection failure#46302

Merged
belimawr merged 10 commits intoelastic:mainfrom
belimawr:37216-fix-udp-input-logs
Sep 10, 2025
Merged

dgram.Listener return error on connection failure#46302
belimawr merged 10 commits intoelastic:mainfrom
belimawr:37216-fix-udp-input-logs

Conversation

@belimawr
Copy link
Contributor

@belimawr belimawr commented Aug 28, 2025

Proposed commit message

The Listener.doRun method previously logged connection failures at a debug level but did not return an error to the caller. This made it difficult for users to understand why a input was not working.

This commit modifies Listener.doRun to return an error when a connection failure occurs and also updates the UDP and Unix inputs to set their status as failed when an error is returned by Listener.Run.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

## Disruptive User Impact
## Author's Checklist

How to test this PR locally

  1. Start netcat to listen on a UDP port

    nc -luvp 3030 &
    
  2. Start sending data to this port using flog

    docker run -it --rm mingrammer/flog -l -d 1 -s 1 | nc -vu localhost 3030
    

    You will start to see some data on your terminal

  3. On another terminal start Filebeat with the following configuration

    filebeat.yaml

    filebeat.inputs:
      - type: udp
        host: 127.0.0.1:3030
    
    output.console:
      enabled: true
    
    logging:
      to_stderr: true
      level: debug
      selectors:
        - "*"

    ./filebeat -e -v
    

    You should see two log error:

    listen udp 127.0.0.1:3030: bind: address already in use

    Input 'udp' failed with: listen udp 127.0.0.1:3030: bind: address already in use

Related issues

## Use cases
## Screenshots
## Logs

The Listener.doRun method previously logged connection failures at a
debug level but did not return an error to the caller. This made it
difficult for users to understand why a input was not working.

This commit modifies Listener.doRun to return an error when a
connection failure occurs and also updates the UDP and Unix inputs to
set their status as failed when an error is returned by Listener.Run.
@belimawr belimawr self-assigned this Aug 28, 2025
@belimawr belimawr added Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team bugfix backport-active-all Automated backport with mergify to all the active branches labels Aug 28, 2025
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Aug 28, 2025
@github-actions
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@belimawr belimawr marked this pull request as ready for review August 28, 2025 22:06
@belimawr belimawr requested a review from a team as a code owner August 28, 2025 22:06
@belimawr belimawr requested review from mauri870 and rdner August 28, 2025 22:06
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@pierrehilbert pierrehilbert requested review from khushijain21 and removed request for rdner August 29, 2025 08:22
@mergify
Copy link
Contributor

mergify bot commented Aug 29, 2025

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b 37216-fix-udp-input-logs upstream/37216-fix-udp-input-logs
git merge upstream/main
git push upstream 37216-fix-udp-input-logs
@belimawr
Copy link
Contributor Author

belimawr commented Sep 3, 2025

The tests have been failing because of our seccomp policy, more details on #46333. Once the fix is merged I'll update this PR.

@mergify
Copy link
Contributor

mergify bot commented Sep 5, 2025

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b 37216-fix-udp-input-logs upstream/37216-fix-udp-input-logs
git merge upstream/main
git push upstream 37216-fix-udp-input-logs
TestLogStatusReporter was starting the Filebeat
command (github.com/elastic/beats/v7/x-pack/filebeat/cmd.Filebeat())
as part of the test, this loaded the default seccomp policy, blocking
system calls needed by subsequent tests like 'pidfd_send_signal'.

This commit fixes the problem by running Filebeat as a sub process,
like all the other integration tests, thus providing the necessary
isolation between tests.
@belimawr belimawr merged commit 46ae121 into elastic:main Sep 10, 2025
49 of 52 checks passed
@github-actions
Copy link
Contributor

@Mergifyio backport 8.18 8.19 9.0 9.1

@mergify
Copy link
Contributor

mergify bot commented Sep 10, 2025

backport 8.18 8.19 9.0 9.1

✅ Backports have been created

Details
mergify bot pushed a commit that referenced this pull request Sep 10, 2025
The Listener.doRun method previously logged connection failures at a
debug level but did not return an error to the caller. This made it
difficult for users to understand why a input was not working.

This commit modifies Listener.doRun to return an error when a
connection failure occurs and also updates the UDP and Unix inputs to
set their status as failed when an error is returned by Listener.Run.

* Add changelog

* Fix log level

* mage check

* double test timeout

* Try using 127.0.0.1 instead of all interfaces

* TestLogStatusReporter run Filebeat as a sub process

TestLogStatusReporter was starting the Filebeat
command (github.com/elastic/beats/v7/x-pack/filebeat/cmd.Filebeat())
as part of the test, this loaded the default seccomp policy, blocking
system calls needed by subsequent tests like 'pidfd_send_signal'.

This commit fixes the problem by running Filebeat as a sub process,
like all the other integration tests, thus providing the necessary
isolation between tests.

(cherry picked from commit 46ae121)

# Conflicts:
#	filebeat/input/unix/input.go
#	x-pack/filebeat/tests/integration/status_reporter_test.go
mergify bot pushed a commit that referenced this pull request Sep 10, 2025
The Listener.doRun method previously logged connection failures at a
debug level but did not return an error to the caller. This made it
difficult for users to understand why a input was not working.

This commit modifies Listener.doRun to return an error when a
connection failure occurs and also updates the UDP and Unix inputs to
set their status as failed when an error is returned by Listener.Run.

* Add changelog

* Fix log level

* mage check

* double test timeout

* Try using 127.0.0.1 instead of all interfaces

* TestLogStatusReporter run Filebeat as a sub process

TestLogStatusReporter was starting the Filebeat
command (github.com/elastic/beats/v7/x-pack/filebeat/cmd.Filebeat())
as part of the test, this loaded the default seccomp policy, blocking
system calls needed by subsequent tests like 'pidfd_send_signal'.

This commit fixes the problem by running Filebeat as a sub process,
like all the other integration tests, thus providing the necessary
isolation between tests.

(cherry picked from commit 46ae121)

# Conflicts:
#	filebeat/input/unix/input.go
#	x-pack/filebeat/tests/integration/status_reporter_test.go
mergify bot pushed a commit that referenced this pull request Sep 10, 2025
The Listener.doRun method previously logged connection failures at a
debug level but did not return an error to the caller. This made it
difficult for users to understand why a input was not working.

This commit modifies Listener.doRun to return an error when a
connection failure occurs and also updates the UDP and Unix inputs to
set their status as failed when an error is returned by Listener.Run.

* Add changelog

* Fix log level

* mage check

* double test timeout

* Try using 127.0.0.1 instead of all interfaces

* TestLogStatusReporter run Filebeat as a sub process

TestLogStatusReporter was starting the Filebeat
command (github.com/elastic/beats/v7/x-pack/filebeat/cmd.Filebeat())
as part of the test, this loaded the default seccomp policy, blocking
system calls needed by subsequent tests like 'pidfd_send_signal'.

This commit fixes the problem by running Filebeat as a sub process,
like all the other integration tests, thus providing the necessary
isolation between tests.

(cherry picked from commit 46ae121)
mergify bot pushed a commit that referenced this pull request Sep 10, 2025
The Listener.doRun method previously logged connection failures at a
debug level but did not return an error to the caller. This made it
difficult for users to understand why a input was not working.

This commit modifies Listener.doRun to return an error when a
connection failure occurs and also updates the UDP and Unix inputs to
set their status as failed when an error is returned by Listener.Run.

* Add changelog

* Fix log level

* mage check

* double test timeout

* Try using 127.0.0.1 instead of all interfaces

* TestLogStatusReporter run Filebeat as a sub process

TestLogStatusReporter was starting the Filebeat
command (github.com/elastic/beats/v7/x-pack/filebeat/cmd.Filebeat())
as part of the test, this loaded the default seccomp policy, blocking
system calls needed by subsequent tests like 'pidfd_send_signal'.

This commit fixes the problem by running Filebeat as a sub process,
like all the other integration tests, thus providing the necessary
isolation between tests.

(cherry picked from commit 46ae121)

# Conflicts:
#	filebeat/input/unix/input.go
#	x-pack/filebeat/tests/integration/status_reporter_test.go
belimawr added a commit that referenced this pull request Sep 10, 2025
The Listener.doRun method previously logged connection failures at a
debug level but did not return an error to the caller. This made it
difficult for users to understand why a input was not working.

This commit modifies Listener.doRun to return an error when a
connection failure occurs and also updates the UDP and Unix inputs to
set their status as failed when an error is returned by Listener.Run.

TestLogStatusReporter was starting the Filebeat
command (github.com/elastic/beats/v7/x-pack/filebeat/cmd.Filebeat())
as part of the test, this loaded the default seccomp policy, blocking
system calls needed by subsequent tests like 'pidfd_send_signal'.

This commit fixes the problem by running Filebeat as a sub process,
like all the other integration tests, thus providing the necessary
isolation between tests.

(cherry picked from commit 46ae121)

Co-authored-by: Tiago Queiroz <tiago.queiroz@elastic.co>
shmsr pushed a commit that referenced this pull request Sep 11, 2025
The Listener.doRun method previously logged connection failures at a
debug level but did not return an error to the caller. This made it
difficult for users to understand why a input was not working.

This commit modifies Listener.doRun to return an error when a
connection failure occurs and also updates the UDP and Unix inputs to
set their status as failed when an error is returned by Listener.Run.

* Add changelog

* Fix log level

* mage check

* double test timeout

* Try using 127.0.0.1 instead of all interfaces

* TestLogStatusReporter run Filebeat as a sub process

TestLogStatusReporter was starting the Filebeat
command (github.com/elastic/beats/v7/x-pack/filebeat/cmd.Filebeat())
as part of the test, this loaded the default seccomp policy, blocking
system calls needed by subsequent tests like 'pidfd_send_signal'.

This commit fixes the problem by running Filebeat as a sub process,
like all the other integration tests, thus providing the necessary
isolation between tests.
belimawr added a commit that referenced this pull request Sep 19, 2025
…lure (#46508)

The Listener.doRun method previously logged connection failures at a
debug level but did not return an error to the caller. This made it
difficult for users to understand why a input was not working.

This commit modifies Listener.doRun to return an error when a
connection failure occurs and also updates the UDP and Unix inputs to
set their status as failed when an error is returned by Listener.Run.

TestLogStatusReporter was starting the Filebeat
command (github.com/elastic/beats/v7/x-pack/filebeat/cmd.Filebeat())
as part of the test, this loaded the default seccomp policy, blocking
system calls needed by subsequent tests like 'pidfd_send_signal'.

This commit fixes the problem by running Filebeat as a sub process,
like all the other integration tests, thus providing the necessary
isolation between tests.

(cherry picked from commit 46ae121)

# Conflicts:
#	filebeat/input/unix/input.go
#	x-pack/filebeat/tests/integration/status_reporter_test.go

* Fix merge conflicts

* Fix changelog

* The UDP input does not report status on 8.18, so remove the test

* Fix merge conflicts

---------

Co-authored-by: Tiago Queiroz <tiago.queiroz@elastic.co>
belimawr added a commit that referenced this pull request Sep 19, 2025
…ure (#46510)

The Listener.doRun method previously logged connection failures at a
debug level but did not return an error to the caller. This made it
difficult for users to understand why a input was not working.

This commit modifies Listener.doRun to return an error when a
connection failure occurs and also updates the UDP and Unix inputs to
set their status as failed when an error is returned by Listener.Run.

TestLogStatusReporter was starting the Filebeat
command (github.com/elastic/beats/v7/x-pack/filebeat/cmd.Filebeat())
as part of the test, this loaded the default seccomp policy, blocking
system calls needed by subsequent tests like 'pidfd_send_signal'.

This commit fixes the problem by running Filebeat as a sub process,
like all the other integration tests, thus providing the necessary
isolation between tests.

(cherry picked from commit 46ae121)

# Conflicts:
#	filebeat/input/unix/input.go
#	x-pack/filebeat/tests/integration/status_reporter_test.go


---------

Co-authored-by: Tiago Queiroz <tiago.queiroz@elastic.co>
belimawr added a commit that referenced this pull request Sep 22, 2025
…ure (#46511)

The Listener.doRun method previously logged connection failures at a
debug level but did not return an error to the caller. This made it
difficult for users to understand why a input was not working.

This commit modifies Listener.doRun to return an error when a
connection failure occurs and also updates the UDP and Unix inputs to
set their status as failed when an error is returned by Listener.Run.

TestLogStatusReporter was starting the Filebeat
command (github.com/elastic/beats/v7/x-pack/filebeat/cmd.Filebeat())
as part of the test, this loaded the default seccomp policy, blocking
system calls needed by subsequent tests like 'pidfd_send_signal'.

This commit fixes the problem by running Filebeat as a sub process,
like all the other integration tests, thus providing the necessary
isolation between tests.

(cherry picked from commit 46ae121)

# Conflicts:
#	filebeat/input/unix/input.go
#	x-pack/filebeat/tests/integration/status_reporter_test.go

---------

Co-authored-by: Tiago Queiroz <tiago.queiroz@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-all Automated backport with mergify to all the active branches bugfix Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

3 participants