-
Notifications
You must be signed in to change notification settings - Fork 1.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
Add openstacksdk option to openstack_controller #3109
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3109 +/- ##
==========================================
- Coverage 84.51% 79.92% -4.59%
==========================================
Files 675 68 -607
Lines 36297 5894 -30403
Branches 4307 642 -3665
==========================================
- Hits 30675 4711 -25964
+ Misses 4362 1020 -3342
+ Partials 1260 163 -1097 |
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 great 💯 🥇 . Definitely on the right track 👏 . I made a few comments to push this the extra mile.
# - <KEY_2>:<VALUE_2> | ||
|
||
## @param openstack_sdk_config_file_path - optional - string |
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.
Let's move these up in the config next to user
. Also let's explain how user can authenticate using one or the other.
## Absolute path of the configuration file for the connection to openstack with openstacksdk. | ||
# | ||
# openstack_sdk_config_file_path: "/path/to/file.yaml" |
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.
let's remove sdk
## Name of the cloud configuration to use | ||
# | ||
# openstack_sdk_cloud_name: "simple-cloud" |
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.
Let's remove sdk
. In general, the config should not expose how thing are being done under the hood. This is not a strong rule 😄
@@ -1 +1,2 @@ | |||
datadog-checks-dev | |||
openstacksdk==0.24.0 |
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.
You can remove this since it's is not in addition to regular deps
@@ -700,7 +708,8 @@ def check(self, instance): | |||
self.collect_hypervisors_metrics(custom_tags=custom_tags, | |||
use_shortname=use_shortname, | |||
collect_hypervisor_metrics=collect_hypervisor_metrics, | |||
collect_hypervisor_load=collect_hypervisor_load) | |||
collect_hypervisor_load=collect_hypervisor_load, | |||
openstack_sdk_cloud_name=openstack_sdk_cloud_name) |
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.
Would it be possible to have this within the api implementation and have the api function that is not supported raise an exception that we would then catch in the check?
@@ -72,6 +83,158 @@ def get_networks(self): | |||
raise NotImplementedError() | |||
|
|||
|
|||
class OpenstackSdkApi(AbstractApi): |
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.
Could we rename this OpenstackSDKApi
. Not a big deal tho, completely opinionated and definitely coming from my OCD issues 😄
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.
Says the one who wrote Api
|
||
api = None | ||
|
||
if openstack_sdk_cloud_name is None: |
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.
Let's add comments here to explain what is going on for people you don't have the full context.
@@ -1,6 +1,8 @@ | |||
# (C) Datadog, Inc. 2018 | |||
# All rights reserved | |||
# Licensed under a 3-clause BSD style license (see LICENSE) | |||
from openstack import connection |
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.
Let's move from .... import ...
after import ...
api = OpenstackSdkApi(None) | ||
api.connection = MockOpenstackConnection() | ||
|
||
assert api.get_os_hypervisors_detail() == EXAMPLE_HYPERVISORS_VALUE |
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.
For all these methods, is the output the same as what the simpleApi
Would return.
It would be great to use the same assertion values in both cases just to make sure things match.
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.
Some of these methods return more information than SimpleApi
, and some less information (not used by the check). There are some commentary for the methods that have less information.
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 guess the tests then should only assert for values actually used by the check, then we can keep the same assertions for both APIs
MissingNovaEndpoint, MissingNeutronEndpoint) | ||
|
||
|
||
EXAMPLE_PROJECTS_VALUE = [ |
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.
For all these Api output, do you have a link to the doc that can help check out the 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.
The doc does not specify the output, I called each methods from the test env to have their explicit output.
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 👍, small nits aside :)
openstack_controller/datadog_checks/openstack_controller/api.py
Outdated
Show resolved
Hide resolved
openstack_controller/datadog_checks/openstack_controller/api.py
Outdated
Show resolved
Hide resolved
openstack_controller/datadog_checks/openstack_controller/api.py
Outdated
Show resolved
Hide resolved
7f19bff
to
1aba6f4
Compare
## @param openstack_config_file_path - optional - string | ||
## Absolute path of the configuration file for the connection to openstack with openstacksdk. | ||
# | ||
# openstack_config_file_path: "/path/to/file.yaml" |
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.
# openstack_config_file_path: "/path/to/file.yaml" | |
# openstack_config_file_path: <PATH_TO_YAML_FILE> |
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.
let's follow the configuration file norm https://github.com/DataDog/integrations-core/blob/master/docs/dev/new_check_howto.md#configuration-file
## openstack_config_file_path, or at the default location: | ||
## ~/.config/openstack or /etc/openstack | ||
# | ||
# openstack_cloud_name: "simple-cloud" |
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.
# openstack_cloud_name: "simple-cloud" | |
# openstack_cloud_name: <CLOUD_NAME> |
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.
Looks good to me. Great Job!
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.
🐍
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.
Fixed some issue in the configuration file, otherwise LGTM 👌
What does this PR do?
Add the
OpenstackSdkApi
option to the api factory ofopenstack_controller
. It uses openstacksdk (v 0.24.0)Motivation
Review checklist
no-changelog
label attachedAdditional Notes
Openstacksdk is in version 0.24.0 and is not complete yet.
hypervisor_uptime
is not available with openstacksdk yet, so the metricshypervisor_load.1
,hypervisor_load.5
andhypervisor_load.15
can't be created (this is like settingcollect_hypervisor_load
toFalse
in the configuration file).server_diagnostics
is not available with openstacksdk yet, but it should be available in the next release (commit), so a few metrics are not created (this is like settingcollect_server_diagnostic_metrics
toFalse
).