Skip to content
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

WIP: add kubernetes auth #18

Closed
wants to merge 2 commits into from
Closed

WIP: add kubernetes auth #18

wants to merge 2 commits into from

Conversation

seanmalloy
Copy link
Contributor

@seanmalloy seanmalloy commented Aug 3, 2018

This pull request does not compile yet. It has not been tested yet.

This pull request depends on BetterCloud/vault-java-driver#122. Also, a new version of the vault-java-driver will need to be released before this will compile.

@seanmalloy
Copy link
Contributor Author

k8s auth support was merged into the master branch of vault-java-driver as part of BetterCloud/vault-java-driver#164. Version 4.1.0 of vault-java-driver needs to be released before the code in this pull request can be tested.

@seanmalloy
Copy link
Contributor Author

Version 4.1.0 of the vault java driver was released today. I should be able to get this working now.

@seanmalloy
Copy link
Contributor Author

The Jenkins pipeline cannot build the plugin. Getting the below error after updating pom.xml to use vault-java-driver 4.1.0.

Seems like this is the most important part of the log ...

[2019-06-25T04:44:27.358Z] [INFO] --- maven-enforcer-plugin:1.3.1:enforce (display-info) @ hashicorp-vault-plugin ---
[2019-06-25T04:44:29.254Z] [INFO] Restricted to JDK 1.8 yet com.bettercloud:vault-java-driver:jar:4.1.0:compile contains module-info.class targeted to 53.0
[2019-06-25T04:44:29.511Z] [WARNING] Rule 2: org.apache.maven.plugins.enforcer.EnforceBytecodeVersion failed with message:
[2019-06-25T04:44:29.511Z] Found Banned Dependency: com.bettercloud:vault-java-driver:jar:4.1.0
[2019-06-25T04:44:29.511Z] Use 'mvn dependency:tree' to locate the source of the banned dependencies.

More of the log ...

[2019-06-25T04:44:23.157Z] + mvn --batch-mode --show-version --errors -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -s /mnt/agent-workspace/workspace/ins_hashicorp-vault-plugin_PR-18@tmp/settings-azure.xml --update-snapshots -Dmaven.repo.local=/mnt/agent-workspace/workspace/ins_hashicorp-vault-plugin_PR-18@tmp/m2repo -Dmaven.test.failure.ignore -Dfindbugs.failOnError=false clean install

[2019-06-25T04:44:23.158Z] Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T18:33:14Z)

[2019-06-25T04:44:23.158Z] Maven home: /mnt/agent-workspace/tools/hudson.tasks.Maven_MavenInstallation/mvn

[2019-06-25T04:44:23.158Z] Java version: 1.8.0_162, vendor: Oracle Corporation, runtime: /mnt/agent-workspace/tools/hudson.model.JDK/jdk8/jre

[2019-06-25T04:44:23.158Z] Default locale: en, platform encoding: UTF-8

[2019-06-25T04:44:23.158Z] OS name: "linux", version: "4.18.0-1020-azure", arch: "amd64", family: "unix"

[2019-06-25T04:44:24.089Z] [INFO] Error stacktraces are turned on.

[2019-06-25T04:44:24.089Z] [INFO] Scanning for projects...

[2019-06-25T04:44:25.462Z] [INFO] 

[2019-06-25T04:44:25.462Z] [INFO] --------< com.datapipe.jenkins.plugins:hashicorp-vault-plugin >---------

[2019-06-25T04:44:25.462Z] [INFO] Building HashiCorp Vault Plugin 2.2.1-SNAPSHOT

[2019-06-25T04:44:25.462Z] [INFO] --------------------------------[ hpi ]---------------------------------

[2019-06-25T04:44:27.358Z] [INFO] 

[2019-06-25T04:44:27.358Z] [INFO] --- maven-clean-plugin:2.6:clean (default-clean) @ hashicorp-vault-plugin ---

