deis/deis — pull request #1665 by gabrtv (2014-08-21 16:22:27+00:00)
Title: Application tags for scheduling to specific hosts

A tag is a key/value pair used to attach scheduling metadata to an application's containers. This is typically used to restrict containers to specific hosts, though it can have other uses in the context of a scheduler. In this PR, we are passing the tags through to Fleet's `X-ConditionMachineMetadata`.

Closes #1376. Refs #1480.

## Developer Workflow

```console
$ deis tags
=== example-go Tags
No tags defined

$ deis tags:set environ=dev
Applying tags... done, v3

=== example-go Tags
environ dev

$ deis releases
=== example-go Releases
v3 18 minutes ago gabrtv added tag environ
v2 19 minutes ago gabrtv deployed gabrtv/example-go:latest
v1 20 minutes ago gabrtv created initial release

$ deis tags:unset environ
Applying tags... done, v4

=== example-go Tags
No tags defined
```
## Testing Instructions

**Important**: In order to test this PR, you must configure Fleet with matching tag key/values.

### Configure Fleet Metadata

On your CoreOS hosts:

```console
$ sudo -i
# mkdir -p /etc/fleet
# echo 'metadata="environ=dev,foo=bar"' >> /etc/fleet/fleet.conf
# systemctl restart fleet
```

More detailed instructions can be found here:

### Create an Application

```console
$ mkdir -p /tmp/example-go && cd /tmp/example-go

$ deis create
Creating application... done, created example-go

$ deis pull gabrtv/example-go:latest
Creating build... done, v2

$ deis ps
=== example-go Processes

--- cmd:
cmd.1 up (v2)

$ deis tags:set environ=dev
Applying tags... done, v3

=== example-go Tags
environ dev
```

## Known Issues

If you use `tags:set` and the scheduler cannot find a matching host, the API call will hang and eventually timeout. This is due to the way the underlying scheduler behaves (no explicit error if no matching host found). To resolve this, simply CTRL-C from the CLI command and use `deis tags:unset`.