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

AMBARI-25483 Web alert triggers a wrong critical alert in kerberized cluster #3181

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

xihuanbanku
Copy link

Python use function time.time() get current time the unit is second, but we need a millisecond here.

What changes were proposed in this pull request?

When a kerberized "WEB" type alert checks its status with kinit for the very first time. It will create a cache file with command "kinit -c /path/to/tmp/cache -kt /path/to/keytab/file some-principal", next time the alert executes, it will check the cache file status first, which checks the difference between current timestamp and last kinit timestamp. But when compare these two timestamps, we should use "millisecond" unit, not "second". From the variable name of kinit_timer_ms we also could firgure is out. Otherwise, the "if" statement at line 128 will never return True after 14400000 seconds(166.66 days) later.

How was this patch tested?

manual tests

Python use function time.time() get current time the unit is second, but we need millisecond here.
@g-boros
Copy link
Contributor

g-boros commented Feb 24, 2020

@xihuanbanku please file an Apache jira ticket and use it in the commit msg

@xihuanbanku
Copy link
Author

xihuanbanku commented Feb 25, 2020

@hapylestat hapylestat changed the title BUG - need a millisecond here AMBARI-25483 Web alert triggers a wrong critical alert in kerberized cluster Jul 24, 2020
@@ -124,7 +124,7 @@ def curl_krb_request(tmp_dir, keytab, principal, url, cache_file_prefix,
# kinit if it's time; this helps to avoid problems approaching ticket boundary when
# executing a klist and then a curl
last_kinit_time = _KINIT_CACHE_TIMES.get(ccache_file_name, 0)
current_time = long(time.time())
current_time = long(time.time() * 1000)
Copy link
Contributor

Choose a reason for hiding this comment

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

lets define a function in the code like:

def get _current_time_ms():
  return round(time.time() * 1000)

and then use it instead any occurrence of time.time() in the module ?

@hapylestat
Copy link
Contributor

The change suggestion is ok, it seems that comments assume that time.time() return milis and .. it is but in form of float number, where on some systems resolution would be higher or not.

Any usage of the mentioned function should be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants