Skip to content

Commit

Permalink
fix permissions for /consul/extra-config
Browse files Browse the repository at this point in the history
On openshift/okd you might not have permissions to create directories
everywhere. But you can introduce mounts.

Here we're just creating insignificant mount-points for the extra-config
to do it's thing, thus eliminating the need for creating the directory,
which the user running the container might not have permissions to do.

Fixes hashicorp#1306
  • Loading branch information
eb4x committed Jun 30, 2022
1 parent e02f2dd commit d7f0de8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
21 changes: 21 additions & 0 deletions charts/consul/test/unit/client-daemonset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,27 @@ load _helpers
[ "${actual}" = "bar" ]
}

#--------------------------------------------------------------------
# extra-config

@test "client/DaemonSet: has extra-config volume" {
cd `chart_dir`

# check that the extra-config volume is defined
local volume_name=$(helm template \
-s templates/client-daemonset.yaml \
. | tee /dev/stderr |
yq -r '.spec.template.spec.volumes[] | select(.name == "extra-config") | .name' | tee /dev/stderr)
[ "${volume_name}" = "extra-config" ]

# check that the consul container mounts the volume at /consul/extra-config
local mount_path=$(helm template \
-s templates/client-daemonset.yaml \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[] | select(.name == "consul") | .volumeMounts[] | select(.name == "extra-config") | .mountPath' | tee /dev/stderr)
[ "${mount_path}" = "/consul/extra-config" ]
}

#--------------------------------------------------------------------
# extraVolumes

Expand Down
21 changes: 21 additions & 0 deletions charts/consul/test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,27 @@ load _helpers
yq -r '.spec.template.spec.containers[0].command' | tee /dev/stderr)
}

#--------------------------------------------------------------------
# extra-config

@test "server/StatefulSet: has extra-config volume" {
cd `chart_dir`

# check that the extra-config volume is defined
local volume_name=$(helm template \
-s templates/server-statefulset.yaml \
. | tee /dev/stderr |
yq -r '.spec.template.spec.volumes[] | select(.name == "extra-config") | .name' | tee /dev/stderr)
[ "${volume_name}" = "extra-config" ]

# check that the consul container mounts the volume at /consul/extra-config
local mount_path=$(helm template \
-s templates/server-statefulset.yaml \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[] | select(.name == "consul") | .volumeMounts[] | select(.name == "extra-config") | .mountPath' | tee /dev/stderr)
[ "${mount_path}" = "/consul/extra-config" ]
}

#--------------------------------------------------------------------
# extraVolumes

Expand Down

0 comments on commit d7f0de8

Please sign in to comment.