Help Center/ Cloud Container Instance (CCI)/ Best Practices/ Workload Management/ Workload Debugging and Troubleshooting in CCI 2.0
Updated on 2026-05-20 GMT+08:00

Workload Debugging and Troubleshooting in CCI 2.0

Scenario

With CCI, you do not need to manage and maintain the underlying infrastructure. If a workload fails to start or fails the health checks, logging in to a node to view Docker logs is no longer a valid approach.

If either of the following problems occurs, you can refer to this section to solve the problem:

  • Workload startup failure (CrashLoopBackOff): A container exits immediately after startup or exits unexpectedly after it has been running for a period of time. As a result, the terminal cannot be accessed for debugging.
  • Health check failure: After a probe is configured, the pod cannot enter the Ready state or restarts repeatedly.

Constraints

Before debugging, ensure that your network environment and monitoring configuration meet the following requirements for you to pull images and view logs:

  • Network configuration: A NAT gateway (SNAT) (used for public network access) and a VPC endpoint (used to access the SWR image repository over the private network) have been configured in the namespace.
  • Log configuration: You have enabled LTS and created a log group and a log stream. You are advised to enable log collection when creating a workload to retain the standard output logs before the container exits.

Scenario 1: Debugging the Workload Startup Failure

  • Analysis

    Symptom Classification

    Typical Symptom

    Crash upon startup

    The pod status changes to CrashLoopBackOff repeatedly. As a result, logs may not be collected in LTS (because the container exits too quickly).

    Crash after the container is running for a period of time

    The pod exits after running for several seconds or minutes. Logs are recorded in LTS.

  • Solution

    Use the sleep mode for debugging. If faults cannot be located based on logs (for example, dependencies or configuration items are missing, or environment variables are incorrect), you can modify the startup command to forcibly keep the container running, and then enter the container for debugging.

    1. Modify the startup command.
      1. On the console, locate the target workload and click Edit YAML.
      2. In the container settings, modify the startup command to make the container enter an infinite loop or a sleep state.

        The following is an example:

        spec:
          containers:
          - name: container-0
            # Original image
            image: swr.cn-north-4.myhuaweicloud.com/test-namespace/app:v1
            # Modify the startup command to keep the container alive.
            command:
              - /bin/sh
              - '-c'
              - 'while true; do echo hello; sleep 10; done'
      3. Click OK. The container is started successfully and in the Running state.
    2. Enter the container for debugging.
      1. Locate the target workload and click View Terminal in the Operation column.
      2. Select /bin/sh or /bin/bash to access the terminal.
      3. Manually execute the original command to locate the fault: Enter the original startup command of the container image in the terminal to manually trigger the service logic and observe the error.
        • Example scenario: Assume that the original startup command of the workload is ping www.example.co.
        • Execution:
          ping www.example.co
        • Result: "ping: unknown host www.example.co" is displayed in the terminal.
      4. Locate and rectify the fault: The domain name is incorrect (.co should be .com). In this case, you can modify the configuration file or environment variables in the container for verification.
    3. Restore the production configuration.

      After verifying that the solution is effective, return to the console, update the workload, and restore the startup command (Command) and parameters (Args) to the correct configuration.

Scenario 2: Debugging the Health Check Probe Failure

If a liveness probe or readiness probe fails to be configured, the container will be stopped and restarted, or traffic cannot be routed to the container.

  • Common misconfigurations
    • HTTP probe listening address: If the application listens on 127.0.0.1, the probe fails to access the application using the pod IP address by default. As a result, the health check may fail. It is recommended that the application listens on 0.0.0.0.
    • Exec probe timeout: In CCI, if the execution time of the exec script exceeds the value of timeoutSeconds, the probe is considered as failed (Unknown).
    • Mismatched ports: The port detected by the probe must be the same as the port that the application listens on in the container.
  • Solution: Manually simulate the health check.

    Remove the probe first, then perform manual verification, and complete reconfiguration. You are advised to follow this process.

    1. Remove the probe: Update the workload and temporarily delete the health check configuration to ensure that the container can be started and run normally.
    2. Access the container: Remotely log in to the container through the console.
    3. Manually execute the health check command.
      • Verifying HTTP requests:
        # Simulate an HTTP GET request initiated by Kubernetes.
        curl -I http://127.0.0.1:<port>/<path>

        If 404 or Connection refused is returned, the application configuration is incorrect.

      • Verifying the exec command:
        # Manually execute the probe script.
        /bin/sh -c "ls /tmp"

        Check whether 0 is returned and the execution takes too long.

    4. Backfill the configuration: After the manual execution is successful, backfill the parameters to the YAML file or console configuration.
  • Reference configuration example

    The following is a Deployment YAML snippet that contains complete health check configuration:

    apiVersion: cci/v2
    kind: Deployment
    metadata:
      name: health-check-demo
    spec:
      template:
        spec:
          containers:
            - name: app
              image: nginx:latest
              # Liveness probe: checks whether the file exists.
              livenessProbe:
                exec:
                  command: ["/bin/sh", "-c", "ls /tmp"]
                initialDelaySeconds: 5
                timeoutSeconds: 2
                periodSeconds: 10
              # Readiness probe: checks whether the HTTP service is available.
              readinessProbe:
                httpGet:
                  path: /
                  port: 80
                  scheme: HTTP
                initialDelaySeconds: 2
                timeoutSeconds: 1