-
Notifications
You must be signed in to change notification settings - Fork 5k
[Ingest Manager] Make agent retry values for bootstraping configurable #25163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
michalpristas
merged 6 commits into
elastic:master
from
michalpristas:bug/increase-limit
Apr 20, 2021
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1b53309
wip
michalpristas d071428
Merge branch 'master' of github.com:elastic/beats into bug/increase-l…
michalpristas ba412f5
env format
michalpristas 562073b
changelog
michalpristas da1942c
accept duration
michalpristas f580370
support config file
michalpristas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,7 @@ import ( | |||||
| "os/exec" | ||||||
| "path/filepath" | ||||||
| "regexp" | ||||||
| "strconv" | ||||||
| "strings" | ||||||
| "sync" | ||||||
| "syscall" | ||||||
|
|
@@ -40,15 +41,19 @@ import ( | |||||
| ) | ||||||
|
|
||||||
| const ( | ||||||
| requestRetrySleep = 1 * time.Second // sleep 1 sec between retries for HTTP requests | ||||||
| maxRequestRetries = 30 // maximum number of retries for HTTP requests | ||||||
| defaultStateDirectory = "/usr/share/elastic-agent/state" // directory that will hold the state data | ||||||
| requestRetrySleepEnv = "KIBANA_REQUEST_RETRY_SLEEP" | ||||||
| maxRequestRetriesEnv = "KIBANA_REQUEST_RETRY_COUNT" | ||||||
| defaultRequestRetrySleep = "1" // sleep 1 sec between retries for HTTP requests | ||||||
| defaultMaxRequestRetries = "30" // maximum number of retries for HTTP requests | ||||||
| defaultStateDirectory = "/usr/share/elastic-agent/state" // directory that will hold the state data | ||||||
| ) | ||||||
|
|
||||||
| var ( | ||||||
| // Used to strip the appended ({uuid}) from the name of an enrollment token. This makes much easier for | ||||||
| // a container to reference a token by name, without having to know what the generated UUID is for that name. | ||||||
| tokenNameStrip = regexp.MustCompile(`\s\([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\)$`) | ||||||
| tokenNameStrip = regexp.MustCompile(`\s\([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\)$`) | ||||||
| requestRetrySleep time.Duration | ||||||
| maxRequestRetries int | ||||||
| ) | ||||||
|
|
||||||
| func newContainerCommand(_ []string, streams *cli.IOStreams) *cobra.Command { | ||||||
|
|
@@ -70,6 +75,8 @@ The following actions are possible and grouped based on the actions. | |||||
| KIBANA_FLEET_USERNAME - kibana username to enable Fleet [$KIBANA_USERNAME] | ||||||
| KIBANA_FLEET_PASSWORD - kibana password to enable Fleet [$KIBANA_PASSWORD] | ||||||
| KIBANA_FLEET_CA - path to certificate authority to use with communicate with Kibana [$KIBANA_CA] | ||||||
| KIBANA_REQUEST_RETRY_SLEEP - specifies number of seconds of sleep taken when agent performs a request to kibana [default 1] | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above
Suggested change
|
||||||
| KIBANA_REQUEST_RETRY_COUNT - specifies number of retries agent performs when executing a request to kibana [default 30] | ||||||
|
simitt marked this conversation as resolved.
|
||||||
|
|
||||||
| * Bootstrapping Fleet Server | ||||||
| This bootstraps the Fleet Server to be run by this Elastic Agent. At least one Fleet Server is required in a Fleet | ||||||
|
|
@@ -163,6 +170,10 @@ func containerCmd(streams *cli.IOStreams, cmd *cobra.Command) error { | |||||
| return err | ||||||
| } | ||||||
|
|
||||||
| if err := setRetry(); err != nil { | ||||||
| return err | ||||||
| } | ||||||
|
|
||||||
| elasticCloud := envBool("ELASTIC_AGENT_CLOUD") | ||||||
| // if not in cloud mode, always run the agent | ||||||
| runAgent := !elasticCloud | ||||||
|
|
@@ -669,6 +680,24 @@ func setPaths() error { | |||||
| return nil | ||||||
| } | ||||||
|
|
||||||
| func setRetry() error { | ||||||
| retrySleepStr := envWithDefault(defaultRequestRetrySleep, requestRetrySleepEnv) | ||||||
| retrySleep, err := strconv.Atoi(retrySleepStr) | ||||||
| if err != nil { | ||||||
| return errors.New(err, fmt.Sprintf("failed to parse '%s'", requestRetrySleepEnv)) | ||||||
| } | ||||||
| requestRetrySleep = time.Duration(retrySleep) * time.Second | ||||||
|
|
||||||
| retryMaxCountStr := envWithDefault(defaultMaxRequestRetries, maxRequestRetriesEnv) | ||||||
| retryRetries, err := strconv.Atoi(retryMaxCountStr) | ||||||
| if err != nil { | ||||||
| return errors.New(err, fmt.Sprintf("failed to parse '%s'", maxRequestRetriesEnv)) | ||||||
| } | ||||||
| maxRequestRetries = retryRetries | ||||||
|
|
||||||
| return nil | ||||||
| } | ||||||
|
|
||||||
| func syncDir(src string, dest string) error { | ||||||
| return filepath.Walk(src, func(path string, info os.FileInfo, err error) error { | ||||||
| if err != nil { | ||||||
|
|
||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this
1sinstead and have time parsing? This makes it possible to pass in any time values if needed and makes it more explicity.