Skip to content

Commit

Permalink
Merge pull request #16 from ArangoGutierrez/issue_14
Browse files Browse the repository at this point in the history
fix typo on README
  • Loading branch information
ArangoGutierrez authored Apr 24, 2019
2 parents 10c59c3 + bd5b4bc commit f6201e1
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 80 deletions.
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 2.0
version: 2

defaults: &defaults
working_directory: /src
Expand Down Expand Up @@ -83,8 +83,10 @@ jobs:
- run:
name: Check for Lint
command: markdownlint --config src/.markdownlint.json src/

workflows:
version: 2

build_and_test:
jobs:
- get_source
Expand Down
30 changes: 15 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ works, incorporate into other computer software, distribute, and sublicense
such enhancements or derivative works thereof, in binary and source code
form.

## Contributing

# Contributing

When contributing to [sylabs/nomad-driver-singularity](https://github.com/sylabs/nomad-driver-singularity/), it
is important to properly communicate the gist of the contribution. If it is a simple code or
editorial fix, simply explaining this within the GitHub Pull Request (PR) will suffice. But
if this is a larger fix or Enhancement, you are advised to first discuss the change
with the project leader or developers.
When contributing to [sylabs/nomad-driver-singularity](https://github.com/sylabs/nomad-driver-singularity/)
it is important to properly communicate the gist of the contribution.
If it is a simple code or editorial fix, simply explaining this within
the GitHub Pull Request (PR) will suffice. But if this is a larger fix or Enhancement,
you are advised to first discuss the change with the project leader or developers.

Please note we have a code of conduct, described below. Please follow it in
all your interactions with the project members and users.

## Pull Requests (PRs)

### Process

1. Essential bug fix PRs should be sent to both master and release branches.
2. Small bug fix and feature enhancement PRs should be sent to master only.
3. Follow the existing code style precedent, especially for C. For Golang, you
Expand All @@ -45,9 +45,9 @@ all your interactions with the project members and users.
requirements are met.
10. Documentation must be provided if necessary (next section)

# Code of Conduct
## Code of Conduct

## Our Pledge
### Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
Expand All @@ -56,7 +56,7 @@ size, disability, ethnicity, gender identity and expression, level of experience
nationality, personal appearance, race, religion, or sexual identity and
orientation.

## Our Standards
### Our Standards

Examples of behavior that contributes to creating a positive environment
include:
Expand Down Expand Up @@ -90,7 +90,7 @@ that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope
### Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
Expand All @@ -99,7 +99,7 @@ address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement
### Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project leaders ([email protected]). All
Expand All @@ -113,10 +113,10 @@ Project maintainers, contributors and users who do not follow or enforce the
Code of Conduct in good faith may face temporary or permanent repercussions
with their involvement in the project as determined by the project's leader(s).

## Attribution
### Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
4 changes: 2 additions & 2 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Maintainers:
# Maintainers

- Eduardo Arango <[email protected]>

# Contributors:
## Contributors
33 changes: 18 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
# nomad-driver-singularity

[Hashicorp Nomad](https://www.nomadproject.io/) driver plugin using [Singularity containers](https://github.com/sylabs/singularity) to execute tasks.
[Hashicorp Nomad](https://www.nomadproject.io/) driver plugin using
[Singularity containers](https://github.com/sylabs/singularity) to execute tasks.

Requirements
------------
## Requirements

- [Nomad](https://www.nomadproject.io/downloads.html) v0.9+
- [Go](https://golang.org/doc/install) v1.11+ (to build the provider plugin)
- [Singularity](https://github.com/singularityware/singularity) v3.0.3+

Building The Driver
---------------------
## Building The Driver

Clone repository on your prefered path

```sh
$ git clone [email protected]:sylabs/nomad-driver-singularity
git clone [email protected]:sylabs/nomad-driver-singularity
```

Enter the provider directory and build the provider

```sh
$ nomad-driver-singularity
$ make dep
$ make build
cd nomad-driver-singularity
make dep
make build
```

Developing the Provider
---------------------------
## Developing the Provider

If you wish to contribute on the project, you'll first need [Go](http://www.golang.org) installed on your machine, and have have `singularity` installed.
If you wish to contribute on the project, you'll first need [Go](http://www.golang.org)
installed on your machine, and have have `singularity` installed.

To compile the provider, run `make build`.
This will build the provider and put the task driver binary under
the NOMAD plugin dir,
which by default is located under `<nomad-data-dir>/plugins/`.

To compile the provider, run `make build`. This will build the provider and put the task driver binary under the NOMAD plugin dir, which by deafult is located under `<nomad-data-dir>/plugins/`.
Check Nomad `-data-dir` and `-plugin-dir` flags for more information.

```sh
$ make build
make build
```

In order to test the provider, you can simply run `make test`.

```sh
$ make test
make test
```
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module github.com/sylabs/nomad-driver-singularity

require (
github.com/LK4D4/joincontext v0.0.0-20171026170139-1724345da6d5 // indirect
github.com/Microsoft/go-winio v0.4.12 // indirect
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/fsnotify/fsnotify v1.4.7 // indirect
github.com/go-ole/go-ole v1.2.2 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/LK4D4/joincontext v0.0.0-20171026170139-1724345da6d5 h1:U7q69tqXiCf6m097GRlNQB0/6SI1qWIOHYHhCEvDxF4=
github.com/LK4D4/joincontext v0.0.0-20171026170139-1724345da6d5/go.mod h1:nxQPcNPR/34g+HcK2hEsF99O+GJgIkW/OmPl8wtzhmk=
github.com/Microsoft/go-winio v0.4.12 h1:xAfWHN1IrQ0NJ9TBC0KBZoqLjzDTr1ML+4MywiUOryc=
github.com/Microsoft/go-winio v0.4.12/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I=
Expand Down
16 changes: 16 additions & 0 deletions pkg/plugin/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,17 @@ func NewSingularityDriver(logger hclog.Logger) drivers.DriverPlugin {
}
}

// PluginInfo return a base.PluginInfoResponse struct
func (d *Driver) PluginInfo() (*base.PluginInfoResponse, error) {
return pluginInfo, nil
}

// ConfigSchema return a hclspec.Spec struct
func (d *Driver) ConfigSchema() (*hclspec.Spec, error) {
return configSpec, nil
}

// SetConfig set the nomad agent config based on base.Config
func (d *Driver) SetConfig(cfg *base.Config) error {
var config Config
if len(cfg.PluginConfig) != 0 {
Expand All @@ -202,19 +205,23 @@ func (d *Driver) SetConfig(cfg *base.Config) error {
return nil
}

// Shutdown the plugin
func (d *Driver) Shutdown(ctx context.Context) error {
d.signalShutdown()
return nil
}

// TaskConfigSchema returns a hclspec.Spec struct
func (d *Driver) TaskConfigSchema() (*hclspec.Spec, error) {
return taskConfigSpec, nil
}

// Capabilities a drivers.Capabilities struct
func (d *Driver) Capabilities() (*drivers.Capabilities, error) {
return capabilities, nil
}

// Fingerprint return the plugin fingerprint
func (d *Driver) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint, error) {
ch := make(chan *drivers.Fingerprint)
go d.handleFingerprint(ctx, ch)
Expand Down Expand Up @@ -265,6 +272,7 @@ func (d *Driver) buildFingerprint() *drivers.Fingerprint {
}
}

// RecoverTask try to recover a failed task, if not return error
func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error {
if handle == nil {
return fmt.Errorf("error: handle cannot be nil")
Expand Down Expand Up @@ -360,6 +368,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
return handle, nil, nil
}

// WaitTask watis for task completion
func (d *Driver) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error) {
handle, ok := d.tasks.Get(taskID)
if !ok {
Expand Down Expand Up @@ -393,6 +402,7 @@ func (d *Driver) handleWait(ctx context.Context, handle *taskHandle, ch chan *dr
}
}

// StopTask shutdown a tasked based on its taskID
func (d *Driver) StopTask(taskID string, timeout time.Duration, signal string) error {
handle, ok := d.tasks.Get(taskID)
if !ok {
Expand All @@ -406,6 +416,7 @@ func (d *Driver) StopTask(taskID string, timeout time.Duration, signal string) e
return nil
}

// DestroyTask delete task
func (d *Driver) DestroyTask(taskID string, force bool) error {
handle, ok := d.tasks.Get(taskID)
if !ok {
Expand All @@ -420,6 +431,7 @@ func (d *Driver) DestroyTask(taskID string, force bool) error {
return nil
}

// InspectTask retrieves task info
func (d *Driver) InspectTask(taskID string) (*drivers.TaskStatus, error) {
handle, ok := d.tasks.Get(taskID)
if !ok {
Expand All @@ -429,6 +441,7 @@ func (d *Driver) InspectTask(taskID string) (*drivers.TaskStatus, error) {
return handle.TaskStatus(), nil
}

// TaskStats get task stats
func (d *Driver) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error) {
handle, ok := d.tasks.Get(taskID)
if !ok {
Expand All @@ -438,14 +451,17 @@ func (d *Driver) TaskStats(ctx context.Context, taskID string, interval time.Dur
return handle.stats(ctx, interval)
}

// TaskEvents return a chan *drivers.TaskEvent
func (d *Driver) TaskEvents(ctx context.Context) (<-chan *drivers.TaskEvent, error) {
return d.eventer.TaskEvents(ctx)
}

// SignalTask send a specific signal to a taskID
func (d *Driver) SignalTask(taskID string, signal string) error {
return fmt.Errorf("Singularity driver does not support signals")
}

// 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("Singularity driver does not support exec") //TODO
}
2 changes: 1 addition & 1 deletion pkg/plugin/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (h *taskHandle) shutdown(timeout time.Duration) error {
}
case err := <-done:
if err != nil {
fmt.Errorf("process finished with error = %v", err)
return fmt.Errorf("process finished with error = %v", err)
}
}

Expand Down
14 changes: 0 additions & 14 deletions pkg/plugin/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,11 @@ import (
"fmt"
"io"
"io/ioutil"
"os/exec"
"path/filepath"

"github.com/hashicorp/nomad/client/lib/fifo"
"github.com/hashicorp/nomad/plugins/drivers"
)

func getAbsolutePath(bin string) (string, error) {
lp, err := exec.LookPath(bin)
if err != nil {
lp, err = exec.LookPath(singularityCmd)
if err != nil {
return "", fmt.Errorf("failed to resolve path to %q executable: %v", bin, err)
}
}

return filepath.EvalSymlinks(lp)
}

// prepareContainer preloads the taskcnf into args to be apssed to a execCmd
func prepareContainer(cfg *drivers.TaskConfig, taskCfg TaskConfig) syexec {
argv := make([]string, 0, 50)
Expand Down
Loading

0 comments on commit f6201e1

Please sign in to comment.