-
Notifications
You must be signed in to change notification settings - Fork 814
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
[Service Discovery] create a template cache to reduce calls to the KV store #3060
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ def get_check_class(agentConfig, check_name): | |
return None | ||
|
||
|
||
def get_auto_conf(agentConfig, check_name): | ||
def get_auto_conf(check_name): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like |
||
"""Return the yaml auto_config dict for a check name (None if it doesn't exist).""" | ||
from config import PathNotFound, get_auto_confd_path | ||
|
||
|
@@ -75,11 +75,11 @@ def get_auto_conf(agentConfig, check_name): | |
return auto_conf | ||
|
||
|
||
def get_auto_conf_images(agentConfig): | ||
def get_auto_conf_images(full_tpl=False): | ||
"""Walk through the auto_config folder and build a dict of auto-configurable images.""" | ||
from config import PathNotFound, get_auto_confd_path | ||
auto_conf_images = { | ||
# image_name: check_name | ||
# image_name: [check_names] or [[check_names], [init_tpls], [instance_tpls]] | ||
} | ||
|
||
try: | ||
|
@@ -100,5 +100,18 @@ def get_auto_conf_images(agentConfig): | |
# extract the supported image list | ||
images = auto_conf.get('docker_images', []) | ||
for image in images: | ||
auto_conf_images[image] = check_name | ||
if full_tpl: | ||
init_tpl = auto_conf.get('init_config') or {} | ||
instance_tpl = auto_conf.get('instances', []) | ||
if image not in auto_conf_images: | ||
auto_conf_images[image] = [[check_name], [init_tpl], [instance_tpl]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it end up being less error-prone to have the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you mean like Problem with that is if users have several instances of the same check for the same image (and a customer actually asked how to do that yesterday so it happens). In this case we still need to wrap init_tpl and instance_tpl in lists and end up with the same logic as we have now. But maybe I didn't understand correctly your suggestion There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I originally meant But then I read on, and I saw it wasn't necessarily a good idea given the current structure/logic. I felt it would make the code a little more maintainable (perhaps). We can maybe just keep in mind for the future (it'd be a pretty big refactor), there's nothing wrong with the current logic. |
||
else: | ||
for idx, item in enumerate([check_name, init_tpl, instance_tpl]): | ||
auto_conf_images[image][idx].append(item) | ||
else: | ||
if image in auto_conf_images: | ||
auto_conf_images[image].append(check_name) | ||
else: | ||
auto_conf_images[image] = [check_name] | ||
|
||
return auto_conf_images |
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.
Big 🙇 for all these awesome tests!