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

docs: make the example for 'load' work #13102

Merged
merged 1 commit into from
May 27, 2022

Conversation

Vaelatern
Copy link
Contributor

Something I ran into when trying this.

@hashicorp-cla
Copy link

hashicorp-cla commented May 23, 2022

CLA assistant check
All committers have signed the CLA.

@the-maldridge
Copy link

s/label/load/ ?

@Vaelatern Vaelatern force-pushed the docker-default-decompress branch from 5e555df to d5008d9 Compare May 26, 2022 05:17
@Vaelatern Vaelatern changed the title docs: make the example for 'label' work docs: make the example for 'load' work May 26, 2022
@Amier3
Copy link
Contributor

Amier3 commented May 26, 2022

Hey @Vaelatern

Thanks for making this PR. I tested the original load example in the docs and you're right it doesn't seem to be working as intended. This might be another manifestation of #2443, since the main error I was getting was:

error="unable to open image archive: open fedora-latest/local/fedora-latest.tar: no such file or directory"

off of this task:


task "fedora_latest" {
driver = "docker"

artifact {
  source = "http://localhost:8000/fedora/fedora_latest.tar.gz" # This tar file generated straight from docker save -o 
}
config {
  load = "fedora_latest.tar.gz" 
  image = "fedora:latest"
}
}

I'll have to ask around to figure out what the intended behavior here is, to know if this is a bug or a documentation gap. In the meantime, could you share the (sanitized) job file you used to confirm that the options stanza was needed?

@tgross tgross self-assigned this May 26, 2022
@tgross
Copy link
Member

tgross commented May 26, 2022

This might be another manifestation of #2443, since the main error I was getting was:

error="unable to open image archive: open fedora-latest/local/fedora-latest.tar: no such file or directory"

The go-getter library used for artifact automatically unarchives .tar.gz (and .tar files after the fix for #2443 in #11481). See https://github.com/hashicorp/go-getter#unarchiving. So once the artifact is downloaded, it's getting automatically unpacked into a pile of files and there's no image for Docker to load.

Comment on lines 202 to 203
remote repository. Equivalent to the `docker load -i <filename>` command. Need
to tell nomad to keep the archive intact for this to work.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
remote repository. Equivalent to the `docker load -i <filename>` command. Need
to tell nomad to keep the archive intact for this to work.
remote repository. Equivalent to the `docker load -i <filename>` command.
If you're using an `artifact` block for the source of the archive, you'll need to
ensure that Nomad keeps the archive intact after download.

@tgross
Copy link
Member

tgross commented May 26, 2022

Reproduction (note that docker save -o does not compress the archive by default):

$ docker save -o busybox.tar busybox:1
$ file busybox.tar
busybox.tar: POSIX tar archive

$ sudo mv busybox.tar /srv/artifacts
$ nomad job run artifact-server.nomad
$ nomad job run example.nomad
artifact server jobspec
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", "artifacts",
          "-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
      }

    }
  }
}
jobspec using artifact
locals {
  auth_header = base64encode("artifacts:supersecret")
}

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

  group "web" {

    network {
      mode = "bridge"
      port "www" {
        to = 8001
      }
    }

    task "http" {

      artifact {
        source = "http://10.0.2.15:15101/busybox.tar"
        options {
          archive = false
        }
        headers {
          Authorization = "Basic ${local.auth_header}"
        }
      }

      driver = "docker"

      config {
        image   = "busybox:1"
        load    = "busybox.tar"
        command = "httpd"
        args    = ["-v", "-f", "-p", "8001", "-h", "/local"]
        ports   = ["www"]
      }

      template {
        data        = "<html>hello, world</html>"
        destination = "local/index.html"
      }

      resources {
        cpu    = 128
        memory = 128
      }

    }
  }
}

@tgross tgross added theme/docs Documentation issues and enhancements stage/waiting-reply backport/website This will backport PR changes to `stable-website` && the latest release-branch backport/1.1.x backport to 1.1.x release line backport/1.2.x backport to 1.1.x release line backport/1.3.x backport to 1.3.x release line labels May 26, 2022
@Vaelatern Vaelatern force-pushed the docker-default-decompress branch from d5008d9 to 44ca8ee Compare May 27, 2022 01:49
@Vaelatern
Copy link
Contributor Author

@tgross Pushed doc text change.

Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, 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 10, 2022
@Vaelatern Vaelatern deleted the docker-default-decompress branch October 12, 2022 01:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/website This will backport PR changes to `stable-website` && the latest release-branch backport/1.1.x backport to 1.1.x release line backport/1.2.x backport to 1.1.x release line backport/1.3.x backport to 1.3.x release line theme/docs Documentation issues and enhancements
Projects
Development

Successfully merging this pull request may close these issues.

5 participants