Skip to content

Commit f6201e1

Browse files
Merge pull request #16 from ArangoGutierrez/issue_14
fix typo on README
2 parents 10c59c3 + bd5b4bc commit f6201e1

File tree

10 files changed

+70
-80
lines changed

10 files changed

+70
-80
lines changed

.circleci/config.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 2.0
1+
version: 2
22

33
defaults: &defaults
44
working_directory: /src
@@ -83,8 +83,10 @@ jobs:
8383
- run:
8484
name: Check for Lint
8585
command: markdownlint --config src/.markdownlint.json src/
86+
8687
workflows:
8788
version: 2
89+
8890
build_and_test:
8991
jobs:
9092
- get_source

CONTRIBUTING.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ works, incorporate into other computer software, distribute, and sublicense
1111
such enhancements or derivative works thereof, in binary and source code
1212
form.
1313

14+
## Contributing
1415

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

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

2625
## Pull Requests (PRs)
2726

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

48-
# Code of Conduct
48+
## Code of Conduct
4949

50-
## Our Pledge
50+
### Our Pledge
5151

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

59-
## Our Standards
59+
### Our Standards
6060

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

93-
## Scope
93+
### Scope
9494

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

102-
## Enforcement
102+
### Enforcement
103103

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

116-
## Attribution
116+
### Attribution
117117

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

121121
[homepage]: http://contributor-covenant.org
122122
[version]: http://contributor-covenant.org/version/1/4/

CONTRIBUTORS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Maintainers:
1+
# Maintainers
22

33
- Eduardo Arango <[email protected]>
44

5-
# Contributors:
5+
## Contributors

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,48 @@
11
# nomad-driver-singularity
22

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

5-
Requirements
6-
------------
6+
## Requirements
77

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

12-
Building The Driver
13-
---------------------
12+
## Building The Driver
1413

1514
Clone repository on your prefered path
1615

1716
```sh
18-
$ git clone [email protected]:sylabs/nomad-driver-singularity
17+
git clone [email protected]:sylabs/nomad-driver-singularity
1918
```
2019

2120
Enter the provider directory and build the provider
2221

2322
```sh
24-
$ nomad-driver-singularity
25-
$ make dep
26-
$ make build
23+
cd nomad-driver-singularity
24+
make dep
25+
make build
2726
```
2827

29-
Developing the Provider
30-
---------------------------
28+
## Developing the Provider
3129

32-
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.
30+
If you wish to contribute on the project, you'll first need [Go](http://www.golang.org)
31+
installed on your machine, and have have `singularity` installed.
32+
33+
To compile the provider, run `make build`.
34+
This will build the provider and put the task driver binary under
35+
the NOMAD plugin dir,
36+
which by default is located under `<nomad-data-dir>/plugins/`.
3337

34-
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/`.
3538
Check Nomad `-data-dir` and `-plugin-dir` flags for more information.
3639

3740
```sh
38-
$ make build
41+
make build
3942
```
4043

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

4346
```sh
44-
$ make test
47+
make test
4548
```

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module github.com/sylabs/nomad-driver-singularity
22

33
require (
44
github.com/LK4D4/joincontext v0.0.0-20171026170139-1724345da6d5 // indirect
5+
github.com/Microsoft/go-winio v0.4.12 // indirect
56
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
67
github.com/fsnotify/fsnotify v1.4.7 // indirect
78
github.com/go-ole/go-ole v1.2.2 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
22
github.com/LK4D4/joincontext v0.0.0-20171026170139-1724345da6d5 h1:U7q69tqXiCf6m097GRlNQB0/6SI1qWIOHYHhCEvDxF4=
33
github.com/LK4D4/joincontext v0.0.0-20171026170139-1724345da6d5/go.mod h1:nxQPcNPR/34g+HcK2hEsF99O+GJgIkW/OmPl8wtzhmk=
4+
github.com/Microsoft/go-winio v0.4.12 h1:xAfWHN1IrQ0NJ9TBC0KBZoqLjzDTr1ML+4MywiUOryc=
5+
github.com/Microsoft/go-winio v0.4.12/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
46
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8=
57
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
68
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I=

pkg/plugin/driver.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,17 @@ func NewSingularityDriver(logger hclog.Logger) drivers.DriverPlugin {
178178
}
179179
}
180180

181+
// PluginInfo return a base.PluginInfoResponse struct
181182
func (d *Driver) PluginInfo() (*base.PluginInfoResponse, error) {
182183
return pluginInfo, nil
183184
}
184185

186+
// ConfigSchema return a hclspec.Spec struct
185187
func (d *Driver) ConfigSchema() (*hclspec.Spec, error) {
186188
return configSpec, nil
187189
}
188190

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

208+
// Shutdown the plugin
205209
func (d *Driver) Shutdown(ctx context.Context) error {
206210
d.signalShutdown()
207211
return nil
208212
}
209213

214+
// TaskConfigSchema returns a hclspec.Spec struct
210215
func (d *Driver) TaskConfigSchema() (*hclspec.Spec, error) {
211216
return taskConfigSpec, nil
212217
}
213218

219+
// Capabilities a drivers.Capabilities struct
214220
func (d *Driver) Capabilities() (*drivers.Capabilities, error) {
215221
return capabilities, nil
216222
}
217223

224+
// Fingerprint return the plugin fingerprint
218225
func (d *Driver) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint, error) {
219226
ch := make(chan *drivers.Fingerprint)
220227
go d.handleFingerprint(ctx, ch)
@@ -265,6 +272,7 @@ func (d *Driver) buildFingerprint() *drivers.Fingerprint {
265272
}
266273
}
267274

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

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

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

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

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

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

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

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

464+
// ExecTask calls a exec cmd over a running task
449465
func (d *Driver) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error) {
450466
return nil, fmt.Errorf("Singularity driver does not support exec") //TODO
451467
}

pkg/plugin/handle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (h *taskHandle) shutdown(timeout time.Duration) error {
9797
}
9898
case err := <-done:
9999
if err != nil {
100-
fmt.Errorf("process finished with error = %v", err)
100+
return fmt.Errorf("process finished with error = %v", err)
101101
}
102102
}
103103

pkg/plugin/prepare.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,11 @@ import (
99
"fmt"
1010
"io"
1111
"io/ioutil"
12-
"os/exec"
13-
"path/filepath"
1412

1513
"github.com/hashicorp/nomad/client/lib/fifo"
1614
"github.com/hashicorp/nomad/plugins/drivers"
1715
)
1816

19-
func getAbsolutePath(bin string) (string, error) {
20-
lp, err := exec.LookPath(bin)
21-
if err != nil {
22-
lp, err = exec.LookPath(singularityCmd)
23-
if err != nil {
24-
return "", fmt.Errorf("failed to resolve path to %q executable: %v", bin, err)
25-
}
26-
}
27-
28-
return filepath.EvalSymlinks(lp)
29-
}
30-
3117
// prepareContainer preloads the taskcnf into args to be apssed to a execCmd
3218
func prepareContainer(cfg *drivers.TaskConfig, taskCfg TaskConfig) syexec {
3319
argv := make([]string, 0, 50)

0 commit comments

Comments
 (0)