Skip to content

Commit

Permalink
Remove web hamdler. (Breaking change) (#254)
Browse files Browse the repository at this point in the history
This change removes the support for HTTP Callbacs.
This mechanism is deprecated and will be removed in
futre Marathon releases.

Breaking changes:

* Remove `sse-enabled` and `web-enabled` flags

Fixes: #253
  • Loading branch information
janisz authored Aug 2, 2017
1 parent b1c1ec5 commit 8bd1b1c
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 404 deletions.
22 changes: 8 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,15 @@ your cert store might be different depending on your system.
docker run '/etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt' -P allegro/marathon-consul
```

## Setting up `marathon-consul` after installation

The Marathon [event bus](https://mesosphere.github.io/marathon/docs/event-bus.html) should point to [`/events`](#endpoints). You can set up the event subscription with a call similar to this one:
```
curl -X POST 'http://marathon.service.consul:8080/v2/eventSubscriptions?callbackUrl=http://marathon-consul.service.consul:4000/events'
```
The event subscription should be set to `localhost` to reduce network traffic.

## Usage

### Marathon masters

- marathon-consul should be installed on all Marathon masters

### Mesos slaves
### Mesos agents

- Consul Agents should be available on every Mesos slave.
- Consul Agents should be available on every Mesos agent.
- Tasks will be registered at the Mesos slave they run on.

### Tagging tasks
Expand Down Expand Up @@ -236,15 +228,12 @@ sync-enabled | `true` | Enable Marathon-consul scheduled
sync-force | `false` | Force leadership-independent Marathon-consul sync (run always)
sync-interval | `15m0s` | Marathon-consul sync interval
workers-pool-size | `10` | Number of concurrent workers processing events
sse-enabled | `false` | Enable marathon-consul SSE on this node
web-enabled | `true` | Enable marathon-consul Web callbacks on this node

### Endpoints

Endpoint | Description
----------|------------------------------------------------------------------------------------
`/health` | healthcheck - returns `OK`
`/events` | event sink - returns `OK` if all keys are set in an event, error message otherwise

## Advanced usage

Expand Down Expand Up @@ -322,14 +311,19 @@ reregister all healthy services managed by marathon-consul to the new format. Un

## SSE Support

In future callback interface between marathon and marathon-consul will be replaced by SSE.
While using SSE please consider:
- SSE is using Web module config for queues, event sizes, in the future will be moved to sse module,
- SSE is using marathon-leader config for determining current leader, when this value match leader returned by marathon (/v2/leader endpoint)
then SSE is started on this instance,
- when enabled SSE is spawning its own own set of workers and separated dispatcher,
- be advised to disable marathon callback subscription when enabling SSE, otherwise it might result in doubling registers and deregisers.

## HTTP callbacks support

Marathon-Consul does not support HTTP callbacks.
Marathon [deprecated support for HTTP callbacks in 1.4](https://github.com/mesosphere/marathon/blob/master/changelog.md#deprecate-event-callback-subscriptions).
This mechanism is no longer available starting from [Marathon 1.5](https://github.com/mesosphere/marathon/blob/master/changelog.md#event-subscribers-has-been-removed).

## Known limitations

The following section describes known limitations in `marathon-consul`.
Expand Down
2 changes: 0 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,8 @@ func (config *Config) parseFlags() {
flag.IntVar(&config.Web.QueueSize, "events-queue-size", 1000, "Size of events queue")
flag.IntVar(&config.Web.WorkersCount, "workers-pool-size", 10, "Number of concurrent workers processing events")
flag.Int64Var(&config.Web.MaxEventSize, "event-max-size", 4096, "Maximum size of event to process (bytes)")
flag.BoolVar(&config.Web.Enabled, "web-enabled", true, "Enable web events (callbacks).")

// SSE
flag.BoolVar(&config.SSE.Enabled, "sse-enabled", false, "Enable sse event stream.")

// Sync
flag.BoolVar(&config.Sync.Enabled, "sync-enabled", true, "Enable Marathon-consul scheduled sync")
Expand Down
5 changes: 1 addition & 4 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,8 @@ func TestConfig_ShouldBeMergedWithFileDefaultsAndFlags(t *testing.T) {
QueueSize: 1000,
WorkersCount: 10,
MaxEventSize: 4096,
Enabled: true,
},
SSE: sse.Config{
Enabled: false,
},
SSE: sse.Config{},
Sync: sync.Config{
Interval: timeutil.Interval{Duration: 15 * time.Minute},
Enabled: true,
Expand Down
4 changes: 1 addition & 3 deletions debian/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
"Listen": ":4000",
"QueueSize": 1000,
"WorkersCount": 10,
"MaxEventSize": 4096,
"Enabled": true
"MaxEventSize": 4096
},
"SSE": {
"Enabled": false
},
"Sync": {
"Enabled": true,
Expand Down
26 changes: 0 additions & 26 deletions events/web_events.go

This file was deleted.

44 changes: 0 additions & 44 deletions events/web_events_test.go

This file was deleted.

10 changes: 2 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,13 @@ func main() {

sync.New(config.Sync, remote, consulInstance, consulInstance.AddAgentsFromApps).StartSyncServicesJob()

if config.SSE.Enabled {
go func() {
stopSSE, err := sse.NewHandler(config.SSE, config.Web, remote, consulInstance)
if err != nil {
log.WithError(err).Fatal("Cannot instantiate SSE handler")
}
defer stopSSE()
}

if config.Web.Enabled {
handler, stop := web.NewHandler(config.Web, remote, consulInstance)
defer stop()
http.HandleFunc("/events", handler)
}
}()

http.HandleFunc("/health", web.HealthHandler)

Expand Down
1 change: 0 additions & 1 deletion sse/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package sse

type Config struct {
Enabled bool
Retries int
RetryBackoff int
}
1 change: 0 additions & 1 deletion web/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ type Config struct {
QueueSize int
WorkersCount int
MaxEventSize int64
Enabled bool
}
31 changes: 0 additions & 31 deletions web/web.go

This file was deleted.

82 changes: 0 additions & 82 deletions web/web_handler.go

This file was deleted.

Loading

0 comments on commit 8bd1b1c

Please sign in to comment.