github.com/hhrutter/nomad@v0.6.0-rc2.0.20170723054333-80c4b03f0705/client/driver/exec_linux.go (about)

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