Skip to content

VMStroage pod can't start when an additional volume mount to the storageDataPath #784

@linjunzhe

Description

@linjunzhe

For example, I have following VMCluster CR

apiVersion: operator.victoriametrics.com/v1beta1
kind: VMCluster
metadata:
  name: vmcluster
spec:
  vmstorage:
    storageDataPath: "/storage"
    volumes:
      - hostPath:
          path: /data/victoria/storage
          type: ""
        name: vmstorage-volume
    volumeMounts:
      - mountPath: /storage
        name: vmstorage-volume
...

I just take hostPath as an example here, it cloud be other kind of volume type like cephfs or nfs. The point is I want vmstorage write data to the volume I mounted, not a PVC or emptydir defined in VMCluster.Spec.VMStorage.Storage. But today VM Operator will create a emptydir as a default behavior and mount it to the path defined in storageDataPath. Which in this case, will cause a conflict and vmstorage pod can't start with following errors.

Events:
  Type     Reason            Age                  From                    Message
  ----     ------            ----                 ----                    -------
  Warning  FailedCreate      22s (x16 over 3m5s)  statefulset-controller  create Pod vmstorage-vmcluster-0 in StatefulSet vmstorage-vmcluster failed error: Pod "vmstorage-vmcluster-0" is invalid: spec.containers[0].volumeMounts[1].mountPath: Invalid value: "/storage": must be unique

The pod will have 2 volumeMount in the same path.

      containers:
      - name: vmstorage
         ......
        volumeMounts:
        - mountPath: /storage
          name: vmstorage-db
        - mountPath: /storage
          name: vmstorage-volume
      volumes:
      - hostPath:
          path: /data/victoria/storage
          type: ""
        name: vmstorage-volume
      - emptyDir: {}
        name: vmstorage-db

My proposal is to add a check before appending the default VolumeMount to StorageDataPath if there's already an additional VolumeMount's mountPath equals the StorageDataPath, and skip the default VolumeMount if it's true. I can contribute the code if the proposal is accepted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions