containerpilot icon indicating copy to clipboard operation
containerpilot copied to clipboard

Allow a job to be configured with multiple watches

Open Smithx10 opened this issue 7 years ago • 2 comments

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

Smithx10 avatar Oct 15 '17 00:10 Smithx10

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.

jwreagor avatar Oct 15 '17 01:10 jwreagor

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.

misterbisson avatar Oct 15 '17 13:10 misterbisson