Properly fail rkt fingerprinting on old vesions

This commit is contained in:
Michael Schurter 2017-10-16 13:58:58 -07:00
parent d7732c1a58
commit 22ac450b2f
1 changed files with 14 additions and 9 deletions

View File

@ -322,19 +322,24 @@ func (d *RktDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, e
return false, fmt.Errorf("Unable to parse Rkt version string: %#v", rktMatches)
}
minVersion, _ := version.NewVersion(minRktVersion)
currentVersion, _ := version.NewVersion(rktMatches[1])
if currentVersion.LessThan(minVersion) {
// Do not allow ancient rkt versions
if d.fingerprintSuccess == nil {
// Only log on first failure
d.logger.Printf("[WARN] driver.rkt: unsupported rkt version %s; please upgrade to >= %s",
currentVersion, minVersion)
}
delete(node.Attributes, rktDriverAttr)
d.fingerprintSuccess = helper.BoolToPtr(false)
return false, nil
}
node.Attributes[rktDriverAttr] = "1"
node.Attributes["driver.rkt.version"] = rktMatches[1]
node.Attributes["driver.rkt.appc.version"] = appcMatches[1]
minVersion, _ := version.NewVersion(minRktVersion)
currentVersion, _ := version.NewVersion(node.Attributes["driver.rkt.version"])
if currentVersion.LessThan(minVersion) && d.fingerprintSuccess == nil {
// Do not allow ancient rkt versions
d.logger.Printf("[WARN] driver.rkt: unsupported rkt version %s; please upgrade to >= %s",
currentVersion, minVersion)
node.Attributes[rktDriverAttr] = "0"
}
// Advertise if this node supports rkt volumes
if d.config.ReadBoolDefault(rktVolumesConfigOption, rktVolumesConfigDefault) {
node.Attributes["driver."+rktVolumesConfigOption] = "1"