checkConfig template

The purpose of this template is to provide a means to prevent users from deploying the Helm chart, or updates to it, in what would be a broken state due to known problematic configurations.

The design makes use of multiple templates, providing a modular method of declaring and managing checks. This aids in simplification of both development and maintenance.

General concept

  1. The last item intemplates/NOTES.txtincludes thegitlab.checkConfigtemplate fromtemplates/_checkConfig.tpl.
  2. Thegitlab.checkConfigtemplateincludes further templates in the same file, collecting their outputs (strings) into alist.
  3. Each individual template handles detection of errant configuration, and outputs messages informing the user of how to address the problem, or outputs nothing.
  4. Thegitlab.checkConfigtemplate checks if any messages were collected. If any messages where, it outputs them under a header ofCONFIGURATION:using thefailfunction.
  5. Thefailfunction results in the termination of the deployment process, preventing the user from deploying with a broken configuration.

Template naming

Templates defined within, and used with this pattern should follow the naming convention ofgitlab.checkConfig.*.Replace*here with an informative name, such asredis.bothto denote what this configuration is related to.

Considerations in detection

The developer should be careful not to assume that a key, or parent key will exist. Judicious application ofif,hasKeyandemptyare strongly recommended. It is just as likely for a single key to be present as it is for the entire property map to be missing several branches before that key. Helmwillcomplain if you attempt to access a property that does not exist within the map structure, generally in a vague manor. Save time, be explicit.

Message format

All messages should have the following format:


chart:
message
  • Theifstatement preceding the messageshould nottrim the newline after it. (}}not-}}) This ensures the formatting and readability for the user.
  • The message should declare which chart, relative to the global chart, that is affected. This helps the user understand where the property came from in the charts, and configuration properties. Example:gitlab.puma,minio,registry.
  • The message should inform the user of the properties that cause the failure, and what action should be taken. Name the property relative to the affected chart(s). For example,gitlab.puma.minio.enabledwould be referenced asminio.enabledbecause the chart affected by the deprecation isgitlab.puma.If more than one chart are affected, use complete property names.
  • The messageshould notcontain hard line breaks to wrap paragraphs. This is because the message may interpolate configuration values, and those will break the hard wrapping.

Example message:


redis: both providers
It appears that `redis.enabled` and `redis-ha.enabled` are both true. This will lead to undefined behavior. Please enable only one.

Activating new checks

Once a template has been defined, and logic placed within it for the detection of affected properties, activating this new template is simple. Simply add a line beneathadd templates herein thegitlab.checkConfigtemplate,according to the format presented.

Corresponding tests live inspec/integration/check_config_spec.rb.