Skip to content

Commit

Permalink
Introduce configurable parameters for ES client node draining
Browse files Browse the repository at this point in the history
Add new configuration options to manage the draining of nodes in the Elasticsearch client within the ES-operator project. These settings include the number of retries and the minimum and maximum wait times for retries, enhancing the flexibility and control over the node draining process.

- ESClientDrainingRetry: Sets the number of retries for draining operations.
- ESClientDrainingMinWaitTime: Defines the minimum wait time between retry attempts.
- ESClientDrainingMaxWaitTime: Specifies the maximum wait time between retry attempts.

These parameters allow operators to tailor the draining behavior based on specific needs and conditions of their Elasticsearch clusters, ensuring more effective and reliable operations.
  • Loading branch information
Abouzar Kamaee committed Apr 25, 2024
1 parent 86f4ab2 commit db89841
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/url"
"os"
"os/signal"
"strconv"
"syscall"
"time"

Expand All @@ -21,27 +22,33 @@ import (
)

const (
defaultInterval = "10s"
defaultAutoscalerInterval = "30s"
defaultMetricsAddress = ":7979"
defaultClientGoTimeout = 30 * time.Second
defaultClusterDNSZone = "cluster.local."
defaultInterval = "10s"
defaultAutoscalerInterval = "30s"
defaultMetricsAddress = ":7979"
defaultClientGoTimeout = 30 * time.Second
defaultClusterDNSZone = "cluster.local."
defaultESClientDrainingRetry = 999
defaultESClientDrainingMinWaitTime = 10 * time.Second
defaultESClientDrainingMaxWaitTime = 30 * time.Second
)

var (
config struct {
Interval time.Duration
AutoscalerInterval time.Duration
APIServer *url.URL
PodSelectors Labels
PriorityNodeSelectors Labels
MetricsAddress string
ClientGoTimeout time.Duration
Debug bool
OperatorID string
Namespace string
ClusterDNSZone string
ElasticsearchEndpoint *url.URL
Interval time.Duration
AutoscalerInterval time.Duration
APIServer *url.URL
PodSelectors Labels
PriorityNodeSelectors Labels
MetricsAddress string
ClientGoTimeout time.Duration
Debug bool
OperatorID string
Namespace string
ClusterDNSZone string
ElasticsearchEndpoint *url.URL
ESClientDrainingRetry int
ESClientDrainingMinWaitTime time.Duration
ESClientDrainingMaxWaitTime time.Duration
}
)

Expand Down Expand Up @@ -69,6 +76,12 @@ func main() {
Default(defaultClusterDNSZone).StringVar(&config.ClusterDNSZone)
kingpin.Flag("elasticsearch-endpoint", "The Elasticsearch endpoint to use for reaching Elasticsearch API. By default the service endpoint for the EDS is used").
URLVar(&config.ElasticsearchEndpoint)
kingpin.Flag("elasticsearch-client-draining-retry", "Number of retries for node draining in Elasticsearch client in case of errors").
Default(strconv.Itoa(defaultESClientDrainingRetry)).IntVar(&config.ESClientDrainingRetry)
kingpin.Flag("elasticsearch-client-draining-min-wait-time", "Minimum wait time between retry attempts during node draining in Elasticsearch client").
Default(defaultESClientDrainingMinWaitTime.String()).DurationVar(&config.ESClientDrainingMinWaitTime)
kingpin.Flag("elasticsearch-client-draining-max-wait-time", "Maximum wait time between retry attempts during node draining in Elasticsearch client").
Default(defaultESClientDrainingMaxWaitTime.String()).DurationVar(&config.ESClientDrainingMaxWaitTime)
kingpin.Flag("namespace", "Limit operator to a certain namespace").
Default(v1.NamespaceAll).StringVar(&config.Namespace)

Expand Down

0 comments on commit db89841

Please sign in to comment.