in src/com/epam/digital/data/platform/pipelines/registrycomponents/regular/Redash.groovy [60:93]
private void initApiKeys(String redashElement, String keyJsonPath, String redashElementUrl, String apiKey) {
boolean isKeysRegenerated = false
def response = context.script.httpRequest url: "${redashElementUrl}/api/users",
httpMode: "GET",
customHeaders: [[name: "authorization", value: apiKey, maskValue: true]],
consoleLogResponseBody: context.logLevel == "DEBUG",
quiet: context.logLevel != "DEBUG",
validResponseCodes: "200,403,404"
context.logger.debug("Redash ${redashElement} response: ${response.content}")
if (response.getStatus() == 404) {
context.logger.info("Redash ${redashElement} api key is no more valid or not yet initialised")
if ("${redashElement}" == "viewer") {
viewerApiKey = DecodeHelper.decodeBase64(patchRedashSecret(redashElementUrl, REDASH_SETUP_SECRET, keyJsonPath))
}
if ("${redashElement}" == "admin") {
adminApiKey = DecodeHelper.decodeBase64(patchRedashSecret(redashElementUrl, REDASH_SETUP_SECRET, keyJsonPath))
}
isKeysRegenerated = true
} else {
context.logger.info("Redash api key secret is up to date for ${redashElement}")
}
if (isKeysRegenerated)
restartRedashExporterPod()
if (response.getStatus() == 403) {
String systemAdminEmail = context.platform.getSecretValue(REDASH_SETUP_SECRET, "email")
context.script.error("Please ensure that redash system admin is added to admin group in redash.\n" +
"Possible solution:\n" +
"1. Check if there is no user with email $systemAdminEmail in Keycloak;\n" +
"2. Run the following commands in redash deployment pod(s):\n" +
"export DATABASE_URL=postgresql://\$REDASH_DATABASE_USER:\$REDASH_DATABASE_PASSWORD@\$REDASH_DATABASE_HOSTNAME/\$REDASH_DATABASE_DB;\n" +
"python ./manage.py users grant_admin $systemAdminEmail")
}
}