From 5dd54053a0d93333bcd3ce6d24bce5a58015dd33 Mon Sep 17 00:00:00 2001 From: yunus shaikh Date: Thu, 22 May 2025 11:50:01 +0530 Subject: [PATCH] Fix: downtime registration without duration now sets default value and update docs too --- docs/deployment.md | 2 ++ go/inst/downtime.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/docs/deployment.md b/docs/deployment.md index a125e9926..8fb4b12e2 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -94,6 +94,8 @@ Shown above are uses for both `orchestrator-client` and the `orchestrator` comma ```shell $ curl -s "http://my.orchestrator.service:80/api/begin-downtime/my.hostname/3306/wallace/experimenting+failover/45m" ``` +`45m` is duration of time in minutes the host will be marked under downtime. +If we don't mention the time, it would consider `config.MaintenanceExpireMinutes` time as downtime which is default 10m The `orchestrator-client` script runs this very API call, wrapping it up and encoding the URL path. It can also automatically detect the leader, in case you don't want to run through a proxy. diff --git a/go/inst/downtime.go b/go/inst/downtime.go index 90ab2ece2..c5e4feb4e 100644 --- a/go/inst/downtime.go +++ b/go/inst/downtime.go @@ -18,8 +18,10 @@ package inst import ( "time" + "github.com/openark/orchestrator/go/config" ) + type Downtime struct { Key *InstanceKey Owner string @@ -32,6 +34,9 @@ type Downtime struct { } func NewDowntime(instanceKey *InstanceKey, owner string, reason string, duration time.Duration) *Downtime { + if duration == 0 { + duration = config.MaintenanceExpireMinutes * time.Minute + } downtime := &Downtime{ Key: instanceKey, Owner: owner,