m/node/kubernetes: fix attaching block PVs

Attaching a block PV to a container failed with the error:
"failed to create device node at target path: file exists".
This happened because there was already a directory at the path.
The directory should only be created for mounts, not for block devices.

I also extended the PV end-to-end test to add a block volume, and check
that it can be opened as a block device and has the expected size.

Change-Id: I40ca82cfcbfee1cb3196a900423f967b45790a64
Reviewed-on: https://review.monogon.dev/c/monogon/+/3623
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/test/e2e/suites/kubernetes/kubernetes_helpers.go b/metropolis/test/e2e/suites/kubernetes/kubernetes_helpers.go
index 85f8909..25a785d 100644
--- a/metropolis/test/e2e/suites/kubernetes/kubernetes_helpers.go
+++ b/metropolis/test/e2e/suites/kubernetes/kubernetes_helpers.go
@@ -195,6 +195,16 @@
 						VolumeMode: ptr.To(corev1.PersistentVolumeFilesystem),
 					},
 				},
+				{
+					ObjectMeta: metav1.ObjectMeta{Name: "vol-block"},
+					Spec: corev1.PersistentVolumeClaimSpec{
+						AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
+						Resources: corev1.VolumeResourceRequirements{
+							Requests: map[corev1.ResourceName]resource.Quantity{corev1.ResourceStorage: resource.MustParse("1Mi")},
+						},
+						VolumeMode: ptr.To(corev1.PersistentVolumeBlock),
+					},
+				},
 			},
 			Template: corev1.PodTemplateSpec{
 				ObjectMeta: metav1.ObjectMeta{
@@ -209,20 +219,26 @@
 							ImagePullPolicy: corev1.PullIfNotPresent,
 							Image:           "test.monogon.internal/metropolis/test/e2e/persistentvolume/persistentvolume_image",
 							VolumeMounts: []corev1.VolumeMount{
-								corev1.VolumeMount{
+								{
 									Name:      "vol-default",
 									MountPath: "/vol/default",
 								},
-								corev1.VolumeMount{
+								{
 									Name:      "vol-local-strict",
 									MountPath: "/vol/local-strict",
 								},
-								corev1.VolumeMount{
+								{
 									Name:      "vol-readonly",
 									ReadOnly:  true,
 									MountPath: "/vol/readonly",
 								},
 							},
+							VolumeDevices: []corev1.VolumeDevice{
+								{
+									Name:       "vol-block",
+									DevicePath: "/vol/block",
+								},
+							},
 						},
 					},
 				},