Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forgive failed refresh only when contract is in set #1280

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions autopilot/contractor/contractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,9 @@ LOOP:
// if we were not able to the contract's revision, we can't properly
// perform the checks that follow, however we do want to be lenient if
// this contract is in the current set and we still have leeway left
_, inSet := inCurrentSet[fcid]
if contract.Revision == nil {
if _, found := inCurrentSet[fcid]; !found || remainingKeepLeeway == 0 {
if !inSet || remainingKeepLeeway == 0 {
toStopUsing[fcid] = errContractNoRevision.Error()
} else if !ctx.AllowRedundantIPs() && ipFilter.IsRedundantIP(contract.HostIP, contract.HostKey) {
toStopUsing[fcid] = fmt.Sprintf("%v; %v", api.ErrUsabilityHostRedundantIP, errContractNoRevision)
Expand All @@ -711,7 +712,7 @@ LOOP:

// decide whether the contract is still good
ci := contractInfo{contract: contract, priceTable: host.PriceTable.HostPriceTable, settings: host.Settings}
usable, recoverable, refresh, renew, reasons := c.isUsableContract(ctx.AutopilotConfig(), ctx.state.RS, ci, bh, ipFilter)
usable, recoverable, refresh, renew, reasons := c.isUsableContract(ctx.AutopilotConfig(), ctx.state.RS, ci, inSet, bh, ipFilter)
ci.usable = usable
ci.recoverable = recoverable
if !usable {
Expand Down
8 changes: 4 additions & 4 deletions autopilot/contractor/hostfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (u *unusableHostsBreakdown) keysAndValues() []interface{} {
// - recoverable -> can be usable in the contract set if it is refreshed/renewed
// - refresh -> should be refreshed
// - renew -> should be renewed
func (c *Contractor) isUsableContract(cfg api.AutopilotConfig, rs api.RedundancySettings, ci contractInfo, bh uint64, f *ipFilter) (usable, recoverable, refresh, renew bool, reasons []string) {
func (c *Contractor) isUsableContract(cfg api.AutopilotConfig, rs api.RedundancySettings, ci contractInfo, inSet bool, bh uint64, f *ipFilter) (usable, recoverable, refresh, renew bool, reasons []string) {
contract, s, pt := ci.contract, ci.settings, ci.priceTable

usable = true
Expand All @@ -121,14 +121,14 @@ func (c *Contractor) isUsableContract(cfg api.AutopilotConfig, rs api.Redundancy
} else {
if isOutOfCollateral(cfg, rs, contract, s, pt) {
reasons = append(reasons, errContractOutOfCollateral.Error())
usable = false
recoverable = true
usable = usable && inSet && c.shouldForgiveFailedRefresh(contract.ID)
recoverable = !usable // only needs to be recoverable if !usable
ChrisSchinnerl marked this conversation as resolved.
Show resolved Hide resolved
refresh = true
renew = false
}
if isOutOfFunds(cfg, pt, contract) {
reasons = append(reasons, errContractOutOfFunds.Error())
usable = usable && c.shouldForgiveFailedRefresh(contract.ID)
usable = usable && inSet && c.shouldForgiveFailedRefresh(contract.ID)
recoverable = !usable // only needs to be recoverable if !usable
refresh = true
renew = false
Expand Down
Loading