Skip to content

Commit

Permalink
autopilot: don't consider hosts bad when we have a contract with them…
Browse files Browse the repository at this point in the history
… and 'scanned=false'
  • Loading branch information
ChrisSchinnerl committed Nov 6, 2024
1 parent 1b506ab commit 8068de9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion autopilot/contractor/contractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,14 @@ func performContractChecks(ctx *mCtx, alerter alerts.Alerter, bus Bus, w Worker,
continue
}

// NOTE: if we have a contract with a host that is not scanned, we either
// added the host and contract manually or reset the host scans. In that case,
// we ignore the fact that the host is not scanned for now to avoid churn.
if check.Usability.NotCompletingScan {
check.Usability.NotCompletingScan = false
check.Usability.Offline = false
}

// check usability
if !check.Usability.IsUsable() {
reasons := strings.Join(check.Usability.UnusableReasons(), ",")
Expand Down Expand Up @@ -1097,9 +1105,10 @@ func performContractFormations(ctx *mCtx, bus Bus, w Worker, cr contractReviser,
usedHosts[c.HostKey] = struct{}{}
}
allHosts, err := bus.SearchHosts(ctx, api.SearchHostOptions{
AutopilotID: ctx.ApID(),
Limit: -1,
FilterMode: api.HostFilterModeAllowed,
UsabilityMode: api.UsabilityFilterModeAll,
UsabilityMode: api.UsabilityFilterModeUsable,
})
if err != nil {
return nil, fmt.Errorf("failed to fetch usable hosts: %w", err)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
UPDATE hosts SET settings = '{}', price_table = '{}', last_scan = 0, last_scan_success = 0, second_to_last_scan_success = 0 WHERE 1=1;
UPDATE hosts SET settings = '{}', price_table = '{}', last_scan = 0, last_scan_success = 0, second_to_last_scan_success = 0, scanned = 0 WHERE 1=1;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
UPDATE hosts SET settings = '{}', price_table = '{}', last_scan = 0, last_scan_success = 0, second_to_last_scan_success = 0 WHERE 1=1;
UPDATE hosts SET settings = '{}', price_table = '{}', last_scan = 0, last_scan_success = 0, second_to_last_scan_success = 0, scanned = 0 WHERE 1=1;

0 comments on commit 8068de9

Please sign in to comment.