Skip to content

Commit

Permalink
Don't register failed renewal alert if the host ran out of funds (#1173)
Browse files Browse the repository at this point in the history
because the user can't do anything about it. So instead we just log it.
  • Loading branch information
ChrisSchinnerl authored Apr 17, 2024
2 parents 2b66e10 + 5ce8bb1 commit 003b4f8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion autopilot/contractor/contractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 003b4f8

Please sign in to comment.