nomad icon indicating copy to clipboard operation
nomad copied to clipboard

Artifacts don't support "file" scheme

Open jippi opened this issue 10 years ago • 53 comments

Nomad version

Nomad v0.5.0-dev ('40d0a4e074b15ee056c5d5cc73d4a338cd19db72')

Operating system and Environment details

OS X

Issue

artifact stanza can't "download" files, example

artifact {
  source = "/opt/deploy/www/frontend/_infrastructure/consul-template/php-fpm.ctmpl"
  destination = "local/php-fpm.ctmpl"
}

yields

 {
     "Type": "Failed Artifact Download",
     "Time": 1477913991678771294,
     "FailsTask": false,
     "RestartReason": "",
     "SetupError": "",
     "DriverError": "",
     "ExitCode": 0,
     "Signal": 0,
     "Message": "",
     "KillTimeout": 0,
     "KillError": "",
     "KillReason": "",
     "StartDelay": 0,
     "DownloadError": "GET error: download not supported for scheme 'file'",
     "ValidationError": "",
     "DiskLimit": 0,
     "FailedSibling": "",
     "VaultError": "",
     "TaskSignalReason": "",
     "TaskSignal": ""
 }

jippi avatar Oct 31 '16 11:10 jippi

Nomad prevents arbitrary host file system access except for docker/rkt volume mounting and raw_exec; all of which can be disabled to lockdown a system and ensure containers can't access the host.

I'd like to keep the surface area for accessing the host file system to a minimum. Is there some compelling reason to use artifacts instead of volume mounts here?

schmichael avatar Oct 31 '16 16:10 schmichael

@schmichael today we got all the source/config files in each project's git repo, which we zip and move to each server. So i basically want to copy the config files from the host system into the alloc dir to be used by nomad.

Using volume mounts did not work either, since template{} seem to error of missing source file before both artifact downloads or docker mount volumes even gets executed (or so it seem from my test today)

jippi avatar Oct 31 '16 16:10 jippi

@schmichael though copying a file from the host system should be equally insecure as to downloading any random file from the internet, so seem like an weird omission to have :)

jippi avatar Oct 31 '16 19:10 jippi

@jippi What you can do in the meantime is running a web server hosting those files and use the artifact block. In a latter release we may add a set of directories that can be accessed. The issue right now is that if you allow arbitrary file downloads then you could access anyones alloc data which is bad.

As for downloading any file from the internet, we allow you to add the checksum for the file so you get what you expect.

dadgar avatar Oct 31 '16 21:10 dadgar

copying a file from the host system should be equally insecure as to downloading any random file from the internet, so seem like an weird omission to have :)

Also worth noting preventing copying from the host is to enforce container isolation, not secure containers against malicious code (which is what the checksum feature is for).

schmichael avatar Oct 31 '16 23:10 schmichael

@dadgar would be nice to have as an option for directly access indeed.. we run a single "monolith" environment where the entire box is trusted :)

Also our PHP-FPM, nginx and redis configuration is contained in the repo we deploy through nomad, so those files will only be available either directly on the host disk or inside the docker container, which the current Nomad setup doesn't work with out of the box.

I'm not sure about the best practice on this, but not being able to use the docker image content or the host file system seem very limiting to me.

I completely get this is the first release with this (awesome!) feature, and it need time to mature and grow into a more feature rich and secure solution over time - I'm just bummed that this was my silver bullet to putting everything into nomad, and now it doesn't seem like it will work without major changes to our 4 year old deployment strategy, causing me a bit of headache :)

jippi avatar Nov 01 '16 07:11 jippi

Additionally, having nomad in production / staging and development require different level of strictness.. for example running nomad on OS X to mirror production, running a separate server to serve files from the local environment is ... not ideal either.. it should be as simple as nomad run <file> and done.

Having it as a flag similar to raw_exec would be nice :)

jippi avatar Nov 01 '16 09:11 jippi

@dadgar @schmichael

What I'm looking for is to do one of the following things, to keep moving parts to a minimum

  • be able to artifact copy from the host fs
  • be able to artifact copy from a docker volume

all our app code lives as directories on the docker host machines, and we use a volume to map the code into our "execution container"

our repos contain all nginx/php-fpm/php-cli configuration files for that project in particular, so I need to find a way to get the configuration from a project directory into the alloc directory, without having to spin up an local nginx server just to work around the limitation of copy being disallowed.

i think it's a pretty tall requirement to have to service template files from a webserver, when the files already exist locally both in a docker volume and in the host filesystem.

any advice on how to make this a more sane setup is highly welcome

jippi avatar Nov 02 '16 11:11 jippi

Hey,

We will get the artifact from host working in 0.5.1. It is just a bit too much to plumb for 0.5

dadgar avatar Nov 02 '16 17:11 dadgar

@dadgar <3 ! :)

jippi avatar Nov 02 '16 17:11 jippi

@dadgar I'm running 0.5.1 here and I still get this error. Did it land and I'm missing something? :)

mongrelion avatar Dec 24 '16 13:12 mongrelion

I just got a GET error: download not supported for scheme 'file' on 0.5.2 as well.

dradtke avatar Jan 24 '17 05:01 dradtke

Sadly I didn't get to it in time for 0.5.3. I'll try again for 0.5.4.

We want to implement it such that the client has a whitelist of paths artifacts can be copied from to maintain a tunable level of encapsulation between tasks.

schmichael avatar Jan 24 '17 19:01 schmichael

did it get in yet @schmichael ? :)

jippi avatar May 30 '17 20:05 jippi

I'm also looking forward for this feature. Either being able to copy files from the host to the task or being able to provide an additional list of files to be copied to the chroot in the task level instead of the client config.

danlsgiga avatar Aug 29 '17 22:08 danlsgiga

I have a use case where one would have some templates already on the host and they just need to make it to the allocation directory. A workaround for sure is the web server to serve these files but sounds like an overkill for this case. You would be introducing yet another service into the moving parts of your system.

mongrelion avatar Sep 02 '17 14:09 mongrelion

Is this ever going to be addressed?

tkoestler avatar Aug 20 '18 13:08 tkoestler

Is using the local filesystem as the artifact source on the horizon at all? I need nomad to work with the artifacts already on the servers box as contacting an external api isn't possible and spinning up a web server does seem like over kill especially when the go getter library does support the file scheme. Or is there some specific reason for this option being excluded? I'm running 0.8.6 and still getting this error message.

danapoklepovich avatar Nov 27 '18 04:11 danapoklepovich

Any news on that ?

LordFPL avatar Jan 21 '19 08:01 LordFPL

Hello, is there anyone there? Would really like to know if this is ever likely to be implemented? If not could someone update the issue with appropriate comments and then close it off?

Seems strange that I can't do this BUT I can map a directory using chroot_env.

andye2004 avatar Mar 01 '19 13:03 andye2004