[2019-06-25T04:44:27.358Z] [INFO] Deleting /mnt/agent-workspace/workspace/ins_hashicorp-vault-plugin_PR-18/target

[2019-06-25T04:44:27.358Z] [INFO] 

[2019-06-25T04:44:27.358Z] [INFO] --- maven-hpi-plugin:1.121:validate (default-validate) @ hashicorp-vault-plugin ---

[2019-06-25T04:44:27.358Z] [INFO] 

[2019-06-25T04:44:27.358Z] [INFO] --- maven-enforcer-plugin:1.3.1:display-info (display-info) @ hashicorp-vault-plugin ---

[2019-06-25T04:44:27.358Z] [INFO] Maven Version: 3.5.4

[2019-06-25T04:44:27.358Z] [INFO] JDK Version: 1.8.0_162 normalized as: 1.8.0-162

[2019-06-25T04:44:27.358Z] [INFO] OS Info: Arch: amd64 Family: unix Name: linux Version: 4.18.0-1020-azure

[2019-06-25T04:44:27.358Z] [INFO] 

[2019-06-25T04:44:27.358Z] [INFO] --- maven-enforcer-plugin:1.3.1:enforce (display-info) @ hashicorp-vault-plugin ---

[2019-06-25T04:44:29.254Z] [INFO] Restricted to JDK 1.8 yet com.bettercloud:vault-java-driver:jar:4.1.0:compile contains module-info.class targeted to 53.0

[2019-06-25T04:44:29.511Z] [WARNING] Rule 2: org.apache.maven.plugins.enforcer.EnforceBytecodeVersion failed with message:

[2019-06-25T04:44:29.511Z] Found Banned Dependency: com.bettercloud:vault-java-driver:jar:4.1.0

[2019-06-25T04:44:29.511Z] Use 'mvn dependency:tree' to locate the source of the banned dependencies.

[2019-06-25T04:44:29.511Z] [INFO] ------------------------------------------------------------------------

[2019-06-25T04:44:29.511Z] [INFO] BUILD FAILURE

[2019-06-25T04:44:29.511Z] [INFO] ------------------------------------------------------------------------

[2019-06-25T04:44:29.511Z] [INFO] Total time: 5.399 s

[2019-06-25T04:44:29.511Z] [INFO] Finished at: 2019-06-25T04:44:29Z

[2019-06-25T04:44:29.511Z] [INFO] ------------------------------------------------------------------------

[2019-06-25T04:44:29.511Z] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (display-info) on project hashicorp-vault-plugin: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]

[2019-06-25T04:44:29.511Z] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (display-info) on project hashicorp-vault-plugin: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.

[2019-06-25T04:44:29.511Z]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)

[2019-06-25T04:44:29.511Z]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)

[2019-06-25T04:44:29.511Z]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)

[2019-06-25T04:44:29.511Z]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)

[2019-06-25T04:44:29.511Z]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)

[2019-06-25T04:44:29.511Z]     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)

[2019-06-25T04:44:29.511Z]     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)

[2019-06-25T04:44:29.511Z]     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)

[2019-06-25T04:44:29.511Z]     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)

[2019-06-25T04:44:29.511Z]     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)

[2019-06-25T04:44:29.511Z]     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)

[2019-06-25T04:44:29.511Z]     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)

[2019-06-25T04:44:29.511Z]     at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)

[2019-06-25T04:44:29.511Z]     at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

[2019-06-25T04:44:29.511Z]     at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)

[2019-06-25T04:44:29.511Z]     at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)

[2019-06-25T04:44:29.511Z]     at java.lang.reflect.Method.invoke (Method.java:498)

[2019-06-25T04:44:29.511Z]     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)

[2019-06-25T04:44:29.511Z]     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)

[2019-06-25T04:44:29.511Z]     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)

[2019-06-25T04:44:29.511Z]     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)

[2019-06-25T04:44:29.511Z] Caused by: org.apache.maven.plugin.MojoExecutionException: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.

