TritonDataCenter / containerpilot

A service for autodiscovery and configuration of applications running in containers
Mozilla Public License 2.0
1.13k stars 135 forks source link

Allow a job to be configured with multiple watches #518

Open Smithx10 opened 7 years ago

Smithx10 commented 7 years ago

While using Containerpilot I ran into the situation where I wanted 1 job to respond to multiple watches.

This is what I ended up doing:

  jobs: [
    {
      name: "update-haproxy-http",
      exec: "reload",
      when: {
        source: "watch.l7-http",
        each: "changed"
      }
    },
    {
      name: "update-haproxy-https",
      exec: "reload",
      when: {
        source: "watch.l7-http2",
        each: "changed"
      }
    },

This is the type of functionality I wanted:

  jobs: [
    {
      name: "update-haproxy-http",
      exec: "reload",
      when: {
        source: [ "watch.l7-http", "watch.l7-http2" ],
        each: "changed"
      }
    }

While attempting to use the functionality I wanted I received, It said that source required a string. You can see that here:

// WhenConfig determines when a Job runs (dependencies on other Jobs,
// Watches, or frequency timers)
type WhenConfig struct {
    Frequency string `mapstructure:"interval"`
    Source    string `mapstructure:"source"`
    Once      string `mapstructure:"once"`
    Each      string `mapstructure:"each"`
    Timeout   string `mapstructure:"timeout"`
}

https://github.com/joyent/containerpilot/blob/master/jobs/config.go#L61

jwreagor commented 7 years ago

Appreciate the feature request Bruce. Off the bat, I'm not sure why this wasn't considered before as it seems to make perfect sense. Nothing comes up when I'm searching through potential issues. It's possible @misterbisson might remember something about configuring multiple watches on a job.

In any case, we're planning to visit watches again with #506. That might be a good time to consider this as well.

misterbisson commented 7 years ago

There was some discussion, though it may not have been captured in the design docs, about the challenges of supporting multiple watches vs also being able to merge config files and have some config settings replace or override those in prior files.