jenkinsci / azure-storage-plugin

21 stars 45 forks source link

Problem with downloading artifacts from several Storage Accounts #184

Closed IlyaKiselevKolibri closed 3 years ago

IlyaKiselevKolibri commented 3 years ago

Version report

Jenkins and plugins versions report:

Jenkins: 2.222.1
OS: Linux - 3.10.0-862.9.1.el7.x86_64
---
workflow-multibranch:2.21
bouncycastle-api:2.18
cloudbees-folder:6.12
structs:1.20
jquery:1.12.4-1
junit:1.28
antisamy-markup-formatter:2.0
credentials:2.3.7
durable-task:1.34
workflow-step-api:2.22
plain-credentials:1.7
mapdb-api:1.0.9.0
credentials-binding:1.22
htmlpublisher:1.22
timestamper:1.11.3
script-security:1.71
blueocean:1.23.0
matrix-project:1.14
ant:1.11
xunit:2.3.9
jquery-detached:1.2.1
workflow-api:2.40
ssh-slaves:1.31.2
workflow-support:3.4
pipeline-input-step:2.11
javadoc:1.5
ace-editor:1.1
windows-slaves:1.6
workflow-scm-step:2.11
scm-api:2.6.3
maven-plugin:3.6
workflow-cps:2.80
pipeline-stage-step:2.3
workflow-job:2.38
branch-api:2.5.6
pipeline-graph-analysis:1.10
token-macro:2.12
pipeline-rest-api:2.13
handlebars:1.1.1
momentjs:1.1.1
pipeline-stage-view:2.13
icon-shim:2.0.3
pipeline-build-step:2.12
ssh-credentials:1.18.1
git-client:3.2.1
git-server:1.9
workflow-cps-global-lib:2.16
workflow-durable-task-step:2.35
matrix-auth:2.5
display-url-api:2.3.2
run-condition:1.3
mailer:1.32
workflow-basic-steps:2.20
blueocean-github-pipeline:1.23.0
workflow-aggregator:2.6
git:4.2.2
external-monitor-job:1.7
conditional-buildstep:1.3.6
parameterized-trigger:2.36
build-pipeline-plugin:1.5.8
azure-credentials:4.0.5
gitlab-plugin:1.5.13
jackson2-api:2.10.3
ssh-agent:1.19
influxdb:2.5
docker-commons:1.16
metrics:4.0.2.6
blueocean-config:1.23.0
nunit:0.26
variant:1.3
authentication-tokens:1.3
blueocean-commons:1.23.0
build-timeout:1.19.1
favorite:2.3.2
pipeline-model-definition:1.6.0
sse-gateway:1.23
blueocean-web:1.23.0
github-api:1.111
github-branch-source:2.6.0
blueocean-pipeline-api-impl:1.23.0
blueocean-events:1.23.0
blueocean-personalization:1.23.0
ansicolor:0.6.3
blueocean-dashboard:1.23.0
blueocean-jwt:1.23.0
docker-workflow:1.23
blueocean-rest:1.23.0
blueocean-rest-impl:1.23.0
github:1.29.5
build-name-setter:2.0.4
kubernetes:1.25.3
blueocean-autofavorite:1.2.4
ws-cleanup:0.38
mercurial:2.10
cloudbees-bitbucket-branch-source:2.7.0
blueocean-pipeline-editor:1.23.0
log-parser:2.1
pipeline-stage-tags-metadata:1.6.0
jsch:0.1.55.2
extended-choice-parameter:0.78
node-iterator-api:1.5.0
jira:3.0.15
pipeline-github-lib:1.0
blueocean-i18n:1.23.0
blueocean-display-url:2.3.1
azure-container-agents:1.2.0
pubsub-light:1.13
pipeline-model-api:1.6.0
pipeline-model-declarative-agent:1.1.1
vsphere-cloud:2.23
resource-disposer:0.14
blueocean-git-pipeline:1.23.0
pipeline-model-extensions:1.6.0
pipeline-milestone-step:1.3.1
xframe-filter-plugin:1.2
rebuild:1.31
handy-uri-templates-2-api:2.1.8-1.0
build-user-vars-plugin:1.5
blueocean-jira:1.23.0
azure-ad:1.2.0
copyartifact:1.43.1
command-launcher:1.4
discard-old-build:1.05
pipeline-utility-steps:2.5.0
lockable-resources:2.7
file-leak-detector:1.6
trilead-api:1.0.6
git-parameter:0.9.12
apache-httpcomponents-client-4-api:4.5.10-2.0
blueocean-pipeline-scm-api:1.23.0
blueocean-bitbucket-pipeline:1.23.0
simple-theme-plugin:0.6
azure-commons:1.0.4
dtkit-api:2.1.2
oauth-credentials:0.4
nodelabelparameter:1.7.2
shiningpanda:0.24
jenkins-design-language:1.23.0
google-oauth-plugin:1.0.0
throttle-concurrents:2.0.2
jdk-tool:1.4
kubernetes-client-api:4.9.1-1
windows-azure-storage:1.1.5
slack:2.40
blueocean-core-js:1.23.0
kubernetes-credentials:0.6.2
Controller - Azure Linux VM (centos 7.5.1804); Agents - MacOS Catalina

Reproduction steps

Results

Expected result:

All the artifacts can be downloaded.

Actual result:

The only available artifacts are from the first storage account (it looks like the same signature is being used for both storage accounts). When you try to download the artifacts from the second storage account, there is an error:

<Error>
<Code>AuthenticationFailed</Code>
<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:43e8ab00-d01e-0093-106f-30d116000000 Time:2021-04-13T14:14:10.3954275Z</Message>
<AuthenticationErrorDetail>Signature did not match. String to sign used was r 2021-04-13T15:14:10Z /blob/container_name/folder/subfolder/artifact.ext 2017-04-17 </AuthenticationErrorDetail>
</Error>

