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

Only load a secret which is a file #2489

Merged
merged 2 commits into from
May 15, 2024
Merged

Conversation

jglick
Copy link
Member

@jglick jglick commented May 14, 2024

If you try to use a secret in K8s which is mounted as optional and the Secret does not in fact exist, K8s will make an empty directory and you get an opaque error

SEVERE	hudson.util.BootFailure#publish: Failed to initialize Jenkins
java.io.IOException: Is a directory
	at java.base/sun.nio.ch.FileDispatcherImpl.read0(Native Method)
	at java.base/sun.nio.ch.FileDispatcherImpl.read(FileDispatcherImpl.java:48)
	at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:330)
	at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:296)
	at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:273)
	at java.base/sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:232)
	at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:65)
	at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:107)
	at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:101)
	at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:281)
	at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:324)
	at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:189)
	at java.base/java.io.InputStreamReader.read(InputStreamReader.java:177)
	at java.base/java.io.Reader.read(Reader.java:250)
	at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1608)
	at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1587)
	at org.apache.commons.io.IOUtils.copy(IOUtils.java:1382)
	at org.apache.commons.io.IOUtils.copy(IOUtils.java:1155)
	at org.apache.commons.io.IOUtils.toString(IOUtils.java:3151)
	at org.apache.commons.io.IOUtils.toString(IOUtils.java:3222)
	at org.apache.commons.io.IOUtils.toString(IOUtils.java:3196)
	at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2686)
	at io.jenkins.plugins.casc.impl.secrets.DockerSecretSource.reveal(DockerSecretSource.java:38)
	at io.jenkins.plugins.casc.SecretSourceResolver$ConfigurationContextStringLookup.lambda$lookup$ad236547$1(SecretSourceResolver.java:142)
	at io.vavr.CheckedFunction0.lambda$unchecked$52349c75$1(CheckedFunction0.java:247)
	at io.jenkins.plugins.casc.SecretSourceResolver$ConfigurationContextStringLookup.lambda$lookup$0(SecretSourceResolver.java:142)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1602)
	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
	at io.jenkins.plugins.casc.SecretSourceResolver$ConfigurationContextStringLookup.lookup(SecretSourceResolver.java:144)
	at io.jenkins.plugins.casc.FixedInterpolatorStringLookup.lookup(FixedInterpolatorStringLookup.java:280)
	at org.apache.commons.text.StringSubstitutor.resolveVariable(StringSubstitutor.java:1151)
	at …

Not sure yet what this looks like with the patch, but I hope more informative.

@jglick jglick requested a review from a team as a code owner May 14, 2024 22:05
@jglick jglick marked this pull request as draft May 14, 2024 22:10
@jglick jglick marked this pull request as ready for review May 14, 2024 22:17
@jglick
Copy link
Member Author

jglick commented May 14, 2024

Not tested as such; the secret appeared at the same time I loaded this patch.

@timja timja added the bug label May 15, 2024
@timja timja merged commit 1455f39 into jenkinsci:master May 15, 2024
16 checks passed
@jglick jglick deleted the DockerSecretSource branch May 15, 2024 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants