Quarkus: defaultMode of a ConfigMap volume is 600 (decimal!) by default

Created on 10 Mar 2020  路  10Comments  路  Source: quarkusio/quarkus

Describe the bug

When I specify a ConfigMap volume using the Quarkus Kubernetes extension configuration properties, the volume has by default a defaultMode of 600:

      volumes:
      - configMap:
          defaultMode: 600
          name: "app-config"
          optional: false
        name: "app-config"

This is a decimal number, because it doesn't begin with 0.

The Fabric8 Kubernetes client even warns about that: Invalid value: 600: must be a number between 0 and 0777 (octal), both inclusive.

The documentation says that default value here is 384 (which is 0600). The corresponding *Config classes have @ConfigItem(defaultValue = "0600"), but apparently, when that string is converted to int, it's parsed as decimal, not octal.

Expected behavior
Default value of defaultMode is either 384 or 0600.

Actual behavior
Default value of defaultMode is 600.

To Reproduce
Steps to reproduce the behavior:

  1. Add the quarkus-kubernetes extension.
  2. Specify a ConfigMap in application.properties.
  3. Run mvn clean package -DskipTests.
  4. See target/kubernetes/*.yml.

Configuration

quarkus.kubernetes.deployment-target=openshift
quarkus.openshift.config-map-volumes.app-config.config-map-name=app-config
quarkus.openshift.mounts.app-config.path=/deployments/config
arekubernetes kinbug

Most helpful comment

We have an issue in the MP Config spec for supporting octal constants as integers. I'll make a note to follow up here once that's solved. The issue number is: https://github.com/eclipse/microprofile-config/issues/477

All 10 comments

Nice catch!

One option (that is pretty easy to implement) is to treat the config as always decimal. We could make @ConfigItem(defaultValue = "384") and mention in the docs that it should be decimal number. If you agree, I can submit a PR with that.

I would rather make it a string and use 0600. Conversion to decimal is not that obvious.

This needs to be fixed for 1.3.

I am also in favor of making it a String (since the unix permissions are well understood). @Ladicek do you want to take care of that or should I look into it?

Dekorate unfortunately expects an int. It should be easy to make the type a String in the *Config classes and convert to an int when calling the Dekorate API. Or would we change that in Dekorate as well? (I'll take a stab at the first option, and if we think it's not enough, I'll pass it over to you :-) )

I would say that given our time constraints for 1.3.0.Final, let's just make the change in Quarkus for now.

OK, I have a fix, will submit a PR shortly.

Thanks @Ladicek . And amazing work finding all these small issues!

Submitted #7724.

We have an issue in the MP Config spec for supporting octal constants as integers. I'll make a note to follow up here once that's solved. The issue number is: https://github.com/eclipse/microprofile-config/issues/477

Was this page helpful?
0 / 5 - 0 ratings