github.com/mattyr/nomad@v0.3.3-0.20160919021406-3485a065154a/client/driver/exec_linux.go (about)

     1  package driver
     2  
     3  import (
     4  	"github.com/hashicorp/nomad/client/config"
     5  	"github.com/hashicorp/nomad/nomad/structs"
     6  	"golang.org/x/sys/unix"
     7  )
     8  
     9  func (d *ExecDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error) {
    10  	// Get the current status so that we can log any debug messages only if the
    11  	// state changes
    12  	_, currentlyEnabled := node.Attributes[execDriverAttr]
    13  
    14  	// Only enable if cgroups are available and we are root
    15  	if _, ok := node.Attributes["unique.cgroup.mountpoint"]; !ok {
    16  		if currentlyEnabled {
    17  			d.logger.Printf("[DEBUG] driver.exec: cgroups unavailable, disabling")
    18  		}
    19  		delete(node.Attributes, execDriverAttr)
    20  		return false, nil
    21  	} else if unix.Geteuid() != 0 {
    22  		if currentlyEnabled {
    23  			d.logger.Printf("[DEBUG] driver.exec: must run as root user, disabling")
    24  		}
    25  		delete(node.Attributes, execDriverAttr)
    26  		return false, nil
    27  	}
    28  
    29  	if !currentlyEnabled {
    30  		d.logger.Printf("[DEBUG] driver.exec: exec driver is enabled")
    31  	}
    32  	node.Attributes[execDriverAttr] = "1"
    33  	return true, nil
    34  }