Huawei CSI Services Fail to Be Started and Error Message '/etc/localtime is not a file' Is Displayed

Symptom

During the installation and deployment of CSI, a Pod fails to run and is in the ContainerCreating state. Alarm /etc/localtime is not a file is generated for the Pod.

Root Cause Analysis

When the container mounts the /etc/localtime file on the host, the type is incorrectly identified. As a result, the container fails to mount the /etc/localtime file on the host and the Pod cannot run.

Procedure

  1. Use a remote access tool, such as PuTTY, to log in to any master node in the Kubernetes cluster through the management IP address.

  2. Run the following command to check the running status of the Pod of the CSI services.

    kubectl get pod -n huawei-csi
    

    The following is an example of the command output. huawei-csi indicates the namespace where the CSI services are deployed.

    NAME                                     READY   STATUS               RESTARTS   AGE
    huawei-csi-controller-6dfcc4b79f-9vjtq   9/9     ContainerCreating    0          24m
    huawei-csi-controller-6dfcc4b79f-csphc   9/9     ContainerCreating    0          24m
    huawei-csi-node-g6f4k                    3/3     ContainerCreating    0          20m
    huawei-csi-node-tqs87                    3/3     ContainerCreating    0          20m
    
  3. Run the following command to check the Events parameter of the container.

    kubectl describe pod huawei-csi-controller-6dfcc4b79f-9vjtq -n huawei-csi
    

    The following is an example of the command output. In the command, huawei-csi-controller-6dfcc4b79f-9vjtq indicates the name of the Pod in the ContainerCreating state found in 2, and huawei-csi indicates the namespace to which the Pod belongs.

    ...
    Events:
      Type     Reason       Age                From               Message
      ----     ------       ----               ----               -------
      Normal   Scheduled    96s                default-scheduler  Successfully assigned huawei-csi/huawei-csi-controller-6dfcc4b79f-9vjtq to node1
      Warning  FailedMount  33s (x8 over 96s)  kubelet            MountVolume.SetUp failed for volume "host-time" : hostPath type check failed: /etc/localtime is not a file
    
  4. Run the cd /helm/esdk/templates command to go to the CSI installation package path. For the path, see Table 1.

  5. Take the huawei-csi-controller.yaml file as an example. Run the following command to view the file content.

    vi huawei-csi-controller.yaml
    

    Find the host-time configuration item under volumes, and delete the type: File line. Perform the same operations on the huawei-csi-node.yaml deployment file that involves the configuration item in the templates directory.

    ...
    ...
    volumes:
      - hostPath:
          path: /var/log/
          type: Directory
        name: log
      - hostPath:
          path: /etc/localtime
          type: File
        name: host-time
    ...
    ...
    
  6. Uninstall and reinstall the service by referring to Uninstalling Huawei CSI Using Helm.

  7. Run the following command to check whether the Pod running status of Huawei CSI services is Running.

    kubectl get pod -n huawei-csi
    

    The following is an example of the command output.

    NAME                                     READY   STATUS    RESTARTS   AGE
    huawei-csi-controller-6dfcc4b79f-9vjts   9/9     Running   0          24m
    huawei-csi-controller-6dfcc4b79f-csphb   9/9     Running   0          24m
    huawei-csi-node-g6f41                    3/3     Running   0          20m
    huawei-csi-node-tqs85                    3/3     Running   0          20m