[2019-06-25T04:44:29.511Z]     at org.apache.maven.plugins.enforcer.EnforceMojo.execute (EnforceMojo.java:209)

[2019-06-25T04:44:29.511Z]     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)

[2019-06-25T04:44:29.511Z]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)

[2019-06-25T04:44:29.512Z]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)

[2019-06-25T04:44:29.512Z]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)

[2019-06-25T04:44:29.512Z]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)

[2019-06-25T04:44:29.512Z]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)

[2019-06-25T04:44:29.512Z]     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)

[2019-06-25T04:44:29.512Z]     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)

[2019-06-25T04:44:29.512Z]     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)

[2019-06-25T04:44:29.512Z]     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)

[2019-06-25T04:44:29.512Z]     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)

[2019-06-25T04:44:29.512Z]     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)

[2019-06-25T04:44:29.512Z]     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)

[2019-06-25T04:44:29.512Z]     at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)

[2019-06-25T04:44:29.512Z]     at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

[2019-06-25T04:44:29.512Z]     at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)

[2019-06-25T04:44:29.512Z]     at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)

[2019-06-25T04:44:29.512Z]     at java.lang.reflect.Method.invoke (Method.java:498)

[2019-06-25T04:44:29.512Z]     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)

[2019-06-25T04:44:29.512Z]     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)

[2019-06-25T04:44:29.512Z]     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)

[2019-06-25T04:44:29.512Z]     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)

[2019-06-25T04:44:29.512Z] [ERROR] 

[2019-06-25T04:44:29.512Z] [ERROR] Re-run Maven using the -X switch to enable full debug logging.

[2019-06-25T04:44:29.512Z] [ERROR] 

[2019-06-25T04:44:29.512Z] [ERROR] For more information about the errors and possible solutions, please read the following articles:

[2019-06-25T04:44:29.512Z] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

@sgarlick987
Copy link

Would be really useful to see this get merged.

For that errors it looks like

Restricted to JDK 1.8 yet com.bettercloud:vault-java-driver:jar:4.1.0:compile contains module-info.class targeted to 53.0

the maven enforcer plugin is enforcing 1.8 but the new vault-java-driver dependency uses 1.9?

And

Found Banned Dependency: com.bettercloud:vault-java-driver:jar:4.1.0

It looks like both rules come from the parent pom.xml https://github.com/jenkinsci/plugin-pom/blob/master/pom.xml#L529

I'm not sure the standard practice for jenkins plugins but for the banned dependency I think you could just add an exclusion to this projects pom.xml?

As for the version mismatch, I'm not sure best way to go about it. https://jenkins.io/doc/administration/requirements/java/ says both java 8 and 11 are supported now, so I think you could override that to allow java 11 in the pom.xml, but then this plugin then requires your jenkins to run java 11. Other option I guess would be to recompile the new vault-java-driver to target 1.8, which doesn't seem all that great either.

Copy link
Member

@jetersen jetersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue with OS compatibility.

String token = null;

// TODO: add error handle here
String jwt = new String(Files.readAllBytes(Paths.get("/var/run/secrets/kubernetes.io/serviceaccount/token")));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only work for Linux 😭

@jetersen
Copy link
Member

jetersen commented Aug 2, 2019

With the updated POM as of #31 using v4.1.0 is no problem.

Which is ancient: Mar 22, 2017

@jetersen
Copy link
Member

jetersen commented Aug 2, 2019

https://ci.jenkins.io/blue/organizations/jenkins/Plugins%2Fhashicorp-vault-plugin/detail/PR-18/8/pipeline#log-99 is a legit error :)

@seanmalloy are you good to go fixing the compile errors? 😅

@seanmalloy
Copy link
Contributor Author

seanmalloy commented Aug 6, 2019 via email

@jetersen
Copy link
Member

We are already using vault-java-driver 5.0.0 😅
Would be nice if you could fixup the bits 😓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants