-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add cloudfoundry common client into x-pack/common #16527
Conversation
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.
I did a quick pass and left some comments, nothing major
…didn't expose overriding the TLSConfig. Add comment for location of documentation for event types.
@exekias Ready for another look. |
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 is looking good, I left some minor comments. Also CI found some issues, this is ready to go once CI is happy.
} | ||
|
||
// InitDefaults initialize the defaults for the configuration. | ||
func (c *Config) InitDefaults() { |
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.
Not a strong opinion, but we normally use this pattern:
beats/metricbeat/helper/config.go
Line 35 in 837279a
func defaultConfig() Config { |
so you can get defaults on a single call, this way you don't risk forgetting to call InitDefaults
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.
I think this is a new way of initializing defaults 🙂 elastic/go-ucfg#141
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.
Awesome, I missed this change 👍
// EventType defines the different event types that can be raised from RPLClient. | ||
type EventType uint | ||
|
||
// EventTypes from loggregator documented here: https://github.com/cloudfoundry/loggregator-api |
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.
thanks for adding this, really helpful! It would look like we are using V1 types?
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.
Yes the code always converts from V2 types to V1. V2 doesn't have any more events then V1 just a different structure.
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.
Good job here. I have added some comments, nothing serious, the only thing I am a bit worried is about having a leak in the cache. Let me know what you think.
} | ||
|
||
// InitDefaults initialize the defaults for the configuration. | ||
func (c *Config) InitDefaults() { |
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.
I think this is a new way of initializing defaults 🙂 elastic/go-ucfg#141
THE SOFTWARE. | ||
|
||
-------------------------------------------------------------------- | ||
Dependency: github.com/cloudfoundry/sonde-go |
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.
Looking at this dependecy, we might need to copy a few files manually to make it work. But that's not a problem.
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.
Deps look right.
I am sorry, I just wanted to comment. But I accidentally clicked on approve. |
…ead of the kubernetes ttl cache. Fix other suggestions.
LGTM once @jsoriano is 👍 |
@@ -107,9 +102,8 @@ func (c *RlpListener) Start() { | |||
|
|||
// Stop receiving events | |||
func (c *RlpListener) Stop() { | |||
c.log.Debugw("Stopping RLP listener.", "rlpAddress", c.rlpAddress) | |||
c.log.Debugw("stopping RLP listener.", "rlpAddress", c.rlpAddress) |
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.
Logged messages can start with uppercase 🙂
c.log.Debugw("stopping RLP listener.", "rlpAddress", c.rlpAddress) | |
c.log.Debugw("Stopping RLP listener.", "rlpAddress", c.rlpAddress) |
|
||
jsonData := make(map[string]interface{}) | ||
decoder := json.NewDecoder(resp.Body) | ||
err = decoder.Decode(&jsonData) |
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.
Handle this error here?
* Add cloudfoundry common client into x-pack/common. * Run mage fmt. * Add support for tlscommon.Config, removing the uaago depedency as it didn't expose overriding the TLSConfig. Add comment for location of documentation for event types. * Use common.Cache with addition of not updated expiration on get, instead of the kubernetes ttl cache. Fix other suggestions. * Fix cache_test and new test for not updated access time. * Handle error sooner in getAuthTokenWithExpiresIn. (cherry picked from commit f4c71b4)
* Add cloudfoundry common client into x-pack/common. * Run mage fmt. * Add support for tlscommon.Config, removing the uaago depedency as it didn't expose overriding the TLSConfig. Add comment for location of documentation for event types. * Use common.Cache with addition of not updated expiration on get, instead of the kubernetes ttl cache. Fix other suggestions. * Fix cache_test and new test for not updated access time. * Handle error sooner in getAuthTokenWithExpiresIn. (cherry picked from commit f4c71b4)
What does this PR do?
Prerequisite to adding an input for filebeat and a module for metricbeat. Contains the required clients and code to use Cloud Foundry loggregator API to collect logs and metrics.
Worry is in the size increase of the binary for the included Cloud Foundry dependencies. Once the filebeat input is enabled in a later PR the size increase is only 3M. Increases from 119M to 122M.
Why is it important?
To support Cloud Foundry.
Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesAuthor's Checklist
How to test this PR locally
Related issues
Use cases
Screenshots
Logs