Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allure Reports throws a NullPointerException #76

Closed
krmahadevan opened this issue Aug 21, 2019 · 16 comments
Closed

Allure Reports throws a NullPointerException #76

krmahadevan opened this issue Aug 21, 2019 · 16 comments

Comments

@krmahadevan
Copy link
Contributor

I am making use of the latest released version of the bamboo allure plugin viz., 1.11

Our Bamboo cluster has more than one remote agents that are running.

I have setup the allure plugin but when generating reports, here's what I see as an exception

Something went wrong with Allure Report generation. Here are some details: 
java.lang.NullPointerException
	at java.util.Objects.requireNonNull(Objects.java:203)
	at io.qameta.allure.bamboo.AllureArtifactsManager.downloadAllArtifactsTo(AllureArtifactsManager.java:260)
	at io.qameta.allure.bamboo.AllureArtifactsManager.downloadAllArtifactsTo(AllureArtifactsManager.java:183)
	at io.qameta.allure.bamboo.AllureBuildCompleteAction.execute(AllureBuildCompleteAction.java:96)
	at com.atlassian.bamboo.chains.ChainPluginSupportImpl$4.call(ChainPluginSupportImpl.java:140)
	at com.atlassian.bamboo.chains.ChainPluginSupportImpl$4.call(ChainPluginSupportImpl.java:137)
	at com.atlassian.bamboo.chains.ChainPluginSupportImpl$2.call(ChainPluginSupportImpl.java:102)
	at com.atlassian.bamboo.chains.ChainPluginSupportImpl$2.call(ChainPluginSupportImpl.java:98)
	at com.atlassian.bamboo.plugin.BambooPluginUtils.callUnsafeCode(BambooPluginUtils.java:53)
	at com.atlassian.bamboo.chains.ChainPluginSupportImpl.callActionFunction(ChainPluginSupportImpl.java:98)
	at com.atlassian.bamboo.chains.ChainPluginSupportImpl.access$000(ChainPluginSupportImpl.java:45)
	at com.atlassian.bamboo.chains.ChainPluginSupportImpl$1.run(ChainPluginSupportImpl.java:88)
	at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:174)
	at com.atlassian.bamboo.variable.CustomVariableContextRunnerImpl.execute(CustomVariableContextRunnerImpl.java:31)
	at com.atlassian.bamboo.chains.ChainPluginSupportImpl.withCustomVariableContext(ChainPluginSupportImpl.java:85)
	at com.atlassian.bamboo.chains.ChainPluginSupportImpl.chainCompleted(ChainPluginSupportImpl.java:137)
	at sun.reflect.GeneratedMethodAccessor2634.invoke(Unknown Source)

I have checked out the codebase, added some debug statements and built the plugin and our DevOps team install the plugin, turned on the logs and this is what I see

com.atlassian.bamboo.plugin.artifact.handler.remote:BambooRemoteArtifactHandler matches the configured artifact name output for the build PVAI-TAR-67
2019-08-21 09:52:23,909 INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-1] [AllureArtifactsManager] [ALLURE]: artifact output with link type as com.atlassian.bamboo.plugin.artifact.handler.remote:AgentLocalArtifactHandler matches the configured artifact name output for the build PVAI-TAR-67
2019-08-21 09:52:23,912 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-1] [AllureBuildCompleteAction] Failed to build allure report for PVAI (Develop 1.x) - Test allure reports
java.lang.NullPointerException
	at java.util.Objects.requireNonNull(Objects.java:203)
	at io.qameta.allure.bamboo.AllureArtifactsManager.downloadAllArtifactsTo(AllureArtifactsManager.java:260)
	at io.qameta.allure.bamboo.AllureArtifactsManager.downloadAllArtifactsTo(AllureArtifactsManager.java:183)
	at io.qameta.allure.bamboo.AllureBuildCompleteAction.execute(AllureBuildCompleteAction.java:96)

Here's my analysis on this so far :

In this section

                        final ArtifactLinkDataProvider dataProvider = artifactLinkManager.getArtifactLinkDataProvider(artifact);
                        if (dataProvider instanceof FileSystemArtifactLinkDataProvider) {
                            downloadAllArtifactsTo((FileSystemArtifactLinkDataProvider) dataProvider, stageDir);
                        } else {
                            downloadAllArtifactsTo(dataProvider, stageDir, "");
                        }

artifactLinkManager.getArtifactLinkDataProvider(artifact); is returning back a null to dataProvider and so the call eventually goes to downloadAllArtifactsTo(dataProvider, stageDir, ""); which has an edit check to see if it got a null value as seen here

I am not able to figure out as to why would this happen.
I can't afford to keep having multiple debug sessions with our DevOps team as well who are the admins for Bamboo.

So my question here is:

  1. Have you folks vetted out this plugin in a bamboo cluster wherein there is more than one agent running ?
  2. Have you folks seen this error or know what is causing this ?

I have made framework changes to adopt allure and didn't see this coming until I got into bamboo for execution. It would be a real shame for me to undo all the allure reporting adoption and either go after something else or build my own.

Before I start exploring that, please do let me know if you folks have seen this.

cc @baev

@krmahadevan
Copy link
Contributor Author

For what its worth, our bamboo agents are all running on the Amazon Elastic Compute Cloud

@baev
Copy link
Member

baev commented Aug 21, 2019

summon @vbragin

@baev
Copy link
Member

baev commented Aug 21, 2019

summon @smecsia

@krmahadevan
Copy link
Contributor Author

ping @smecsia @vbragin @baev - Any updates on this? I am kind of running out of time and have to quickly make a decision. Any insights into how to fix this issue would be really helpful for me.

apologies if I am sounding a bit pushy or desperate...

