Skip to content

Commit 78faf44

Browse files
authored
HTTPS Configurable Timeout (#221)
1 parent 07f8cd5 commit 78faf44

File tree

8 files changed

+37
-38
lines changed

8 files changed

+37
-38
lines changed

README.md

+21-19
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,25 @@ Cloudability Metrics Agent currently does not support OpenShift, Rancher or On P
3636

3737
### Configuration Options
3838

39-
| Environment Variable | Description |
40-
|--------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
41-
| CLOUDABILITY_API_KEY | Required: Cloudability api key |
42-
| CLOUDABILITY_CLUSTER_NAME | Required: The cluster name to be used for the cluster the agent is running in. |
43-
| CLOUDABILITY_POLL_INTERVAL | Optional: The interval (Seconds) to poll metrics. Default: 180 |
44-
| CLOUDABILITY_OUTBOUND_PROXY | Optional: The URL of an outbound HTTP/HTTPS proxy for the agent to use (eg: http://x.x.x.x:8080). The URL must contain the scheme prefix (http:// or https://) |
45-
| CLOUDABILITY_OUTBOUND_PROXY_AUTH | Optional: Basic Authentication credentials to be used with the defined outbound proxy. If your outbound proxy requires basic authentication credentials can be defined in the form username:password |
46-
| CLOUDABILITY_OUTBOUND_PROXY_INSECURE | Optional: When true, does not verify TLS certificates when using the outbound proxy. Default: False |
47-
| CLOUDABILITY_INSECURE | Optional: When true, does not verify certificates when making TLS connections. Default: False |
48-
| CLOUDABILITY_FORCE_KUBE_PROXY | Optional: When true, forces agent to use the proxy to connect to nodes rather than attempting a direct connection. Default: False |
49-
| CLOUDABILITY_COLLECTION_RETRY_LIMIT | Optional: Number of times agent should attempt to gather metrics from each source upon a failure Default: 1 |
50-
| CLOUDABILITY_NAMESPACE | Optional: Override the namespace that the agent runs in. It is not recommended to change this as it may negatively affect the agents ability to collect data. Default: `cloudability` |
51-
| CLOUDABILITY_LOG_FORMAT | Optional: Format for log output (JSON,PLAIN) Default: PLAIN |
52-
| CLOUDABILITY_LOG_LEVEL | Optional: Log level to run the agent at (INFO,WARN,DEBUG,TRACE). Default: `INFO` |
53-
| CLOUDABILITY_SCRATCH_DIR | Optional: Temporary directory that metrics will be written to. If set, must assure that the directory exists and that the user agent UID 1000 has read/write access to the folder. Default: `/tmp` |
54-
| CLOUDABILITY_NUMBER_OF_CONCURRENT_NODE_POLLERS | Optional: Number of goroutines that are created to poll node metrics in parallel. Default: `100` |
55-
| CLOUDABILITY_INFORMER_RESYNC_INTERVAL | Optional: Period of time (in hours) that the informers will fully resync the list of running resources. Default: 24 hours. Can be set to 0 to never resync |
56-
| CLOUDABILITY_PARSE_METRIC_DATA | Optional: When true, core files will be parsed and non-relevant data will be removed prior to upload. Default: `false` |
39+
| Environment Variable | Description |
40+
|------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
41+
| CLOUDABILITY_API_KEY | Required: Cloudability api key |
42+
| CLOUDABILITY_CLUSTER_NAME | Required: The cluster name to be used for the cluster the agent is running in. |
43+
| CLOUDABILITY_POLL_INTERVAL | Optional: The interval (Seconds) to poll metrics. Default: 180 |
44+
| CLOUDABILITY_OUTBOUND_PROXY | Optional: The URL of an outbound HTTP/HTTPS proxy for the agent to use (eg: http://x.x.x.x:8080). The URL must contain the scheme prefix (http:// or https://) |
45+
| CLOUDABILITY_OUTBOUND_PROXY_AUTH | Optional: Basic Authentication credentials to be used with the defined outbound proxy. If your outbound proxy requires basic authentication credentials can be defined in the form username:password |
46+
| CLOUDABILITY_OUTBOUND_PROXY_INSECURE | Optional: When true, does not verify TLS certificates when using the outbound proxy. Default: False |
47+
| CLOUDABILITY_INSECURE | Optional: When true, does not verify certificates when making TLS connections. Default: False |
48+
| CLOUDABILITY_FORCE_KUBE_PROXY | Optional: When true, forces agent to use the proxy to connect to nodes rather than attempting a direct connection. Default: False |
49+
| CLOUDABILITY_COLLECTION_RETRY_LIMIT | Optional: Number of times agent should attempt to gather metrics from each source upon a failure Default: 1 |
50+
| CLOUDABILITY_NAMESPACE | Optional: Override the namespace that the agent runs in. It is not recommended to change this as it may negatively affect the agents ability to collect data. Default: `cloudability` |
51+
| CLOUDABILITY_LOG_FORMAT | Optional: Format for log output (JSON,PLAIN) Default: PLAIN |
52+
| CLOUDABILITY_LOG_LEVEL | Optional: Log level to run the agent at (INFO,WARN,DEBUG,TRACE). Default: `INFO` |
53+
| CLOUDABILITY_SCRATCH_DIR | Optional: Temporary directory that metrics will be written to. If set, must assure that the directory exists and that the user agent UID 1000 has read/write access to the folder. Default: `/tmp` |
54+
| CLOUDABILITY_NUMBER_OF_CONCURRENT_NODE_POLLERS | Optional: Number of goroutines that are created to poll node metrics in parallel. Default: `100` |
55+
| CLOUDABILITY_INFORMER_RESYNC_INTERVAL | Optional: Period of time (in hours) that the informers will fully resync the list of running resources. Default: 24 hours. Can be set to 0 to never resync |
56+
| CLOUDABILITY_PARSE_METRIC_DATA | Optional: When true, core files will be parsed and non-relevant data will be removed prior to upload. Default: `false` |
57+
| CLOUDABILITY_HTTPS_CLIENT_TIMEOUT | Optional: Amount (in seconds) of time the http client has before timing out requests. Might need to be increased to clusters with large payloads. Default: `60` |
5758

5859
```sh
5960

@@ -79,8 +80,9 @@ Flags:
7980
--poll_interval int Time, in seconds, to poll the services infrastructure. Default: 180 (default 180)
8081
--namespace string The namespace which the agent runs in. Changing this is not recommended. (default `cloudability`)
8182
--informer_resync_interval int The amount of time, in hours, between informer resyncs. (default 24)
82-
--number_of_concurrent_node_pollers int The number of goroutines that are created to poll node metrics in parallel. (default: `100`)
83+
--number_of_concurrent_node_pollers int The number of goroutines that are created to poll node metrics in parallel. (default `100`)
8384
--parse_metric_data bool When true, core files will be parsed and non-relevant data will be removed prior to upload. (default `false`)
85+
--https_client_timeout int Amount (in seconds) of time the https client has before timing out requests. (default `60`)
8486
Global Flags:
8587
--log_format string Format for log output (JSON,PLAIN) (default "PLAIN")
8688
--log_level string Log level to run the agent at (INFO,WARN,DEBUG) (default "INFO")

charts/metrics-agent/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ type: application
1414

1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
17-
version: 2.11.9
17+
version: 2.11.10
1818

1919
# This is the version number of the application being deployed. This version number should be
2020
# incremented each time you make changes to the application.
21-
appVersion: 2.11.9
21+
appVersion: 2.11.10

charts/metrics-agent/values.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pollInterval: 180
2424

2525
image:
2626
name: cloudability/metrics-agent
27-
tag: 2.11.9
27+
tag: 2.11.10
2828
pullPolicy: Always
2929

3030
imagePullSecrets: []

client/client.go

-3
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ type Configuration struct {
6161
// NewHTTPMetricClient will configure a new instance of a Cloudability client.
6262
func NewHTTPMetricClient(cfg Configuration) (MetricClient, error) {
6363

64-
if cfg.Timeout.Seconds() > 60 {
65-
return nil, errors.New("A valid timeout is required (between 1s and 60s")
66-
}
6764
if !validToken.MatchString(cfg.Token) {
6865
return nil, errors.New("Token format is invalid (only alphanumeric are allowed)")
6966
}

client/client_test.go

-12
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@ func TestClientCreation(t *testing.T) {
3636
t.Error("Expected client to successfully create")
3737
}
3838
})
39-
40-
t.Run("timeout greater than 60s rejected", func(t *testing.T) {
41-
_, err := client.NewHTTPMetricClient(client.Configuration{
42-
Timeout: 61 * time.Second,
43-
Token: test.SecureRandomAlphaString(20),
44-
BaseURL: "https://cloudability.com",
45-
MaxRetries: 2,
46-
})
47-
if err == nil {
48-
t.Error("Expected error when passing timeout of 61s")
49-
}
50-
})
5139
}
5240

5341
func TestSendMeasurement(t *testing.T) {

cmd/kubernetesCmd.go

+8
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ func init() {
126126
false,
127127
"When true, core files will be parsed and non-relevant data will be removed prior to upload. Default: False",
128128
)
129+
kubernetesCmd.PersistentFlags().IntVar(
130+
&config.HTTPSTimeout,
131+
"https_client_timeout",
132+
60,
133+
"Amount (in seconds) of time the https client has before timing out requests. Default 60",
134+
)
129135

130136
//nolint gas
131137
_ = viper.BindPFlag("api_key", kubernetesCmd.PersistentFlags().Lookup("api_key"))
@@ -149,6 +155,7 @@ func init() {
149155
_ = viper.BindPFlag("number_of_concurrent_node_pollers",
150156
kubernetesCmd.PersistentFlags().Lookup("number_of_concurrent_node_pollers"))
151157
_ = viper.BindPFlag("parse_metric_data", kubernetesCmd.PersistentFlags().Lookup("parse_metric_data"))
158+
_ = viper.BindPFlag("https_client_timeout", kubernetesCmd.PersistentFlags().Lookup("https_client_timeout"))
152159

153160
viper.SetEnvPrefix("cloudability")
154161
viper.AutomaticEnv()
@@ -172,6 +179,7 @@ func init() {
172179
ScratchDir: viper.GetString("scratch_dir"),
173180
InformerResyncInterval: viper.GetInt("informer_resync_interval"),
174181
ParseMetricData: viper.GetBool("parse_metric_data"),
182+
HTTPSTimeout: viper.GetInt("https_client_timeout"),
175183
}
176184

177185
}

kubernetes/kubernetes.go

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ type KubeAgentConfig struct {
8181
Informers map[string]*cache.SharedIndexInformer
8282
InformerResyncInterval int
8383
ParseMetricData bool
84+
HTTPSTimeout int
8485
}
8586

8687
const uploadInterval time.Duration = 10
@@ -217,6 +218,7 @@ func performConnectionChecks(ka *KubeAgentConfig) error {
217218
ProxyURL: ka.OutboundProxyURL,
218219
ProxyAuth: ka.OutboundProxyAuth,
219220
ProxyInsecure: ka.OutboundProxyInsecure,
221+
Timeout: time.Duration(ka.HTTPSTimeout) * time.Second,
220222
})
221223
if err != nil {
222224
return errors.New("error creating Cloudability Metric client in connectivity test")
@@ -394,6 +396,7 @@ func (ka KubeAgentConfig) sendMetrics(metricSample *os.File) {
394396
ProxyURL: ka.OutboundProxyURL,
395397
ProxyAuth: ka.OutboundProxyAuth,
396398
ProxyInsecure: ka.OutboundProxyInsecure,
399+
Timeout: time.Duration(ka.HTTPSTimeout) * time.Second,
397400
})
398401

399402
if err != nil {
@@ -735,6 +738,7 @@ func createAgentStatusMetric(workDir *os.File, config KubeAgentConfig, sampleSta
735738
m.Values["force_kube_proxy"] = strconv.FormatBool(config.ForceKubeProxy)
736739
m.Values["number_of_concurrent_node_pollers"] = strconv.Itoa(config.ConcurrentPollers)
737740
m.Values["parse_metric_data"] = strconv.FormatBool(config.ParseMetricData)
741+
m.Values["https_client_timeout"] = strconv.Itoa(config.HTTPSTimeout)
738742
if len(config.OutboundProxyAuth) > 0 {
739743
m.Values["outbound_proxy_auth"] = "true"
740744
} else {

version/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
package version
22

33
// VERSION is the current version of the agent
4-
var VERSION = "2.11.9"
4+
var VERSION = "2.11.10"

0 commit comments

Comments
 (0)