Skip to content

WildflyImageOpenShiftProvisioner not handling multiple secrets #347

@tommaso-borgato

Description

@tommaso-borgato

Describe the bug

When implementing method getSecrets() in class WildflyOpenShiftApplication we can theoretically add multiple secrets :

public interface WildflyOpenShiftApplication extends OpenShiftApplication, HasSecrets {
    default List<String> getCliScript() {
        return Collections.emptyList();
    }

    default List<Secret> getSecrets() {
        return Collections.emptyList();
    }
}

Unfortunately, if you add more than one secret, the provisioning fails;

The culprit is probably https://github.com/Intersmash/intersmash/blob/main/provisioners/src/main/java/org/jboss/intersmash/provision/openshift/WildflyImageOpenShiftProvisioner.java#L313:

.addVolumeMount(secret.getMetadata().getName(), "/etc/secrets", false);

where "/etc/secrets" is hard coded and should be, instead, configurable;

To Reproduce
Use Infinispan2ReplicasCustomCertificateService and replace:

Secret customTlsSecret = new SecretBuilder()
				.withNewMetadata()
				.withName(CUSTOM_TLS_SECRET_NAME)
				.withLabels(Collections.singletonMap("app", WILDFLY_APP_NAME))
				.endMetadata()
				.addToData(Map.of("keystore.pkcs12",
						Base64.getEncoder()
								.encodeToString(FileUtils.readFileToByteArray(wildflyCertificate.keystore.toFile()))))
				.addToData(Map.of("truststore.pkcs12",
						Base64.getEncoder()
								.encodeToString(FileUtils.readFileToByteArray(infinispanCertificate.truststore.toFile()))))
				.build();
		secrets.add(customTlsSecret);

with 2 distinct secrets: one containing "keystore.pkcs12" and the other containing "truststore.pkcs12"

Expected behavior
Change/Add:

default List<Secret> getSecrets() {

into e.g.:

default Map<Secret, MountPoint> getSecrets() {

so that the second secrets isn't mounted onto "/etc/secrets" like the former;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions