diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7d125b25..93e28df8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,9 +9,9 @@ jobs: steps: - uses: actions/checkout@v1 - - uses: actions/setup-go@v2 - with: - go-version: '^1.14.1' + + - name: Show go version + run: go version - name: Lint Deps run: make lint-deps diff --git a/CHANGELOG.md b/CHANGELOG.md index b23b8633..323a7559 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,12 @@ FEATURES: -* config: Ability to configure dns server list +* config: [[GH-54](https://github.com/hashicorp/nomad-driver-podman/issues/54)] Ability to configure dns server list +* runtime: [[GH-64](https://github.com/hashicorp/nomad-driver-podman/issues/64)] Add support for SignalTask + +BUG FIXES: + +* [[GH-67](https://github.com/hashicorp/nomad-driver-podman/issues/67)] run container from oci-archive image ## 0.1.0 diff --git a/GNUmakefile b/GNUmakefile index 9bee5d08..24d889b9 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -7,14 +7,14 @@ changelogfmt: .PHONY: check check: ## Lint the source code @echo "==> Linting source code..." - @golangci-lint run + @$(CURDIR)/build/bin/golangci-lint run @echo "==> vetting hc-log statements" - @hclogvet . + @$(CURDIR)/build/bin/hclogvet $(CURDIR) .PHONY: lint-deps lint-deps: ## Install linter dependencies ## Keep versions in sync with tools/go.mod (see https://github.com/golang/go/issues/30515) @echo "==> Updating linter dependencies..." - GO111MODULE=on cd tools && go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.24.0 - GO111MODULE=on cd tools && go get github.com/client9/misspell/cmd/misspell@v0.3.4 - GO111MODULE=on cd tools && go get github.com/hashicorp/go-hclog/hclogvet@master + cd tools && GOBIN=$(CURDIR)/build/bin go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.24.0 + cd tools && GOBIN=$(CURDIR)/build/bin go get github.com/client9/misspell/cmd/misspell@v0.3.4 + cd tools && GOBIN=$(CURDIR)/build/bin go get github.com/hashicorp/go-hclog/hclogvet@master diff --git a/driver.go b/driver.go index 9c4c7388..0e2fb43e 100644 --- a/driver.go +++ b/driver.go @@ -19,12 +19,13 @@ package main import ( "context" "fmt" - "github.com/hashicorp/consul-template/signals" "os/user" "path/filepath" "strings" "time" + "github.com/hashicorp/consul-template/signals" + "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/go-hclog" @@ -356,12 +357,6 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive return nil, nil, fmt.Errorf("image name required") } - img, err := d.createImage(cfg, &driverConfig) - if err != nil { - return nil, nil, fmt.Errorf("Couldn't create image: %v", err) - } - d.logger.Debug("created/pulled image", "img_id", img.ID) - allArgs := []string{driverConfig.Image} if driverConfig.Command != "" { allArgs = append(allArgs, driverConfig.Command) @@ -690,54 +685,6 @@ func (d *Driver) ExecTask(taskID string, cmd []string, timeout time.Duration) (* return nil, fmt.Errorf("Podman driver does not support exec") } -func (d *Driver) createImage(cfg *drivers.TaskConfig, driverConfig *TaskConfig) (iopodman.InspectImageData, error) { - img, err := d.podmanClient.InspectImage(driverConfig.Image) - if err != nil { - err = d.eventer.EmitEvent(&drivers.TaskEvent{ - TaskID: cfg.ID, - AllocID: cfg.AllocID, - TaskName: cfg.Name, - Timestamp: time.Now(), - Message: "Downloading image", - Annotations: map[string]string{ - "image": driverConfig.Image, - }, - }) - if err != nil { - d.logger.Warn("error emitting event", "error", err) - } - - pullLog, err := d.podmanClient.PullImage(driverConfig.Image) - if err != nil { - return iopodman.InspectImageData{}, fmt.Errorf("image %s couldn't be downloaded: %v", driverConfig.Image, err) - } - - img, err = d.podmanClient.InspectImage(driverConfig.Image) - if err != nil { - return iopodman.InspectImageData{}, fmt.Errorf("image %s couldn't be inspected: %v", driverConfig.Image, err) - } - - err = d.eventer.EmitEvent(&drivers.TaskEvent{ - TaskID: cfg.ID, - AllocID: cfg.AllocID, - TaskName: cfg.Name, - Timestamp: time.Now(), - Message: fmt.Sprintf("Image downloaded: %s", pullLog), - Annotations: map[string]string{ - "image": driverConfig.Image, - }, - }) - if err != nil { - d.logger.Warn("error emitting event", "error", err) - } - - } - - d.logger.Debug("Image created", "img_id", img.ID, "config", img.Config) - - return img, nil -} - func (d *Driver) containerBinds(task *drivers.TaskConfig, driverConfig *TaskConfig) ([]string, error) { allocDirBind := fmt.Sprintf("%s:%s", task.TaskDir().SharedAllocDir, task.Env[taskenv.AllocDir]) taskLocalBind := fmt.Sprintf("%s:%s", task.TaskDir().LocalDir, task.Env[taskenv.TaskLocalDir])