From 5ce8bb1af4ab8c699124a0314ad07c86a8514d63 Mon Sep 17 00:00:00 2001 From: Chris Schinnerl Date: Tue, 16 Apr 2024 17:20:50 +0200 Subject: [PATCH] contractor: don't register failed renewal alert if the host ran out of funds --- autopilot/contractor/contractor.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/autopilot/contractor/contractor.go b/autopilot/contractor/contractor.go index 00bbef98b..524049c36 100644 --- a/autopilot/contractor/contractor.go +++ b/autopilot/contractor/contractor.go @@ -14,6 +14,7 @@ import ( rhpv2 "go.sia.tech/core/rhp/v2" rhpv3 "go.sia.tech/core/rhp/v3" "go.sia.tech/core/types" + cwallet "go.sia.tech/coreutils/wallet" "go.sia.tech/renterd/alerts" "go.sia.tech/renterd/api" "go.sia.tech/renterd/internal/utils" @@ -984,7 +985,16 @@ func (c *Contractor) runContractRenewals(ctx *mCtx, w Worker, toRenew []contract contract := toRenew[i].contract.ContractMetadata renewed, proceed, err := c.renewContract(ctx, w, toRenew[i], budget) if err != nil { - c.alerter.RegisterAlert(ctx, newContractRenewalFailedAlert(contract, !proceed, err)) + // don't register an alert for hosts that are out of funds since the + // user can't do anything about it + if !(worker.IsErrHost(err) && utils.IsErr(err, cwallet.ErrNotEnoughFunds)) { + c.alerter.RegisterAlert(ctx, newContractRenewalFailedAlert(contract, !proceed, err)) + } + c.logger.With(zap.Error(err)). + With("fcid", toRenew[i].contract.ID). + With("hostKey", toRenew[i].contract.HostKey). + With("proceed", proceed). + Errorw("failed to renew contract") if toRenew[i].usable { toKeep = append(toKeep, toRenew[i].contract.ContractMetadata) }