From b7103bd146d5c2b5ffb7e9e03c1c5b782b3226db Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Thu, 12 Dec 2019 10:58:18 -0500 Subject: [PATCH] Print out agent debugging links during CI (#52812) --- vars/agentInfo.groovy | 42 ++++++++++++++++++++++++++++++++++++++ vars/kibanaPipeline.groovy | 2 ++ 2 files changed, 44 insertions(+) create mode 100644 vars/agentInfo.groovy diff --git a/vars/agentInfo.groovy b/vars/agentInfo.groovy new file mode 100644 index 0000000000000..b53ed23f81ff0 --- /dev/null +++ b/vars/agentInfo.groovy @@ -0,0 +1,42 @@ +def print() { + try { + def startTime = sh(script: "date -d '-3 minutes' -Iseconds | sed s/+/%2B/", returnStdout: true).trim() + def endTime = sh(script: "date -d '+1 hour 30 minutes' -Iseconds | sed s/+/%2B/", returnStdout: true).trim() + + def resourcesUrl = + ( + "https://infra-stats.elastic.co/app/kibana#/visualize/edit/8bd92360-1b92-11ea-b719-aba04518cc34" + + "?_g=(time:(from:'${startTime}',to:'${endTime}'))" + + "&_a=(query:'host.name:${env.NODE_NAME}')" + ) + .replaceAll("'", '%27') // Need to escape ' because of the shell echo below, but can't really replace "'" with "\'" because of groovy sandbox + .replaceAll(/\)$/, '%29') // This is just here because the URL parsing in the Jenkins console doesn't work right + + def logsStartTime = sh(script: "date -d '-3 minutes' +%s", returnStdout: true).trim() + def logsUrl = + ( + "https://infra-stats.elastic.co/app/infra#/logs" + + "?_g=()&flyoutOptions=(flyoutId:!n,flyoutVisibility:hidden,surroundingLogsId:!n)" + + "&logFilter=(expression:'host.name:${env.NODE_NAME}',kind:kuery)" + + "&logPosition=(position:(time:${logsStartTime}000),streamLive:!f)" + ) + .replaceAll("'", '%27') + .replaceAll('\\)', '%29') + + sh script: """ + set +x + echo 'Resource Graph:' + echo '${resourcesUrl}' + echo '' + echo 'Agent Logs:' + echo '${logsUrl}' + echo '' + echo 'SSH Command:' + echo "ssh -F ssh_config \$(hostname --ip-address)" + """, label: "Worker/Agent/Node debug links" + } catch(ex) { + print ex.toString() + } +} + +return this diff --git a/vars/kibanaPipeline.groovy b/vars/kibanaPipeline.groovy index dbb33f2766dac..18f214554b444 100644 --- a/vars/kibanaPipeline.groovy +++ b/vars/kibanaPipeline.groovy @@ -116,6 +116,8 @@ def legacyJobRunner(name) { def jobRunner(label, useRamDisk, closure) { node(label) { + agentInfo.print() + if (useRamDisk) { // Move to a temporary workspace, so that we can symlink the real workspace into /dev/shm def originalWorkspace = env.WORKSPACE