Skip to content

Commit

Permalink
Moving from vendor to go.mod (#26)
Browse files Browse the repository at this point in the history
* Moving from vendor to go.mod

* Updating imports

* Updating imports

* Testing building with github actions

* Testing building with github actions

* Testing building with github actions
  • Loading branch information
Esteban Barrios authored Aug 26, 2021
1 parent be7bbef commit ef06fbc
Show file tree
Hide file tree
Showing 1,327 changed files with 2,094 additions and 532,754 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: 'Build for Freebsd'
on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: 'Checkout'
uses: actions/checkout@v2

- name: 'Installing Go'
uses: actions/setup-go@v2
with:
go-version: '^1.15.0' # The Go version to download (if necessary) and use.

- name: 'Build FreeBSD binary'
run: GOOS=freebsd go build
59 changes: 31 additions & 28 deletions driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@ package pot

import (
"context"
"errors"
"fmt"
"os"
"os/exec"
"time"

hclog "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/nomad/drivers/shared/eventer"
"github.com/hashicorp/nomad/helper/pluginutils/hclutils"
"github.com/hashicorp/nomad/plugins/base"
"github.com/hashicorp/nomad/plugins/drivers"
"github.com/hashicorp/nomad/plugins/shared/hclspec"
pstructs "github.com/hashicorp/nomad/plugins/shared/structs"
"github.com/hashicorp/nomad/plugins/shared/structs"
)

const (
// pluginName is the name of the plugin
pluginName = "pot"

// pluginVersion allows the client to identify and use newer versions of
// an installed plugin
pluginVersion = "v0.2.0"

// fingerprintPeriod is the interval at which the driver will send fingerprint responses
fingerprintPeriod = 30 * time.Second

Expand All @@ -35,8 +40,8 @@ var (
// pluginInfo is the response returned for the PluginInfo RPC
pluginInfo = &base.PluginInfoResponse{
Type: base.PluginTypeDriver,
PluginApiVersions: []string{"0.1.0"},
PluginVersion: "0.0.1",
PluginApiVersions: []string{drivers.ApiVersion010},
PluginVersion: pluginVersion,
Name: pluginName,
}

Expand Down Expand Up @@ -138,10 +143,11 @@ type TaskConfig struct {
// StartTask. This information is needed to rebuild the task state and handler
// during recovery.
type TaskState struct {
TaskConfig *drivers.TaskConfig
ContainerName string
StartedAt time.Time
PID int
ReattachConfig *structs.ReattachConfig
TaskConfig *drivers.TaskConfig
StartedAt time.Time
ContainerName string
PID int
}

// NewPotDriver returns a new DriverPlugin implementation
Expand Down Expand Up @@ -226,27 +232,23 @@ func (d *Driver) handleFingerprint(ctx context.Context, ch chan<- *drivers.Finge
}

func (d *Driver) buildFingerprint() *drivers.Fingerprint {
var health drivers.HealthState
var desc string
attrs := map[string]*pstructs.Attribute{}

potVersion := "pot0.1.0"
fp := &drivers.Fingerprint{
Attributes: map[string]*structs.Attribute{},
Health: drivers.HealthStateHealthy,
HealthDescription: drivers.DriverHealthy,
}

if d.config.Enabled && potVersion != "" {
health = drivers.HealthStateHealthy
desc = "healthy"
attrs["driver.pot"] = pstructs.NewBoolAttribute(true)
attrs["driver.pot.version"] = pstructs.NewStringAttribute(potVersion)
if d.config.Enabled && pluginVersion != "" {
fp.Health = drivers.HealthStateHealthy
fp.HealthDescription = "healthy"
fp.Attributes["driver.pot"] = structs.NewBoolAttribute(true)
fp.Attributes["driver.pot.version"] = structs.NewStringAttribute(pluginVersion)
} else {
health = drivers.HealthStateUndetected
desc = "disabled"
fp.Health = drivers.HealthStateUndetected
fp.HealthDescription = "disabled"
}

return &drivers.Fingerprint{
Attributes: attrs,
Health: health,
HealthDescription: desc,
}
return fp
}

// RecoverTask try to recover a failed task, if not return error
Expand All @@ -256,7 +258,7 @@ func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error {
d.logger.Trace("###########################################################################################################################################")
d.logger.Trace("RECOVER TASK", "ID", handle.Config.ID)
if handle == nil {
return fmt.Errorf("error: handle cannot be nil")
return errors.New("error: handle cannot be nil")
}

if taskhandle, ok := d.tasks.Get(handle.Config.ID); ok {
Expand Down Expand Up @@ -385,6 +387,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive

d.logger.Trace("StartTask", "driverConfig", driverConfig)

d.logger.Info("starting task", "driver_cfg", hclog.Fmt("%+v", driverConfig))
handle := drivers.NewTaskHandle(taskHandleVersion)
handle.Config = cfg

Expand Down Expand Up @@ -591,7 +594,7 @@ func (d *Driver) DestroyTask(taskID string, force bool) error {
}

if handle.IsRunning() && !force {
return fmt.Errorf("cannot destroy running task")
return errors.New("cannot destroy running task")
}

d.tasks.Delete(taskID)
Expand Down Expand Up @@ -630,5 +633,5 @@ func (d *Driver) SignalTask(taskID string, signal string) error {

// ExecTask calls a exec cmd over a running task
func (d *Driver) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error) {
return nil, fmt.Errorf("POT driver does not support exec") //TODO
return nil, errors.New("POT driver does not support exec") //TODO
}
3 changes: 1 addition & 2 deletions driver/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"time"

hclog "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/nomad/plugins/drivers"
)

Expand Down Expand Up @@ -46,7 +46,6 @@ func (h *taskHandle) TaskStatus() *drivers.TaskStatus {
func (h *taskHandle) IsRunning() bool {
h.stateLock.RLock()
defer h.stateLock.RUnlock()

return h.procState == drivers.TaskStateRunning
}

Expand Down
57 changes: 57 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module github.com/trivago/nomad-pot-driver

go 1.15

require (
github.com/LK4D4/joincontext v0.0.0-20171026170139-1724345da6d5 // indirect
github.com/NVIDIA/gpu-monitoring-tools v0.0.0-20191126014920-0d8df858cca4 // indirect
github.com/Sirupsen/logrus v0.0.0-00010101000000-000000000000 // indirect
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/appc/spec v0.8.11 // indirect
github.com/checkpoint-restore/go-criu v0.0.0-20191125063657-fcdcd07065c5 // indirect
github.com/containerd/go-cni v0.0.0-20191121212822-60d125212faf // indirect
github.com/containernetworking/plugins v0.8.3 // indirect
github.com/coreos/go-iptables v0.4.3 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/cyphar/filepath-securejoin v0.2.2 // indirect
github.com/docker/cli v0.0.0-20191202230238-13fb276442f5 // indirect
github.com/docker/docker v1.13.1 // indirect
github.com/docker/docker-credential-helpers v0.6.3 // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
github.com/fsouza/go-dockerclient v1.6.0 // indirect
github.com/hashicorp/consul v1.6.2 // indirect
github.com/hashicorp/consul-template v0.23.0 // indirect
github.com/hashicorp/go-envparse v0.0.0-20190703193109-150b3a2a4611 // indirect
github.com/hashicorp/go-getter v1.4.0 // indirect
github.com/hashicorp/go-hclog v0.10.0
github.com/hashicorp/go-plugin v1.0.1 // indirect
github.com/hashicorp/hcl2 v0.0.0-20191002203319-fb75b3253c80 // indirect
github.com/hashicorp/nomad v0.10.1
github.com/hashicorp/nomad/api v0.0.0-20191203164002-b31573ae7206 // indirect
github.com/mitchellh/go-ps v0.0.0-20190716172923-621e5597135b // indirect
github.com/moby/moby v1.13.1 // indirect
github.com/mrunalp/fileutils v0.0.0-20171103030105-7d4729fb3618 // indirect
github.com/opencontainers/runc v1.0.0-rc8.0.20190611121236-6cc515888830 // indirect
github.com/opencontainers/selinux v1.3.1 // indirect
github.com/seccomp/libseccomp-golang v0.9.1 // indirect
github.com/shirou/gopsutil v2.19.11+incompatible // indirect
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2 // indirect
github.com/ugorji/go v1.1.7 // indirect
github.com/vbatts/tar-split v0.11.1 // indirect
github.com/zclconf/go-cty v1.1.1 // indirect
go4.org v0.0.0-20191010144846-132d2879e1e9 // indirect
)

// use lower-case sirupsen
replace github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.4.2

// don't use shirou/gopsutil, use the hashicorp fork
replace github.com/shirou/gopsutil => github.com/hashicorp/gopsutil v2.17.13-0.20190117153606-62d5761ddb7d+incompatible

// don't use ugorji/go, use the hashicorp fork
replace github.com/ugorji/go => github.com/hashicorp/go-msgpack v0.0.0-20190927123313-23165f7bc3c2

// fix the version of hashicorp/go-msgpack to 96ddbed8d05b
replace github.com/hashicorp/go-msgpack => github.com/hashicorp/go-msgpack v0.0.0-20191101193846-96ddbed8d05b
Loading

0 comments on commit ef06fbc

Please sign in to comment.