rkt fingerprint logs once
This commit is contained in:
parent
a6b36df4de
commit
39542b4cf0
|
@ -21,9 +21,9 @@ import (
|
|||
|
||||
appcschema "github.com/appc/spec/schema"
|
||||
"github.com/hashicorp/consul-template/signals"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/go-version"
|
||||
hclog "github.com/hashicorp/go-hclog"
|
||||
plugin "github.com/hashicorp/go-plugin"
|
||||
version "github.com/hashicorp/go-version"
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/client/taskenv"
|
||||
|
@ -193,6 +193,9 @@ type Driver struct {
|
|||
|
||||
// logger will log to the Nomad agent
|
||||
logger hclog.Logger
|
||||
|
||||
// hasFingerprinted is used to store whether we have fingerprinted before
|
||||
hasFingerprinted bool
|
||||
}
|
||||
|
||||
func NewRktDriver(logger hclog.Logger) drivers.DriverPlugin {
|
||||
|
@ -262,6 +265,10 @@ func (d *Driver) handleFingerprint(ctx context.Context, ch chan *drivers.Fingerp
|
|||
}
|
||||
|
||||
func (d *Driver) buildFingerprint() *drivers.Fingerprint {
|
||||
defer func() {
|
||||
d.hasFingerprinted = true
|
||||
}()
|
||||
|
||||
fingerprint := &drivers.Fingerprint{
|
||||
Attributes: map[string]*pstructs.Attribute{},
|
||||
Health: drivers.HealthStateHealthy,
|
||||
|
@ -270,6 +277,9 @@ func (d *Driver) buildFingerprint() *drivers.Fingerprint {
|
|||
|
||||
// Only enable if we are root
|
||||
if syscall.Geteuid() != 0 {
|
||||
if !d.hasFingerprinted {
|
||||
d.logger.Debug("must run as root user, disabling")
|
||||
}
|
||||
fingerprint.Health = drivers.HealthStateUndetected
|
||||
fingerprint.HealthDescription = drivers.DriverRequiresRootMessage
|
||||
return fingerprint
|
||||
|
@ -297,6 +307,10 @@ func (d *Driver) buildFingerprint() *drivers.Fingerprint {
|
|||
// Do not allow ancient rkt versions
|
||||
fingerprint.Health = drivers.HealthStateUndetected
|
||||
fingerprint.HealthDescription = fmt.Sprintf("Unsuported rkt version %s", currentVersion)
|
||||
if !d.hasFingerprinted {
|
||||
d.logger.Warn("unsupported rkt version please upgrade to >= "+minVersion.String(),
|
||||
"rkt_version", currentVersion)
|
||||
}
|
||||
return fingerprint
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue