watcher: save and notify nothing for a cut-short port or TLS check (closes #185)
check / check (push) Successful in 1m8s
check / check (push) Successful in 1m8s
When shutdown cancels a check that is under way, the rest of the check still runs with the cancelled context. The resolver already drops a lookup the context cut short, but a cancelled connection attempt was saved as a closed port or a failed certificate check and notified as Port Change or TLS Failure. The watcher now drops a port or TLS check result when its context was cancelled, the same way. The test runs a check with the context already cancelled, using the real resolver and the real port and TLS checkers; no query is sent and no connection is made. Model: opus-5-5
This commit was merged in pull request #188.
This commit is contained in:
@@ -658,6 +658,13 @@ func (w *Watcher) checkSinglePort(
|
||||
hostnames []string,
|
||||
) {
|
||||
result, err := w.portCheck.CheckPort(ctx, ip, port)
|
||||
|
||||
// A check the context cut short says nothing about the port, so it
|
||||
// is neither saved nor notified.
|
||||
if ctx.Err() != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
w.log.Error(
|
||||
"port check failed",
|
||||
@@ -733,6 +740,13 @@ func (w *Watcher) checkTLSCert(
|
||||
hostname string,
|
||||
) {
|
||||
cert, err := w.tlsCheck.CheckCertificate(ctx, ip, hostname)
|
||||
|
||||
// A check the context cut short says nothing about the certificate,
|
||||
// so it is neither saved nor notified.
|
||||
if ctx.Err() != nil {
|
||||
return
|
||||
}
|
||||
|
||||
certKey := fmt.Sprintf("%s:%d:%s", ip, tlsPort, hostname)
|
||||
now := time.Now().UTC()
|
||||
prev, hasPrev := w.state.GetCertificateState(certKey)
|
||||
|
||||
Reference in New Issue
Block a user