From d4517f74dc2bd9d82a88c3e17b39acf29d5b89d8 Mon Sep 17 00:00:00 2001 From: Andreas Peters Date: Mon, 23 Aug 2021 23:38:45 +0200 Subject: [PATCH] add: suppress offers if every service are running. --- changelog.md | 1 + mesos/mesos.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/changelog.md b/changelog.md index d68722f..addf652 100644 --- a/changelog.md +++ b/changelog.md @@ -29,6 +29,7 @@ - Add mesos-cli plugin - Mesos-CLI: Show all running M3s frameworks - Mesos-CLI: Get kubeconfig from a selected running m3s +- Add supress offers if every services are running ## v0.0.4 diff --git a/mesos/mesos.go b/mesos/mesos.go index 2bb402d..ba48457 100644 --- a/mesos/mesos.go +++ b/mesos/mesos.go @@ -112,6 +112,7 @@ func Subscribe() error { case mesosproto.Event_HEARTBEAT: // K3S API Server Heatbeat K3SHeartbeat() + suppressFramework() case mesosproto.Event_OFFERS: restartFailedContainer() logrus.Debug("Offer Got: ", event.Offers.Offers[0].GetID()) @@ -221,6 +222,20 @@ func restartFailedContainer() { } } +// if all Tasks are running, suppress framework offers +func suppressFramework() { + if config.ETCDCount == config.ETCDMax && + config.K3SServerCount == config.K3SServerMax && + config.K3SAgentCount == config.K3SAgentMax { + + logrus.Info("Framework Suppress") + suppress := &mesosproto.Call{ + Type: mesosproto.Call_SUPPRESS, + } + Call(suppress) + } +} + /* default: // tell mesos he dont have to offer again until we ask