From c226759e09f75557d06e8bce55213ca17c3d2f28 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 2 Aug 2022 18:12:25 -0400 Subject: [PATCH 1/6] Add Windows Min Artifacts Building on Jenkins Signed-off-by: Peter Zhu --- .../opensearch/distribution-build.jenkinsfile | 59 ++++++++++++++++--- src/system/temporary_directory.py | 19 +++++- vars/buildManifest.groovy | 1 + vars/getRepositoryCommit.groovy | 1 + 4 files changed, 68 insertions(+), 12 deletions(-) diff --git a/jenkins/opensearch/distribution-build.jenkinsfile b/jenkins/opensearch/distribution-build.jenkinsfile index b463915a4e..abf505edfe 100644 --- a/jenkins/opensearch/distribution-build.jenkinsfile +++ b/jenkins/opensearch/distribution-build.jenkinsfile @@ -48,6 +48,11 @@ pipeline { description: 'Publish the status of this build job or not.', defaultValue: true ) + booleanParam( + name: 'CREATE_GITHUB_ISSUE', + description: 'To create a github issue for failing component or not.', + defaultValue: false + ) } stages { stage('detect docker image + args') { @@ -194,6 +199,37 @@ pipeline { } } } + stage('build-snapshot-windows-x64-tar') { + agent { + node { + label 'Jenkins-Agent-Windows2019-X64-C54xlarge-Single-Host' + } + } + tools { + jdk dockerAgent.javaVersion + } + steps { + script { + buildManifest( + componentName: "${COMPONENT_NAME}", + inputManifest: "manifests/${INPUT_MANIFEST}", + distribution: 'zip', + platform: 'windows', + snapshot: true + ) + echo("Uploading windows min snapshots to S3") + uploadMinSnapshotsToS3( + fileActions: [createSha512Checksums()], + distribution: 'zip' + ) + } + } + post { + always { + postCleanup() + } + } + } stage('build-and-test-x64-tar') { agent { docker { @@ -265,7 +301,7 @@ pipeline { } } post { - always { + always { script { lib.jenkins.Messages.new(this).add( "${STAGE_NAME}", @@ -443,7 +479,7 @@ pipeline { script { lib.jenkins.Messages.new(this).add( "${STAGE_NAME}", - lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"]) + + lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"]) + "\n${env.ARTIFACT_URL_ARM64_TAR_INTEG_TEST_RESULT}" + "\n${env.ARTIFACT_URL_ARM64_TAR_BWC_TEST_RESULT}" ) @@ -538,7 +574,7 @@ pipeline { postCleanup() } - } + } } } } @@ -565,7 +601,7 @@ pipeline { stage('docker build') { when { beforeAgent true - expression { + expression { params.BUILD_DOCKER != 'do_not_build_docker' } } @@ -581,7 +617,7 @@ pipeline { script { echo "env.ARTIFACT_URL_X64_TAR: ${env.ARTIFACT_URL_X64_TAR}" echo "env.ARTIFACT_URL_ARM64_TAR: ${env.ARTIFACT_URL_ARM64_TAR}" - + buildDockerImage( inputManifest: "manifests/${INPUT_MANIFEST}", buildNumber: "${BUILD_NUMBER}", @@ -597,11 +633,11 @@ pipeline { success { node(AGENT_X64) { script { - if (params.PUBLISH_NOTIFICATION) { + if (params.PUBLISH_NOTIFICATION) { def stashed = lib.jenkins.Messages.new(this).get([ - 'build-and-test-x64-tar', + 'build-and-test-x64-tar', 'assemble-archive-and-test-linux-x64-rpm', - 'build-and-test-arm64-tar', + 'build-and-test-arm64-tar', 'assemble-archive-and-test-linux-arm64-rpm' ]) @@ -621,7 +657,7 @@ pipeline { failure { node(AGENT_X64) { script { - if (params.PUBLISH_NOTIFICATION) { + if (params.PUBLISH_NOTIFICATION) { publishNotification( icon: ':warning:', message: buildFailureMessage(), @@ -629,6 +665,11 @@ pipeline { manifest: "${INPUT_MANIFEST}" ) } + if (params.CREATE_GITHUB_ISSUE) { + createGithubIssue( + message: buildFailureMessage() + ) + } postCleanup() } diff --git a/src/system/temporary_directory.py b/src/system/temporary_directory.py index aff46393d8..5dc348c51c 100644 --- a/src/system/temporary_directory.py +++ b/src/system/temporary_directory.py @@ -10,6 +10,7 @@ import shutil import stat import tempfile +import time from pathlib import Path from types import FunctionType from typing import Any @@ -17,9 +18,21 @@ def g__handleRemoveReadonly(func: FunctionType, path: str, exc: Any) -> Any: excvalue = exc[1] - if func in (os.rmdir, os.remove, os.unlink) and excvalue.errno == errno.EACCES: - os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # 0777 - func(path) + logging.debug(f"excvalue {excvalue}") + logging.debug(f"func {func.__name__}") + if func in (os.rmdir, os.remove, os.unlink): + os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO | stat.S_IWRITE | stat.S_IREAD) # 0777 + try_total = 3 + for try_count in range(try_total): + try: + logging.debug(f'Try count: {try_count + 1}/{try_total}') + func_result = None + func_result = func(path) + if func_result is None: + break + except Exception as ex: + logging.debug(func_result) + logging.debug(ex) else: raise diff --git a/vars/buildManifest.groovy b/vars/buildManifest.groovy index d626505add..2a804e6807 100644 --- a/vars/buildManifest.groovy +++ b/vars/buildManifest.groovy @@ -1,4 +1,5 @@ void call(Map args = [:]) { + echo "haha" sh(([ './build.sh', args.inputManifest ?: "manifests/${INPUT_MANIFEST}", diff --git a/vars/getRepositoryCommit.groovy b/vars/getRepositoryCommit.groovy index c93998eb3f..32279aca7f 100644 --- a/vars/getRepositoryCommit.groovy +++ b/vars/getRepositoryCommit.groovy @@ -14,6 +14,7 @@ void call(Map args = [:]) { OUTPUT_FILE=${args.outputFile} cp -v ${WORKSPACE}/${args.inputManifest} ${WORKSPACE}/\$OUTPUT_FILE + if [ -z "${args.componentName}" ]; then echo "Component list not specified so search the entire input manifest: ${WORKSPACE}/${args.inputManifest}" read -r -a COMPONENT_LIST <<< `yq e '.components[].name' ${WORKSPACE}/${args.inputManifest} | tr '\n' ' '` From d3bb4a0d72413b3edff78b26a39e1b46b3aeffeb Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Fri, 19 Aug 2022 14:54:27 -0400 Subject: [PATCH 2/6] Remove unused libs Signed-off-by: Peter Zhu --- src/system/temporary_directory.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/system/temporary_directory.py b/src/system/temporary_directory.py index 5dc348c51c..bd25e8db08 100644 --- a/src/system/temporary_directory.py +++ b/src/system/temporary_directory.py @@ -4,13 +4,11 @@ # this file be licensed under the Apache-2.0 license or a # compatible open source license. -import errno import logging import os import shutil import stat import tempfile -import time from pathlib import Path from types import FunctionType from typing import Any From cfc364888c8e79dad765d0ee0d95cbe5b1a339b8 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Fri, 19 Aug 2022 14:56:18 -0400 Subject: [PATCH 3/6] Add more comments Signed-off-by: Peter Zhu --- src/system/temporary_directory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/system/temporary_directory.py b/src/system/temporary_directory.py index bd25e8db08..3d4e28c04a 100644 --- a/src/system/temporary_directory.py +++ b/src/system/temporary_directory.py @@ -19,9 +19,9 @@ def g__handleRemoveReadonly(func: FunctionType, path: str, exc: Any) -> Any: logging.debug(f"excvalue {excvalue}") logging.debug(f"func {func.__name__}") if func in (os.rmdir, os.remove, os.unlink): - os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO | stat.S_IWRITE | stat.S_IREAD) # 0777 + os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO | stat.S_IWRITE | stat.S_IREAD) # 0777 nix* / +wr windows try_total = 3 - for try_count in range(try_total): + for try_count in range(try_total): # Re-run func to force deletion especially on windows try: logging.debug(f'Try count: {try_count + 1}/{try_total}') func_result = None From 706a44784eba96c5e698985b5434cb7821fa04d9 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Fri, 19 Aug 2022 14:57:25 -0400 Subject: [PATCH 4/6] Add more comments Signed-off-by: Peter Zhu --- vars/buildManifest.groovy | 1 - vars/getRepositoryCommit.groovy | 1 - 2 files changed, 2 deletions(-) diff --git a/vars/buildManifest.groovy b/vars/buildManifest.groovy index 2a804e6807..d626505add 100644 --- a/vars/buildManifest.groovy +++ b/vars/buildManifest.groovy @@ -1,5 +1,4 @@ void call(Map args = [:]) { - echo "haha" sh(([ './build.sh', args.inputManifest ?: "manifests/${INPUT_MANIFEST}", diff --git a/vars/getRepositoryCommit.groovy b/vars/getRepositoryCommit.groovy index 32279aca7f..c93998eb3f 100644 --- a/vars/getRepositoryCommit.groovy +++ b/vars/getRepositoryCommit.groovy @@ -14,7 +14,6 @@ void call(Map args = [:]) { OUTPUT_FILE=${args.outputFile} cp -v ${WORKSPACE}/${args.inputManifest} ${WORKSPACE}/\$OUTPUT_FILE - if [ -z "${args.componentName}" ]; then echo "Component list not specified so search the entire input manifest: ${WORKSPACE}/${args.inputManifest}" read -r -a COMPONENT_LIST <<< `yq e '.components[].name' ${WORKSPACE}/${args.inputManifest} | tr '\n' ' '` From c75efe558c1c6705caa9009ae7d9a6922c5843ff Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Fri, 19 Aug 2022 15:01:40 -0400 Subject: [PATCH 5/6] Add more comments Signed-off-by: Peter Zhu --- src/system/temporary_directory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/temporary_directory.py b/src/system/temporary_directory.py index 3d4e28c04a..c41aa83f35 100644 --- a/src/system/temporary_directory.py +++ b/src/system/temporary_directory.py @@ -21,7 +21,7 @@ def g__handleRemoveReadonly(func: FunctionType, path: str, exc: Any) -> Any: if func in (os.rmdir, os.remove, os.unlink): os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO | stat.S_IWRITE | stat.S_IREAD) # 0777 nix* / +wr windows try_total = 3 - for try_count in range(try_total): # Re-run func to force deletion especially on windows + for try_count in range(try_total): # Re-run func to force deletion especially on windows try: logging.debug(f'Try count: {try_count + 1}/{try_total}') func_result = None From 2bb56330709ec8e6722d8ac2a6937cd1f30c73bd Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Mon, 22 Aug 2022 14:02:25 -0400 Subject: [PATCH 6/6] Address comments Signed-off-by: Peter Zhu --- src/system/temporary_directory.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/system/temporary_directory.py b/src/system/temporary_directory.py index c41aa83f35..bda92e0fb3 100644 --- a/src/system/temporary_directory.py +++ b/src/system/temporary_directory.py @@ -20,17 +20,16 @@ def g__handleRemoveReadonly(func: FunctionType, path: str, exc: Any) -> Any: logging.debug(f"func {func.__name__}") if func in (os.rmdir, os.remove, os.unlink): os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO | stat.S_IWRITE | stat.S_IREAD) # 0777 nix* / +wr windows - try_total = 3 - for try_count in range(try_total): # Re-run func to force deletion especially on windows + retry_total = 3 + for retry_count in range(retry_total): # Re-run func to force deletion especially on windows try: - logging.debug(f'Try count: {try_count + 1}/{try_total}') - func_result = None + logging.debug(f'Try count: {retry_count + 1}/{retry_total}') func_result = func(path) if func_result is None: break except Exception as ex: - logging.debug(func_result) - logging.debug(ex) + logging.warn(func_result) + logging.warn(ex) else: raise