1

I have the following Nomad job:

job "aws_s3_copy_rev2" {
  datacenters = ["dc1"]
  type = "system"

  group "aws_s3_copy_rev2" {
    count = 1

    task "aws_s3_copy_rev2" {
      driver = "raw_exec"

      artifact {
        source = "s3::https://my-data-files/123/"
      }

      resources {
        cpu    = 500 # 500 MHz
        memory = 256 # 256MB
        network {
          port "http" {}
        }
      }
    }
  }
}

I submitted the job using nomad run aws_s3_copy_rev2.nomad. But I do not know where the file is downloaded to. Where does the Nomad put the downloaded S3 files?

This is my configuration file for starting the Nomad agent.

# Increase log verbosity
log_level = "DEBUG"

# Setup data dir
data_dir = "/tmp/client1"

# Give the agent a unique name. Defaults to hostname
name = "client1"

# Enable the client
client {
    enabled = true

    # For demo assume we are talking to server1. For production,
    # this should be like "nomad.service.consul:4647" and a system
    # like Consul used for service discovery.
    servers = ["xxx:4647"]
    options {
      "driver.raw_exec.enable" = "1"
    }
}

# Modify our port to avoid a collision with server1
ports {
    http = 5657
}
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
LifeAndHope
  • 674
  • 2
  • 10
  • 27

2 Answers2

3

Usually artifacts are stored in the allocation folder off your Nomad allocation, which in the default case would be /etc/nomad.d/alloc/<alloc_id>/<task>/local/<your_file.ext> on Linux machines. Not sure where things land on other OSes.

In this case, your data_dir is set to /tmp/client1, so I would expect the files would be somewhere like /tmp/client1/alloc/<alloc_id>/<task>/local/<your_file.ext>.

It is important to note that these artifacts are generated on the Nomad 'client' running an allocation of your job, not the machine you are starting the job from.

Also, you might want to be careful rooting your Nomad data directory in the /tmp folder as it might get periodically deleted, which might explain why you cannot find those files.

Chris Zacharias
  • 608
  • 5
  • 7
1

You can reference this directory in nomad environment as ${NOMAD_TASK_DIR} and access or execute the file using the path:

artifact {
    source = "s3::https://some-bucket/code/archive-logs.sh"
    destination = "/local/"
  }

  driver = "raw_exec"
  kill_timeout = "120s"

  config {
    command = "/bin/bash"
    args = ["${NOMAD_TASK_DIR}/archive-logs.sh","7"]
  }
dovka
  • 971
  • 1
  • 8
  • 20