diff --git a/drivers/rkt/driver.go b/drivers/rkt/driver.go index c2be6494e..54fa4d486 100644 --- a/drivers/rkt/driver.go +++ b/drivers/rkt/driver.go @@ -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 }