Skip to content

Modernize Nomad driver for Singularity/Apptainer: dynamic binary detection, new container flags, bug fixes#1

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/modernize-nomad-driver
Draft

Modernize Nomad driver for Singularity/Apptainer: dynamic binary detection, new container flags, bug fixes#1
Copilot wants to merge 3 commits intomasterfrom
copilot/modernize-nomad-driver

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 23, 2026

Modernizes the nomad-driver-singularity task driver to work with current Go versions, adds Apptainer support, fixes several bugs, and exposes missing Singularity/Apptainer CLI flags.

Dependency Updates

  • hashicorp/nomad bumped from v0.9.0-rc2v0.12.12 — fixes a runtime panic caused by the old ugorji/go codec using a duplicate-character base64 alphabet rejected by Go 1.22+
  • hashicorp/go-hclog updated to latest
  • github.com/sylabs/singularity removed — was only used to supply the hardcoded version string "3.1.1"
  • go 1.21 language directive added to go.mod

Apptainer Support + Dynamic Binary/Version Detection

  • Removed the hardcoded /usr/local/bin/singularity constant
  • New findBinary(configured string) helper: returns the configured path if set, otherwise searches $PATH for singularity then apptainer
  • New getVersion(binPath string) helper: runs <bin> version and returns the live output instead of the static string "3.1.1"
  • New driver config option singularity_path so operators can point directly at /usr/bin/apptainer
  • Removed the init() function in main.go that called useragent.InitValue("singularity", "3.1.1")
plugin "nomad-driver-singularity" {
  config {
    enabled          = true
    singularity_path = "/usr/bin/apptainer"
  }
}

New Task Config Flags

HCL key Singularity/Apptainer flag
containall --containall
writable_tmpfs --writable-tmpfs
net --net
hostname --hostname

Bug Fixes

  • Duplicate SetDriverState call in StartTask — the second identical call was removed
  • timeout * time.Second in shutdown()timeout is already a time.Duration; multiplying it by time.Second was producing vastly inflated timeouts
  • Missing NoCgroups bool in the Config struct — no_cgroups was declared in configSpec but never decoded into the struct
  • ioutil.Discard replaced with io.Discard

Other Changes

  • examples/example.hcl: added the MPL 2.0 license header
  • README.md: updated requirements (Nomad v0.12+, Go v1.21+, Apptainer v1.0+ as alternative), added full driver config and task config reference tables with Apptainer usage example, and added step-by-step testing instructions for running the driver on a Nomad client node
  • Tests: added TestFindBinary and TestPrepareContainer (9 sub-tests covering all new flags)
  • gofmt applied to all changed Go files

Testing

  • go build ./... passes
  • go vet ./... passes
  • ✅ All 11 tests pass (go test ./...)
  • ✅ CodeQL security scan: 0 alerts
  • gofmt formatting applied

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

@abhi18av
Copy link
Copy Markdown
Member

@copilot summarize all changes

Copy link
Copy Markdown
Author

Copilot AI commented Mar 23, 2026

@copilot summarize all changes

Here's a summary of all changes made across the two commits:


Dependencies (go.mod / go.sum)

  • hashicorp/nomad bumped from v0.9.0-rc2v0.12.12 — fixes a runtime panic caused by the old ugorji/go codec using a duplicate-character base64 alphabet that Go 1.22+ rejects
  • hashicorp/go-hclog updated to latest
  • github.com/sylabs/singularity removed — was only used to supply the hardcoded version string "3.1.1"
  • go 1.21 language directive added to go.mod

Apptainer support + dynamic binary/version detection (driver.go, singularity.go, main.go)

  • Removed the hardcoded /usr/local/bin/singularity constant
  • New findBinary(configured string) helper: returns the configured path if set, otherwise searches $PATH for singularity then apptainer
  • New getVersion(binPath string) helper: runs <bin> version and returns the live output instead of the static string "3.1.1"
  • New driver config option singularity_path so operators can point directly at /usr/bin/apptainer
  • Removed the init() function in main.go that called useragent.InitValue("singularity", "3.1.1")

New task config flags (driver.go, prepare.go)

HCL key Singularity/Apptainer flag Addresses issue
containall --containall hpcng#35
writable_tmpfs --writable-tmpfs hpcng#36
net --net hpcng#33
hostname --hostname hpcng#28

Bug fixes (driver.go, handle.go, prepare.go)

  • Duplicate SetDriverState call in StartTask — the second identical call was removed
  • timeout * time.Second in shutdown()timeout is already a time.Duration; multiplying it by time.Second was incorrect (e.g. a 30s timeout became 30 × 10⁹ seconds)
  • Missing NoCgroups bool in the Config struct — no_cgroups was declared in configSpec but never decoded into the struct
  • ioutil.Discard replaced with io.Discard (standard library, not deprecated)

Other

  • examples/example.hcl: added the MPL 2.0 license header (issue example.hcl: no license hpcng/nomad-driver-singularity#29)
  • README.md: updated requirements (Nomad v0.12+, Go v1.21+, Apptainer v1.0+ as alternative), added full driver config and task config reference tables, Apptainer usage example
  • Tests (driver_test.go): added TestFindBinary and TestPrepareContainer (9 sub-tests covering all new flags)
  • gofmt applied to all changed Go files

Copilot AI changed the title Analysis for modernizing Nomad driver for Singularity Modernize Nomad driver for Singularity/Apptainer: dynamic binary detection, new container flags, bug fixes Mar 23, 2026
Copilot AI requested a review from abhi18av March 23, 2026 09:06
@abhi18av
Copy link
Copy Markdown
Member

@copilot create testing instructions, assuming a nomad client running on a compute node with proper singularity/apptainer setup.

Copy link
Copy Markdown
Author

Copilot AI commented Mar 24, 2026

@copilot create testing instructions, assuming a nomad client running on a compute node with proper singularity/apptainer setup.

Added a "Testing on a Nomad client node" section to README with step-by-step instructions for validating the driver on a compute node (build/install, config, runtime check, smoke-test job, and log inspection). Commit: 95ce0ba.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants