Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Use config-based Docker endpoint instead of hardcoded #62

Merged
merged 5 commits into from
Dec 22, 2016

Conversation

denismakogon
Copy link
Contributor

Use config-based Docker endpoint instead of hardcoded one

@denismakogon denismakogon changed the title Use config-based Docker endpoint instead of hardcoded [WIP] Use config-based Docker endpoint instead of hardcoded Dec 22, 2016
@denismakogon
Copy link
Contributor Author

@kindermoumoute what would be the best way to stub init_client method during metrics collecting?

@denismakogon denismakogon changed the title [WIP] Use config-based Docker endpoint instead of hardcoded Use config-based Docker endpoint instead of hardcoded Dec 22, 2016
return nil, err
}

err = d.init_client(conf["endpoint"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

This way you are going to initialize new client for each call to CollectMetrics. I would suggest to do it only once. (check for nil?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marcin-krolik take a look at new commit, in initClient method, we check if client was initialized, if yes (checking if .client is not nil, but i think it would be more useful to do some sort of ping check if Docker daemon is alive and its API is responsive).

@denismakogon
Copy link
Contributor Author

@marcin-krolik your comment was addressed with 8358759.

@marcin-krolik
Copy link
Collaborator

@denismakogon Thanks, I think it's better now.

... but i think it would be more useful to do some sort of ping check if Docker daemon is alive and its API is responsive).

I also think this way. I don't know if you read my comment to your previous PR, just to make sure it was not missed - In current sprint I'm working on heavy refactor of docker collector. There will be a lot of changes, like getting rid of expensive collects (only collecting requested metrics), proper discovery of cgroupfs driver, pinging docker deamon as well :)

@denismakogon
Copy link
Contributor Author

@marcin-krolik yes, i've seen that. Probably i can help with that.

@denismakogon
Copy link
Contributor Author

So, @kindermoumoute @marcin-krolik i just tried to build and run this plugin using this PR, it seems like it works fine. At least i'm able to create task and see metrics and some data published into a file (using file publisher). Would this mean that plugin works?

Can someone confirm that it worked for you too?

return err
}
d.client = dc
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

this line seems unnecessary as there seems nothing else besides if statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, removing.

return &docker{
containers: map[string]containerData{},
client: dc,
client: nil,
Copy link
Contributor

Choose a reason for hiding this comment

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

if the client is nil at New(), do you still want to keep it in the type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, removing.

@@ -66,48 +66,56 @@ var mockMts = []plugin.Metric{
Namespace: plugin.NewNamespace(NS_VENDOR, NS_PLUGIN).
AddDynamicElement("docker_id", "an id of docker container").
AddStaticElements("spec", "creation_time"),
Config: plugin.Config{"endpoint": "unix:///var/run/docker.sock"},
Copy link
Contributor

Choose a reason for hiding this comment

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

probably a visible scope variable instead of the same definition everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, refactoring.

@candysmurf
Copy link
Contributor

@denismakogon, thanks for your contribution.

@candysmurf candysmurf merged commit 4e01f75 into intelsdi-x:master Dec 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants