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 docker & swarm container metadata #1685

Merged
merged 3 commits into from
May 11, 2018
Merged

Conversation

mfpierre
Copy link
Contributor

@mfpierre mfpierre commented May 9, 2018

What does this PR do?

Add a new container-meta field in metadata payload

Add docker_version and docker_swarm to it as it was reported by agent 5

Motivation

screen shot 2018-05-09 at 18 31 43

Additional Notes

Other container metadata provider should follow

@mfpierre mfpierre added this to the 6.3.0 milestone May 9, 2018
@mfpierre mfpierre requested review from devonboyer and a team May 9, 2018 16:38
@mfpierre mfpierre requested review from a team as code owners May 9, 2018 16:38
@@ -18,6 +20,8 @@ import (

func TestGetPayload(t *testing.T) {
p := GetPayload("myhostname")
pj, _ := json.Marshal(p)
fmt.Println(string(pj))
Copy link
Contributor

@devonboyer devonboyer May 9, 2018

Choose a reason for hiding this comment

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

Is this just testing that the payload is marshalled correctly? Capturing the error and using assert.NoError() instead of letting it panic would give better output I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oups good catch, this was for debugging purposes I'll remove it 🙈

@devonboyer
Copy link
Contributor

@CharlyF mentioned that adding the swarm node role (manager/worker) may make more sense as container meta instead of a host tag (DataDog/dd-agent#3735). Is container meta something that already exists in the agent5?

@mfpierre
Copy link
Contributor Author

@devonboyer yes it already exists, check this DataDog/dd-agent#3557 for more details

@mfpierre mfpierre force-pushed the mfpierre/container-meta branch 2 times, most recently from 2d3151b to f3bf572 Compare May 11, 2018 09:17
Copy link
Contributor

@xvello xvello left a comment

Choose a reason for hiding this comment

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

👍 on the pluggable architecture, one concern about the collection time, that might delay the initial payload (total max time is now 10seconds)

log.Debugf("Unable to collect Docker host metadata: %s", err)
return metadata
}
ctx, cancel := context.WithTimeout(context.Background(), du.queryTimeout)
Copy link
Contributor

Choose a reason for hiding this comment

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

To avoid delaying the metadata generation too much, could we use a 1 second timeout for all requests in this method?

As for GetSwarmState, if we think it will be reused, we could change it to a method accepting a types.Info object, like we do for parseStorageStatsFromInfo. That way:

  • we can unit-test the parsing
  • we can retrieve the info with a one-second timeout for this specific use
  • later we could extract other tags from it without multiplying requests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

both swarm and server version are in types.Info simplifying the code 👍

metadata["docker_version"] = v.Version
i, err := du.cli.Info(ctx)
if err != nil {
return metadata
Copy link
Contributor

Choose a reason for hiding this comment

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

We might want to either log or return the error, if we need to debug it one day

Copy link
Contributor

@xvello xvello left a comment

Choose a reason for hiding this comment

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

return 👍, nil

@mfpierre mfpierre merged commit 45c13c4 into master May 11, 2018
@mfpierre mfpierre deleted the mfpierre/container-meta branch May 11, 2018 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants