You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My org uses Keeper Secrets in python, configured to use the KSMCache for added resiliency. This works great when there's momentary connection issues, but more recently we've occasionally had chunks of time where a connection is established but we get errors back from the server:
HTTP500 An unexpected server error occurred (unable to validate app client: XXXXXXXXXXXXXXX). Please reboot your device and if the issue persists, contact your Keeper Support Team. HTTP503 Service Unavailable: Back-end server is at capacity
I'd expect for these to fall back to the checking the cache, but instead it was raising an error which was causing scheduled production scripts to fail. As a workaround, we made a new function to wrap KSMCache.caching_post_function, and we use that as the custom_post_function after setting up our cache instead. So far (about a month), it seems to be working with no production issues since.
defimproved_caching_post_function( # type: ignore url, transmission_key, encrypted_payload_and_signature, verify_ssl_certs=True
):
"""Wrapper for KSMCache's ``caching_post_function`` to handle HTTP errors while fetching secrets. KSMCache uses the cache if there's no connection at all, but raises for HTTP errors with isn't ideal. """ksm_rs=KSMCache.caching_post_function(
url, transmission_key, encrypted_payload_and_signature, verify_ssl_certs
)
ifksm_rs.status_code<400:
returnksm_rs# Try to log any error info we got back. # Very loosely based on KSM's SecretsManager.handler_http_error() info= {
"status_code": ksm_rs.status_code,
"reason": ksm_rs.http_response.reason,
}
try:
info["body"] =ksm_rs.http_response.json()
exceptJSONDecodeError:
info["body"] =ksm_rs.http_response.textinfo= {k: vfork, vininfo.items() ifvnotin (None, "")}
logger.warning("Handling KSM Error", **info)
# Cache access, code copied from KSMCache.caching_post_function() cached_data=KSMCache.get_cached_data()
cached_transmission_key=cached_data[:32]
transmission_key.key=cached_transmission_keydata=cached_data[32 : len(cached_data)]
new_rs=KSMHttpResponse(HTTPStatus.OK, data, None)
returnnew_rs
The text was updated successfully, but these errors were encountered:
Great information! The original cache function that we have developed was more like an example for the developers to use as a template to develop their own catching mechanism.
I'll also talk to the team to see if we should update our default caching function using your work around.
The original cache function that we have developed was more like an example for the developers to use as a template to develop their own catching mechanism.
The optional one mentioned in the link above? Where can i find information about that in product papers? What are the use cases of this default implementation? Is there a detailed explanation how to use it for mixed use cases ksm cli ( for ansible-vault key/password files ) and keeper_ansible ( for ansible playbooks) ?
My org uses Keeper Secrets in python, configured to use the
KSMCache
for added resiliency. This works great when there's momentary connection issues, but more recently we've occasionally had chunks of time where a connection is established but we get errors back from the server:I'd expect for these to fall back to the checking the cache, but instead it was raising an error which was causing scheduled production scripts to fail. As a workaround, we made a new function to wrap
KSMCache.caching_post_function
, and we use that as thecustom_post_function
after setting up our cache instead. So far (about a month), it seems to be working with no production issues since.The text was updated successfully, but these errors were encountered: