-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Support for maximum size for Output of checks #5233
Changes from 5 commits
6c21464
b5717aa
b5f00ff
79a02fa
8dcf910
bc0ace6
a684019
89b5a23
0a95339
2b3df47
a68ecd0
acce4eb
13710da
8478180
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -915,6 +915,7 @@ func (a *Agent) consulConfig() (*consul.Config, error) { | |
base.CoordinateUpdateBatchSize = a.config.ConsulCoordinateUpdateBatchSize | ||
base.CoordinateUpdateMaxBatches = a.config.ConsulCoordinateUpdateMaxBatches | ||
base.CoordinateUpdatePeriod = a.config.ConsulCoordinateUpdatePeriod | ||
base.CheckOutputMaxSize = a.config.CheckOutputMaxSize | ||
|
||
base.RaftConfig.HeartbeatTimeout = a.config.ConsulRaftHeartbeatTimeout | ||
base.RaftConfig.LeaderLeaseTimeout = a.config.ConsulRaftLeaderLeaseTimeout | ||
|
@@ -971,6 +972,9 @@ func (a *Agent) consulConfig() (*consul.Config, error) { | |
if a.config.Bootstrap { | ||
base.Bootstrap = true | ||
} | ||
if a.config.CheckOutputMaxSize > 0 { | ||
base.CheckOutputMaxSize = a.config.CheckOutputMaxSize | ||
} | ||
if a.config.RejoinAfterLeave { | ||
base.RejoinAfterLeave = true | ||
} | ||
|
@@ -2239,6 +2243,13 @@ func (a *Agent) addCheck(check *structs.HealthCheck, chkType *structs.CheckType, | |
|
||
// Check if already registered | ||
if chkType != nil { | ||
maxOutputSize := a.config.CheckOutputMaxSize | ||
if maxOutputSize == 0 { | ||
maxOutputSize = checks.DefaultBufSize | ||
} | ||
if chkType.OutputMaxSize > 0 && maxOutputSize > chkType.OutputMaxSize { | ||
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. As you mention in your description, this will only override the agent check if the check's Could you expand more on why we shouldn't allow the check's max to override the agent's max? 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. @freddygv I wanted to be as conservative as possible (meaning, that for instance, if someone is storing those results in a DB and assumed size will never be more than 4k, we won't break this assumption), but allowing large infrastructure to reduce the size of their checks since it might be hugely impacting when checks are varying a lot (for instance, the normal result if checks if 'OK', while the broken checks returns large stack traces), ask @orarnon for instance who had this issue (we did had it as well on very large clusters in the past) Increasing this value is trivial and could be done in another patch if someone is resquesting it, but if you really want, we can remove this limit in this PR as well. 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. @pierresouchay Thanks. Can you please expand on the need for the check-specific max output size? Would adding a max for the agent alone be sufficient? The implementation would be simpler if we only set this max once. Additionally, there is a UX mismatch where someone can discard output at the agent level, but at the check level the max size can only be brought down to 1. 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. yes, the reason for that is serialization of payload: if the user specify 0, it means no value has been specified in payload (for instance for a user not setting |
||
maxOutputSize = chkType.OutputMaxSize | ||
} | ||
switch { | ||
|
||
case chkType.IsTTL(): | ||
|
@@ -2285,6 +2296,7 @@ func (a *Agent) addCheck(check *structs.HealthCheck, chkType *structs.CheckType, | |
Interval: chkType.Interval, | ||
Timeout: chkType.Timeout, | ||
Logger: a.logger, | ||
OutputMaxSize: maxOutputSize, | ||
TLSClientConfig: tlsClientConfig, | ||
} | ||
http.Start() | ||
|
@@ -2352,7 +2364,7 @@ func (a *Agent) addCheck(check *structs.HealthCheck, chkType *structs.CheckType, | |
} | ||
|
||
if a.dockerClient == nil { | ||
dc, err := checks.NewDockerClient(os.Getenv("DOCKER_HOST"), checks.BufSize) | ||
dc, err := checks.NewDockerClient(os.Getenv("DOCKER_HOST"), int64(maxOutputSize)) | ||
if err != nil { | ||
a.logger.Printf("[ERR] agent: error creating docker client: %s", err) | ||
return err | ||
|
@@ -2387,14 +2399,14 @@ func (a *Agent) addCheck(check *structs.HealthCheck, chkType *structs.CheckType, | |
check.CheckID, checks.MinInterval) | ||
chkType.Interval = checks.MinInterval | ||
} | ||
|
||
monitor := &checks.CheckMonitor{ | ||
Notify: a.State, | ||
CheckID: check.CheckID, | ||
ScriptArgs: chkType.ScriptArgs, | ||
Interval: chkType.Interval, | ||
Timeout: chkType.Timeout, | ||
Logger: a.logger, | ||
Notify: a.State, | ||
CheckID: check.CheckID, | ||
ScriptArgs: chkType.ScriptArgs, | ||
Interval: chkType.Interval, | ||
Timeout: chkType.Timeout, | ||
Logger: a.logger, | ||
OutputMaxSize: maxOutputSize, | ||
} | ||
monitor.Start() | ||
a.checkMonitors[check.CheckID] = monitor | ||
|
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.
This may be unnecessary. How could
a.config.CheckOutputMaxSize
end up as 0? The config builder has a default value of 4096 and returns an error if the input is < 1.