Skip to content

Conversation

@SoloJacobs
Copy link
Contributor

This commit addresses the following error:

 time=2025-11-14T16:14:59.573Z level=ERROR source=main.go:559
msg="Listen error" err="listen tcp 127.0.0.1:36357: bind: address
already in use"

freeAddress is called multiple times within one test, but also in parallel in multiple tests. freeAddress immediately releases the port despite it being used later in a test. This causes ports to errorenously to be reused.

We replace net.Listen in order to avoid calling syscall.Listen. This way the port can be reused by AM, without the kernel assuming that port can be reused by other processes specifiying port 0.

Fixes: #4742

This commit addresses the following error:
```
 time=2025-11-14T16:14:59.573Z level=ERROR source=main.go:559
msg="Listen error" err="listen tcp 127.0.0.1:36357: bind: address
already in use"
```

`freeAddress` is called multiple times within one test, but also in
parallel in multiple tests. `freeAddress` immediately releases the port
despite it being used later in a test. This causes ports to errorenously
to be reused.

We replace `net.Listen` in order to avoid calling `syscall.Listen`. This
way the port can be reused by AM, without the kernel assuming that port
can be reused by other processes specifiying port `0`.

Fixes: prometheus#4742
Signed-off-by: Solomon Jacobs <[email protected]>
@TheMeier
Copy link
Contributor

I tried this locally and it still produces the same error but now in TestColdStart

--- FAIL: TestColdStart (5.07s)
    acceptance.go:193: failed to start alertmanager cluster: unable to get a successful response from the Alertmanager: Get "http://127.0.0.1:37501/api/v2/status": dial tcp 127.0.0.1:37501: connect: connection refused
    send_test.go:481: 
        collector "webhook":
        
        interval [4,5]
        ---
        - &{map[] 0001-01-01T00:00:00.000Z <nil> [] 0001-01-01T00:00:01.000Z <nil> <nil> { map[alertname:test1]}}[1:]

@SoloJacobs
Copy link
Contributor Author

Ah, wow. That is definitely a problem.

@SoloJacobs SoloJacobs closed this Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix flakes in TestMergeAlerts

2 participants