Skip to content

streamline dynamic machine label creation and cleanup process #6372

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
74 changes: 32 additions & 42 deletions buildenv/jenkins/openjdk_tests
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ def PLATFORMS = params.PLATFORM.trim().split("\\s*,\\s*");
def JDK_VERSIONS = params.JDK_VERSION.trim().split("\\s*,\\s*");
def JDK_IMPLS = params.JDK_IMPL.trim().split("\\s*,\\s*");

@Field String ebcDemandId = ""
// if multiple JDK_VERSION / JDK_IMPL / PLATFORM are provided, run test jobs in parallel
timestamps{
if (JDK_VERSIONS.size() > 1 || JDK_IMPLS.size() > 1 || PLATFORMS.size() >1 || PLATFORMS.any { it.contains("all") }) {
Expand Down Expand Up @@ -386,28 +385,23 @@ timestamps{
// DynamicAgents and DockerAgents shouldn't contain the same label
if (params.CLOUD_PROVIDER != null && params.CLOUD_PROVIDER in dynamicAgents) {
if (params.CLOUD_PROVIDER == "EBC") {
boolean ebcNode = false
ebcDemandId = UUID.randomUUID().toString()
def dynamicMachineLabel = 'ci.agent.dynamic.' + ebcDemandId
try {
timeout(time: 120, unit: 'MINUTES') {
// ToDo: pass in platform once we support more platforms. For now, we only support xlinux.
getEBCNode(ebcDemandId, dynamicMachineLabel)
def dynamicMachineLabel = 'ci.agent.dynamic.' + UUID.randomUUID().toString()
getEBCnode(dynamicMachineLabel)
node(dynamicMachineLabel) {
echo "EBC node ${dynamicMachineLabel} is ready"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to check for the node to be ready here? It appears that is what param WAIT is doing on the Create job.

Copy link
Author

Choose a reason for hiding this comment

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

I would say it doesn't hurt if we keep it for when we decide to set wait:false.

}
ebcNode = true
LABEL = dynamicMachineLabel
echo "Using EBC node ${LABEL}..."
}
} catch (Exception e) {
echo 'Exception: ' + e.toString()
echo "Cannot launch EBC node ${dynamicMachineLabel}..."
}
if (ebcNode) {
LABEL = dynamicMachineLabel
echo "Use EBC node ${LABEL}..."
} else {
echo "Use static node ${LABEL}..."
}

} else {
LABEL = LABEL.minus("ci.role.test&&")
LABEL += '&&ci.agent.dynamic'
Expand Down Expand Up @@ -588,13 +582,10 @@ def runTest() {
}
}
}
if (params.CLOUD_PROVIDER == "EBC" && ebcDemandId) {
if (params.CLOUD_PROVIDER == "EBC" && LABEL.startsWith("ci.agent.dynamic.")) {
try {
println("Triggering EBC_Delete_Node job with demandId: ${ebcDemandId}")
def parameters = [
string(name: 'demandId', value: ebcDemandId)
]
build job: 'EBC_Delete_Node', parameters: parameters, propagate: false
println("Triggering EBC_Delete_Node for label: ${LABEL}")
freeEBCnode(LABEL)
} catch (Exception e) {
println("Warning: Exception when triggering EBC_Delete_Node. This does not affect test build result.")
println(e.toString())
Expand Down Expand Up @@ -732,29 +723,28 @@ def generateJobViaAutoGen(testJobName) {
}
}

def getEBCNode(demandId, dynamicMachineLabel) {
library 'jenkins-ci-websphere'
def ebcPlan = 'hur-runtimesJenkins-aqa-ubuntu22_x86.yml'
def ebcShortlist = ''
int expectedNodeLifespan = params.TIME_LIMIT ? Integer.parseInt(params.TIME_LIMIT) : 1
echo "Calling ebcJenkinsNodeDemand() with demandId: ${demandId} and label: ${dynamicMachineLabel}"
def ebcArgs = [
demandId: demandId,
ebcPlan: ebcPlan,
ebcShortlist: ebcShortlist,
autoCompleteAfterXHours: expectedNodeLifespan + 1,
ebcBranch: 'prod',
credentialsId: "${params.EBC_CREDENTIALS_ID}",
extraProps: ['[email protected]:runtimes/infra-can.git',
'ebc_jenkins_server_instance_name=hyc-runtimes-jenkins.swg-devops.com',
'ebc_jenkins_service_name=runtimes-jenkins',
"ebc_jenkins_agent_label=${dynamicMachineLabel}",
'ebc_remotePlaybook_gitBranch=openj9',
'ebc_remotePlaybook_file=ansible/playbooks/ibm_unix_playbook/ibm_jenkins_unix_test.yml',
"ebc_ansible_extra_vars='is_ebc=true'",
'ebc_remotePlaybook_jenkinsUserSshPubKey=unused']
]
echo "EBC Args: ${ebcArgs}"
def ebcResult = ebcJenkinsNodeDemand(ebcArgs);
echo "EBC Result: ${ebcResult}"
def getEBCnode(dynamicMachineLabel) {
def expectedNodeLifespan = params.TIME_LIMIT ?: 1
def wait = true
build job: 'EBC/EBC_Create_Node',
propagate: false,
wait: wait,
parameters: [
string(name: 'group_label', value: dynamicMachineLabel),
string(name: 'platform', value: params.PLATFORM),
string(name: 'nodeType', value: 'testmachine'),
string(name: 'NUM_MACHINES', value: "1"),
string(name: 'TIME_LIMIT', value: expectedNodeLifespan.toString()),
string(name: 'EBC_ENV', value: 'prod'),
booleanParam(name: 'WAIT', value: wait),
]
}

def freeEBCnode(dynamicMachineLabel) {
build job: 'EBC/EBC_Complete',
propagate: false,
wait: false,
parameters: [
string(name: 'LABEL', value: dynamicMachineLabel),
]
}