Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

artifacts: does not automatically unpack .tar archives #2443

Closed
stefreak opened this issue Mar 13, 2017 · 6 comments · Fixed by #11481
Closed

artifacts: does not automatically unpack .tar archives #2443

stefreak opened this issue Mar 13, 2017 · 6 comments · Fixed by #11481
Assignees
Milestone

Comments

@stefreak
Copy link

Nomad version

Nomad v0.5.4

Operating system and Environment details

Ubuntu

Issue

Does not unpack .tar, only zipped archives.

Expected behaviour: also unpack .tar archives

Reproduction steps

      artifact {
        source      = "https://example.com/file.tar"
      }
@stefreak stefreak changed the title Nomad artifacts: does not automatically decompress .tar Nomad artifacts: does not automatically unpack .tar Mar 13, 2017
@stefreak stefreak changed the title Nomad artifacts: does not automatically unpack .tar Nomad artifacts: does not automatically unpack .tar archives Mar 13, 2017
@stefreak stefreak changed the title Nomad artifacts: does not automatically unpack .tar archives artifacts: does not automatically unpack .tar archives Mar 13, 2017
@dadgar
Copy link
Contributor

dadgar commented Mar 13, 2017

Hey can you file and cross link against https://github.com/hashicorp/go-getter

@dadgar dadgar closed this as completed Mar 13, 2017
@stefreak
Copy link
Author

go-getter issue: hashicorp/go-getter#19

@ketzacoatl
Copy link
Contributor

AFAICT, this is still an issue in that Nomad does not yet support unpacking .tar archives, and while hashicorp/go-getter#19 is still open, it seems that go-getter does now support .tar archives (see https://github.com/hashicorp/go-getter/blob/master/decompress_tar.go).

@dadgar, does nomad support decompressing .tar archives, or should this ticket be re-opened?

@tgross
Copy link
Member

tgross commented Nov 8, 2021

This was a very old bug that got re-opened, so I wanted to make sure it hadn't been opened accidentally. But I was able to confirm this is still broken! The specific behavior is with uncompressed .tar archives and not with compressed .tar.gz archives, which is probably why no one has realized this was still a problem years later.

artifact to run
#!/usr/bin/env sh

while :
do
    echo "sleeping..."
    sleep 2
done

On our Vagrant development box, you can prep this artifact to be served as follows:

tar -cf sleeper.tar ./sleeper.sh
tar -czf sleeper.tar.gz ./sleeper.sh
sudo mkdir -p /srv/artifacts
sudo mv sleeper.tar* /srv/artifacts

Run the artifact server:

jobspec for an artifact server
job "artifacts" {
  datacenters = ["dc1"]
  type        = "system"

  group "artifacts" {

    network {
      mode = "bridge"
      port "www" {
        static = 15101
        to     = 8000
      }
    }

    task "httpd" {

      driver = "docker"

      config {
        image   = "busybox:1"
        command = "httpd"
        args = [
          "-v", "-f",
          "-p", "8000",
          "-u", "www-data:www-data",
          "-h", "/srv",
          "-r", "artfiacts",
          "-c", "/local/httpd.conf",
        ]

        mount {
          type     = "bind"
          target   = "/srv"
          source   = "/srv/artifacts"
          readonly = true
        }

        ports = ["www"]
      }

      template {
        # HTTP Basic Auth username: "artifacts", password: "supersecret"
        data = <<EOT
/:artifacts:$1$iSV64UXs$IWot5UKWBzka6VskUSFWm0
EOT

        destination = "local/httpd.conf"
      }

      resources {
        cpu    = 128
        memory = 128
      }

    }
  }
}

And then try to run the following job:

jobspec that uses this artifact
locals {
  auth_header = base64encode("artifacts:supersecret")
}

job "example" {
  datacenters = ["dc1"]

  group "sleeper" {

    task "sleeper" {

      artifact {
        source      = "http://localhost:15101/sleeper.tar"

        # but .tar.gz works:
        # source      = "http://localhost:15101/sleeper.tar.gz"

        headers {
          Authorization = "Basic ${local.auth_header}"
        }
      }

      driver = "exec"
      config {
        command = "/local/sleeper.sh"
      }

    }
  }
}

If the .tar file is used, it'll be dropped as-is into /local and fail. Whereas if the tar.gz file is used, it'll be decompressed and unpacked so that the task can use it.

@tgross tgross self-assigned this Nov 8, 2021
@ketzacoatl
Copy link
Contributor

Yay! Thank you!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Development

Successfully merging a pull request may close this issue.

5 participants