Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Why are remote agents missing some builtin beans?

Scott Purdy August 23, 2016

I've built a Bamboo plugin task that requires the CredentialsAccessor bean. I've properly annotated it and added the component-import to the atlassian-plugin.xml file and it all works locally with a local agent. But it fails on the remote agent. The remote agent is running inside the "bamboo-agent-docker" Docker image provided by Atlassian. I built a debug Task that prints out available beans and I find that the remote agent in my production environment are missing many things present on my local agent running on my development machine.

How do I get these extra beans on the remote agent?

 

Remote agent (production server) beans:

simple  23-Aug-2016 19:52:34    List of beans:
simple  23-Aug-2016 19:52:34        org.springframework.context.annotation.internalConfigurationAnnotationProcessor : class org.springframework.context.annotation.ConfigurationClassPostProcessor
simple  23-Aug-2016 19:52:34        org.springframework.context.annotation.internalAutowiredAnnotationProcessor : class org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
simple  23-Aug-2016 19:52:34        org.springframework.context.annotation.internalRequiredAnnotationProcessor : class org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor
simple  23-Aug-2016 19:52:34        org.springframework.context.annotation.internalCommonAnnotationProcessor : class org.springframework.context.annotation.CommonAnnotationBeanPostProcessor
simple  23-Aug-2016 19:52:34        componentImportBeanFactoryPostProcessor : class com.atlassian.plugin.spring.scanner.extension.ComponentImportBeanFactoryPostProcessor
simple  23-Aug-2016 19:52:34        serviceExportBeanPostProcessor : class com.atlassian.plugin.spring.scanner.extension.ServiceExporterBeanPostProcessor
simple  23-Aug-2016 19:52:34        devModeBeanInitialisationLoggerBeanPostProcessor : class com.atlassian.plugin.spring.scanner.extension.DevModeBeanInitialisationLoggerBeanPostProcessor
simple  23-Aug-2016 19:52:34        administrationConfigurationAccessor : class com.sun.proxy.$Proxy40
simple  23-Aug-2016 19:52:34        capabilityContext : class com.sun.proxy.$Proxy47
simple  23-Aug-2016 19:52:34        environmentVariableAccessor : class com.sun.proxy.$Proxy70
simple  23-Aug-2016 19:52:34        pluginManager : class com.sun.proxy.$Proxy55
simple  23-Aug-2016 19:52:34        processService : class com.sun.proxy.$Proxy109
simple  23-Aug-2016 19:52:34        textProvider : class com.sun.proxy.$Proxy61

Local agent (dev machine) beans:

simple  23-Aug-2016 09:35:25    List of beans:
simple  23-Aug-2016 09:35:25        org.springframework.context.annotation.internalConfigurationAnnotationProcessor : class org.springframework.context.annotation.ConfigurationClassPostProcessor
simple  23-Aug-2016 09:35:25        org.springframework.context.annotation.internalAutowiredAnnotationProcessor : class org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
simple  23-Aug-2016 09:35:25        org.springframework.context.annotation.internalRequiredAnnotationProcessor : class org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor
simple  23-Aug-2016 09:35:25        org.springframework.context.annotation.internalCommonAnnotationProcessor : class org.springframework.context.annotation.CommonAnnotationBeanPostProcessor
simple  23-Aug-2016 09:35:25        componentImportBeanFactoryPostProcessor : class com.atlassian.plugin.spring.scanner.extension.ComponentImportBeanFactoryPostProcessor
simple  23-Aug-2016 09:35:25        serviceExportBeanPostProcessor : class com.atlassian.plugin.spring.scanner.extension.ServiceExporterBeanPostProcessor
simple  23-Aug-2016 09:35:25        devModeBeanInitialisationLoggerBeanPostProcessor : class com.atlassian.plugin.spring.scanner.extension.DevModeBeanInitialisationLoggerBeanPostProcessor
simple  23-Aug-2016 09:35:25        i18nResolver : class com.sun.proxy.$Proxy447
simple  23-Aug-2016 09:35:25        credentialsAccessor : class com.sun.proxy.$Proxy448
simple  23-Aug-2016 09:35:25        encryptionService : class com.sun.proxy.$Proxy449
simple  23-Aug-2016 09:35:25        administrationConfigurationAccessor : class com.sun.proxy.$Proxy178
simple  23-Aug-2016 09:35:25        authenticationContext : class com.sun.proxy.$Proxy327
simple  23-Aug-2016 09:35:25        buildLogFileAccessorFactory : class com.sun.proxy.$Proxy267
simple  23-Aug-2016 09:35:25        capabilityContext : class com.sun.proxy.$Proxy235
simple  23-Aug-2016 09:35:25        capabilitySetManager : class com.sun.proxy.$Proxy360
simple  23-Aug-2016 09:35:25        deploymentProjectService : class com.sun.proxy.$Proxy381
simple  23-Aug-2016 09:35:25        environmentVariableAccessor : class com.sun.proxy.$Proxy293
simple  23-Aug-2016 09:35:25        pluginManager : class com.sun.proxy.$Proxy265
simple  23-Aug-2016 09:35:25        processService : class com.sun.proxy.$Proxy501
simple  23-Aug-2016 09:35:25        repositoryDefinitionManager : class com.sun.proxy.$Proxy363
simple  23-Aug-2016 09:35:25        taskConfiguratorHelper : class com.sun.proxy.$Proxy191
simple  23-Aug-2016 09:35:25        templateRenderer : class com.sun.proxy.$Proxy380
simple  23-Aug-2016 09:35:25        textProvider : class com.sun.proxy.$Proxy288
simple  23-Aug-2016 09:35:25        uiConfigBean : class com.sun.proxy.$Proxy332

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Scott Purdy August 26, 2016