Please find the screenshots attached:

Screenshot 2021-04-13 at 16 17 13 Screenshot 2021-04-13 at 14 58 38
timja commented 3 years ago

could you add a sample pipeline?

IlyaKiselevKolibri commented 3 years ago

Sure! Please find below:

pipeline {
    agent {
        label "label"
    }
    stages {
        stage('Upload') {
            steps {
                script {
                    sh("mkdir -p ./folder1 && mkdir -p folder2")
                    sh("touch ./folder1/file && touch ./folder2/file")

                    azureUpload storageCredentialId: StorageAccount1Credentials,
                        storageType: "blobstorage",
                        containerName: "containername",
                        filesPath: "folder1/*",
                        virtualPath: ""

                    azureUpload storageCredentialId: StorageAccount2Credentials,
                        storageType: "blobstorage",
                        containerName: "containername",
                        filesPath: "folder2/*",
                        virtualPath: ""
                }
            }
        }
    }
}
timja commented 3 years ago

thanks I'll try check this out tomorrow

timja commented 3 years ago

I think there might be something missing from the test pipeline?

It passes, am I missing something?

IlyaKiselevKolibri commented 3 years ago

So the problem is not with the uploading part, but when you try to download the artifacts from https:///job///Azure/ page. You will be able to download the artifact from StorageAccount1, but not from the StorageAccount2. Could you please try it?

IlyaKiselevKolibri commented 3 years ago

https://github.com/jenkinsci/azure-storage-plugin/blob/master/src/main/resources/com/microsoftopentechnologies/windowsazurestorage/AzureBlobAction/index.jelly

timja commented 3 years ago

what do you do to get that Action? I don't seem to have it image

IlyaKiselevKolibri commented 3 years ago

Nothing specific to be honest, I just reproduced the error quickly by running docker run --rm -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts, installing Azure Storage plugin, adding 2 azure storage credentials via Jenkins Global settings, then added the above pipeline and I can see this action in build results. The URL in this case is http://localhost:8080/job/jenkins_docker_azure_download_test/5/Azure/

image

IlyaKiselevKolibri commented 3 years ago

Here is a plugin version that I used in the above example, if it helps: image

Also here are the direct download links from the above example:

timja commented 3 years ago

Thanks, reproduced.

I also hit another issue when running it on an agent, do you not hit this? (I've fixed the agent issue locally fairly trivial).

ERROR: AzureStorage - Error occurred while uploading to Azure - timtestvmagentsssd
com.microsoftopentechnologies.windowsazurestorage.exceptions.WAStorageException: Fail to upload individual files to blob
    at com.microsoftopentechnologies.windowsazurestorage.service.UploadToBlobService.uploadIndividuals(UploadToBlobService.java:151)
    at com.microsoftopentechnologies.windowsazurestorage.service.UploadService.execute(UploadService.java:720)
    at com.microsoftopentechnologies.windowsazurestorage.WAStoragePublisher.perform(WAStoragePublisher.java:438)
    at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
    at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:99)
    at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:69)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.io.IOException: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Could not initialize class com.microsoftopentechnologies.windowsazurestorage.service.UploadService
    at com.microsoftopentechnologies.windowsazurestorage.service.UploadService$UploadOnSlave.invoke(UploadService.java:373)
    at com.microsoftopentechnologies.windowsazurestorage.service.UploadService$UploadOnSlave.invoke(UploadService.java:346)
    at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3317)
    at hudson.remoting.UserRequest.perform(UserRequest.java:211)
    at hudson.remoting.UserRequest.perform(UserRequest.java:54)
    at hudson.remoting.Request$2.run(Request.java:376)
    at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:119)
    ... 1 more
    Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to agent
        at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1800)
        at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
        at hudson.remoting.Channel.call(Channel.java:1001)
        at hudson.FilePath.act(FilePath.java:1159)
        at hudson.FilePath.act(FilePath.java:1148)
        at com.microsoftopentechnologies.windowsazurestorage.service.UploadToBlobService.uploadIndividuals(UploadToBlobService.java:142)
        at com.microsoftopentechnologies.windowsazurestorage.service.UploadService.execute(UploadService.java:720)
        at com.microsoftopentechnologies.windowsazurestorage.WAStoragePublisher.perform(WAStoragePublisher.java:438)
        at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
        at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:99)
        at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:69)
        at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        ... 1 more
Caused by: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Could not initialize class com.microsoftopentechnologies.windowsazurestorage.service.UploadService
    at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
    at com.microsoftopentechnologies.windowsazurestorage.service.UploadService$UploadOnSlave.invoke(UploadService.java:370)
    ... 11 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.microsoftopentechnologies.windowsazurestorage.service.UploadService
    at com.microsoftopentechnologies.windowsazurestorage.service.UploadService$UploadThread.execute(UploadService.java:597)
    at com.microsoftopentechnologies.windowsazurestorage.service.UploadService$UploadThread.call(UploadService.java:515)
    at com.microsoftopentechnologies.windowsazurestorage.service.UploadService$UploadThread.call(UploadService.java:423)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    ... 1 more
timja commented 3 years ago

@IlyaKiselevKolibri this PR fixes it: https://github.com/jenkinsci/azure-storage-plugin/pull/185

reading the code I think the same file name different contents across accounts may not work, so I'll test that and either adjust or ship depending on result. Out of time on this for now will get back to it later

IlyaKiselevKolibri commented 3 years ago

Wow, that was super fast, thanks a lot!

Regarding the above exception - I didn't hit anything similar yet.