mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
When a node is fingerprinted, we calculate a "computed class" from a hash over a subset of its fields and attributes. In the scheduler, when a given node fails feasibility checking (before fit checking) we know that no other node of that same class will be feasible, and we add the hash to a map so we can reject them early. This hash cannot include any values that are unique to a given node, otherwise no other node will have the same hash and we'll never save ourselves the work of feasibility checking those nodes. In #4390 we introduce the `nomad.advertise.address` attribute and in #19969 we introduced `consul.dns.addr` attribute. Both of these are unique per node and break the hash. Additionally, we were not correctly filtering attributes out when checking if a node escaped the class by not filtering for attributes that start with `unique.`. The test for this introduced in #708 had an inverted assertion, which allowed this to pass unnoticed since the early days of Nomad. Ref: https://github.com/hashicorp/nomad/pull/708 Ref: https://github.com/hashicorp/nomad/pull/4390 Ref: https://github.com/hashicorp/nomad/pull/19969
32 lines
914 B
Go
32 lines
914 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package fingerprint
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
log "github.com/hashicorp/go-hclog"
|
|
)
|
|
|
|
// NomadFingerprint is used to fingerprint the Nomad version
|
|
type NomadFingerprint struct {
|
|
StaticFingerprinter
|
|
logger log.Logger
|
|
}
|
|
|
|
// NewNomadFingerprint is used to create a Nomad fingerprint
|
|
func NewNomadFingerprint(logger log.Logger) Fingerprint {
|
|
f := &NomadFingerprint{logger: logger.Named("nomad")}
|
|
return f
|
|
}
|
|
|
|
func (f *NomadFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
|
|
resp.AddAttribute("unique.advertise.address", req.Node.HTTPAddr)
|
|
resp.AddAttribute("nomad.version", req.Config.Version.VersionNumber())
|
|
resp.AddAttribute("nomad.revision", req.Config.Version.Revision)
|
|
resp.AddAttribute("nomad.service_discovery", strconv.FormatBool(req.Config.NomadServiceDiscovery))
|
|
resp.Detected = true
|
|
return nil
|
|
}
|