It looks like we needed to use \@ComponentImport for credentialsAccessor and encryptionService and that the `<component-import .../>` in the atlassian-plugin.xml doesn't work on the versions we are running. So despite all the solutions out there suggesting the use of the xml component-import, we have removed those entirely and rely exclusively on code annotations. We also had to abandon TemplateRenderer (which we were using for non-UI things) since it seems unavailable on the remote agents.

0 votes
Przemek Bruski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 23, 2016

Database is not available on the remote agents and all beans that require it will not be available as well. To make these credentials available to your task, you have to use the ConfigurableSharedCredentialDepender  interface on your TaskDefinition.

Scott Purdy August 23, 2016

Thank you! I will try switching to this now and will follow up.

Scott Purdy August 23, 2016

Could you elaborate a bit? The CredentialsAccessor took a credential ID (long) and returned CredentialsData. The interface that you suggest implementing seems to do the opposite. The function takes a config (unclear what is in it) and expects an iterable of credential IDs (longs) as output. So if I know the credential ID then how do I get the actual stored credentials?

Przemek Bruski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 23, 2016

Through that interface, you declare which credentials are required by your task. You'll then be able to use credentialAccessor to access them (a different instance of that bean is available on the agent, the interface is the same). The bean is definitely available because other plugins are using it. Could you link your plugin xml?

Scott Purdy August 24, 2016

We use that interface (ConfigurableSharedCredentialDepender) in our configurator so that the user can select which credential set to use. We could move our credentialsAccessor to the configurator as well so that it runs on the server but we wouldn't want to store the unencrypted credentials in the task config map and in addition to not having the credentialsAccessor bean on the agent, we also don't have the encryptionService bean (see my list in original post).

So we need access to at least the encryptionService, but preferably also the credentialsAccessor, on the remote agents. But as I showed in my original post, they are not available.

atlassian-plugin.xml: https://gist.github.com/scottpurdy/a49d342c32b4340792ac4fb8ea09a043

Task: https://gist.github.com/scottpurdy/8c4bbbcd2ec24ed0fc6058ff1209eed1

Configurator: https://gist.github.com/scottpurdy/0f8701a5f2a31000d302f0a405ce1465

By the way, the way that I checked which beans were available was using this technique:

http://stackoverflow.com/a/28919634

I did look into the Docker container running the remote agent and the jarfile that contains the credentials accessor interface was present, just didn't seem to have been loaded.

Scott Purdy August 24, 2016

I tried using the Git repository with shared credentials and it worked on a remote agent, successfully pulling the shared credentials. I ran my debug task immediately after which prints the list of beans available and it still did not show the credentialsAccessor or encryptionService beans.

The only difference I see in the GitRepository class is that it uses the `setCredentialsAccessor` method of dependency injection while my plugin uses the \@Autowire annotation.

Przemek Bruski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 24, 2016

Which version are you on? Probably worth trying out the setter injection too.

Scott Purdy August 24, 2016

The server and remote agent are running Bamboo 5.12.3.1.

I stumbled on the `taskContext.getCommonContext().getSharedCredentials()` method which successfully enabled me to get the shared credentials and do away with credentialsAccessor.

However, I still got the bean-not-found error for encryptionService. When I switched to the setter-injection method I got a null pointer exception instead. I could not find any way to get the encryption service.

But we know that the git repository is working with shared credentials and the encryption server using the setter injection so I'm not sure how it works for that but not my plugin.

Sebastien Delcoigne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 26, 2018

I'd be interested to know if any progress have been made on this issue. I too am struggling to get the encryptionService on a remote agent and haven't yet figured out a solution

TAGS
AUG Leaders

Atlassian Community Events