Skip to content
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

Merged
merged 6 commits into from
Feb 25, 2020

Conversation

blakerouse
Copy link
Contributor

@blakerouse blakerouse commented Feb 24, 2020

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

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

@blakerouse blakerouse added enhancement libbeat x-pack Issues and pull requests for X-Pack features. Team:Platforms Label for the Integrations - Platforms team labels Feb 24, 2020
@exekias exekias requested a review from a team February 24, 2020 21:02
Copy link
Contributor

@exekias exekias left a 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.
@blakerouse
Copy link
Contributor Author

@exekias Ready for another look.

Copy link
Contributor

@exekias exekias left a 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() {
Copy link
Contributor

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:

func defaultConfig() Config {

so you can get defaults on a single call, this way you don't risk forgetting to call InitDefaults

Copy link
Member

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

Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Member

@jsoriano jsoriano left a 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() {
Copy link
Member

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
Copy link
Contributor

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.

Copy link
Contributor

@kvch kvch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deps look right.

@kvch
Copy link
Contributor

kvch commented Feb 25, 2020

I am sorry, I just wanted to comment. But I accidentally clicked on approve.

@blakerouse
Copy link
Contributor Author

@exekias @jsoriano Ready for another look.

@exekias
Copy link
Contributor

exekias commented Feb 25, 2020

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)
Copy link
Member

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 🙂

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle this error here?

@blakerouse blakerouse merged commit f4c71b4 into elastic:master Feb 25, 2020
@blakerouse blakerouse deleted the common-cloudfoundry branch February 25, 2020 18:14
blakerouse added a commit to blakerouse/beats that referenced this pull request Feb 25, 2020
* 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)
blakerouse added a commit that referenced this pull request Feb 26, 2020
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement libbeat Team:Platforms Label for the Integrations - Platforms team v7.7.0 x-pack Issues and pull requests for X-Pack features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants