-
-
Notifications
You must be signed in to change notification settings - Fork 329
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
mahdipub
wants to merge
1
commit into
adoptium:master
Choose a base branch
from
mahdipub:EBC_pipeline_call
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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") }) { | ||
|
@@ -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" | ||
} | ||
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' | ||
|
@@ -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()) | ||
|
@@ -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), | ||
] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.