1 similar comment
@krmahadevan
Copy link
Contributor Author

ping @smecsia @vbragin @baev - Any updates on this? I am kind of running out of time and have to quickly make a decision. Any insights into how to fix this issue would be really helpful for me.

apologies if I am sounding a bit pushy or desperate...

@smecsia
Copy link
Contributor

smecsia commented Aug 23, 2019

@krmahadevan We're running this plugin with both Elastic Bamboo agents and Per-build-containers with no issues. Although we also have "Artifact handlers" feature enabled with artifacts being uploaded to AWS S3.
A few questions:

  • How does your Bamboo instance store generated artifacts?
  • Can you access artifacts from the build results?
  • Did you try to configure "artifact handlers" according to Allure Docs?

@krmahadevan
Copy link
Contributor Author

@smecsia

How does your Bamboo instance store generated artifacts?

To be frank, I dont know. I can talk to our DevOps and find this out. Any specific things, that I should be asking them ?

Can you access artifacts from the build results?

Yes, when I export the allure-results folder as an artifact, I am able to download all of the JSON files locally (if that's what you are asking).

Did you try to configure "artifact handlers" according to Allure Docs?

Sure I can try doing that. But I would like to know as to what causes Bamboo to return back a null provider? The same setup works fine when I spin off a bamboo instance via atlas-run when building the plugin.

If I could get some pointers around which aspects of the bamboo setup do I need to poke around, I can work with our DevOps to get insights around this and fix it accordingly.

@krmahadevan
Copy link
Contributor Author

ping @smecsia

@krmahadevan
Copy link
Contributor Author

@smecsia - would appreciate if you could please help me with this?

@smecsia
Copy link
Contributor

smecsia commented Sep 4, 2019

@krmahadevan apologies for the long response...

To be frank, I dont know. I can talk to our DevOps and find this out. Any specific things, that I should be asking them ?

Ask them specifically about the artifacts storage and how it's configured. I'm not very familiar with typical Bamboo set-ups, but AFAIK there are different extensions that allow you to store artifacts in different storages (e.g. S3). I believe, answer to this question would give us more info for further investigation.
This plugin has been tested with local agents (when artifacts are stored on the same disk as the server itself) and with S3 artifact handler. I don't know what happens if there's anything else.

@krmahadevan
Copy link
Contributor Author

@smecsia - Thank you for those inputs. I will check with our devops folks and get more information.

@krmahadevan
Copy link
Contributor Author

@smecsia - The logs that I had shared earlier, had some hints around the handler that was getting involved in my case

2019-08-21 09:52:23,909 INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-1] [AllureArtifactsManager] [ALLURE]: artifact output with link type as com.atlassian.bamboo.plugin.artifact.handler.remote:AgentLocalArtifactHandler matches the configured artifact name output for the build PVAI-TAR-67

Its basically of type com.atlassian.bamboo.plugin.artifact.handler.remote:AgentLocalArtifactHandler which am guessing maps to Agent Local Artifact Handler

Do you think that because the nodes are dynamic (as in they get spun off when needed) would cause confusion here, because the artifacts are getting generated in the node, but somehow aren't available to the server (the master node from where the allure command line attempts at generating reports out of them) ?

@smecsia
Copy link
Contributor

smecsia commented Sep 4, 2019

@krmahadevan looks like it. Since Agent Local Artifact Handler stores artifacts on the agent's disk and report generation is happening on the server's side, it simply cannot download artifacts from there. I think we could implement a workaround by accessing Bamboo artifacts directly through the artifacts servlet or find the way how Bamboo serves such artifacts from the artifacts view. TBH I'm not 100% sure how this works. Probably it needs extra hacking and debugging.
There is no integration tests that would run remote agent with agent local artifact handlers currently. If you have time, you could try to reproduce it even locally. Let me know if you identify this as a source issue.

@krmahadevan
Copy link
Contributor Author

Here's what was causing the problem.

The plan was configured to run on elastic bamboo agent. So after the job runs to completion I believe the node was being recycled and the allure reporting command line was trying to refer to a path that doesn't exist and thus resulting in NullPointerException.

I worked with our dev ops team to basically reconfigure the job to run on a local agent after which the problem got resolved.

The reason why I didn't consider this as a problem was because I wasn't sure if this would even be a cause.

Closing this issue. Thanks for the inputs @smecsia which helped me investigate in the right direction.

@baev
Copy link
Member

baev commented Sep 7, 2019

@smecsia @krmahadevan how can we prevent such kind of problems in future? Maybe add a notice to docs/readme or add some additional logging in plugin?

@krmahadevan
Copy link
Contributor Author

krmahadevan commented Sep 8, 2019

@baev - There were a couple of issues that goofed me up and caused a long time before narrowing down the issue.

  1. The problem that was fixed by the PR Fix download url discrepancy. #61
  2. I also believe there's a problem in this line viz.,
    wherein I had to change final Path downloadToFile = createTempFile("allure", ".zip"); into final Path downloadToFile = createTempFile("allure", ".zip").toRealPath();

I came to this conclusion because in our bamboo installation, we had defined the temporary folder and had it pointed to a folder via a symbolic link.

I am not sure if Java would be able to follow up symbolic links. So I made the above change locally and got it working.

Because of both the above issues, I never was able to narrow down to the agent nature to be the root cause of the problem.

So yes, the code definitely could use some additional logging (but then again, this would be visible only if a user has access to the bamboo logs, which am not sure is possible with everyone).

So instead of doing a null check later, we could perhaps add a null check here and if there was a null then print out the artifact.getLinkType() and other attributes and include it as part of a custom exception that gets thrown. That way the exception bubbles up on the bamboo UI.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants