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

[info] unknown ver if failed module load, custom if custom check. #3488

Merged
merged 2 commits into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions checks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,17 @@ def __init__(self, name, init_config, agentConfig, instances=None):
def set_manifest_path(self, manifest_path):
self.manifest_path = manifest_path

def set_check_version(self, manifest=None):
version = AGENT_VERSION
def set_check_version(self, version=None, manifest=None):
_version = AGENT_VERSION

if version:
Copy link
Contributor

Choose a reason for hiding this comment

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

this could be _version = version or AGENT_VERSION

_version = version

if manifest is not None:
version = "{core}:{sdk}".format(core=AGENT_VERSION,
_version = "{core}:{sdk}".format(core=AGENT_VERSION,
sdk=manifest.get('version', 'unknown'))

self.check_version = version
self.check_version = _version

def get_instance_proxy(self, instance, uri):
proxies = self.proxies.copy()
Expand Down
2 changes: 1 addition & 1 deletion checks/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def run(self, checksd=None, start_event=True, configs_reloaded=False):
if not self.continue_running:
return
check_status = CheckStatus(check_name, None, None, None, None,
check_version=info.get('version'),
check_version=info.get('version', 'unknown'),
init_failed_error=info['error'],
init_failed_traceback=info['traceback'])
check_statuses.append(check_status)
Expand Down
18 changes: 15 additions & 3 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,8 @@ def get_valid_check_class(check_name, check_path):
return True, check_class, {}


def _initialize_check(check_config, check_name, check_class, agentConfig, manifest_path):
def _initialize_check(check_config, check_name, check_class, agentConfig,
manifest_path, version_override=None):
init_config = check_config.get('init_config') or {}
instances = check_config['instances']
try:
Expand All @@ -989,14 +990,20 @@ def _initialize_check(check_config, check_name, check_class, agentConfig, manife

if manifest_path:
check.set_manifest_path(manifest_path)
check.set_check_version(load_manifest(manifest_path))

if not version_override:
check.set_check_version(manifest=load_manifest(manifest_path))
else:
check.set_check_version(version=version_override)
except Exception as e:
log.exception('Unable to initialize check %s' % check_name)
traceback_message = traceback.format_exc()
manifest = load_manifest(manifest_path)
if manifest is not None:
check_version = '{core}:{vers}'.format(core=AGENT_VERSION,
vers=manifest.get('version', 'unknown'))
elif version_override:
check_version = version_override
else:
check_version = AGENT_VERSION

Expand Down Expand Up @@ -1066,8 +1073,13 @@ def load_check_from_places(check_config, check_name, checks_places, agentConfig)
log.warn("The SDK check (%s) was designed for a different agent core "
"or couldnt be validated - behavior is undefined" % check_name)

version_override = None
if not manifest_path and agentConfig['additional_checksd'] in check_path:
version_override = 'custom' # custom check


load_success, load_failure = _initialize_check(
check_config, check_name, check_class, agentConfig, manifest_path
check_config, check_name, check_class, agentConfig, manifest_path, version_override
)

_update_python_path(check_config)
Expand Down