woodpecker-ci/woodpecker

Kubernetes resources requests are ignored if numbers are used

Closed this issue · 0 comments

Component

agent

Describe the bug

Woodpecker failed to set Kubernetes resources requests and limits if it's specified with a number instead of string.

    backend_options:
      kubernetes:
        resources:
          requests:
            cpu: 2000m
            memory: 6Gi
            nvidia.com/gpu: 1
            nvidia.com/gpumem: 2000
          limits:
            cpu: 2000m
            memory: 6Gi
            nvidia.com/gpu: 1
            nvidia.com/gpumem: 2000

results in

    Limits:
      cpu:     2
      memory:  6Gi
    Requests:
      cpu:     2
      memory:  6Gi

while

    backend_options:
      kubernetes:
        resources:
          requests:
            cpu: 2000m
            memory: 6Gi
            nvidia.com/gpu: '1'
            nvidia.com/gpumem: '2000'
          limits:
            cpu: 2000m
            memory: 6Gi
            nvidia.com/gpu: '1'
            nvidia.com/gpumem: '2000'

results in

    Limits:
      cpu:                2
      memory:             6Gi
      nvidia.com/gpu:     1
      nvidia.com/gpumem:  2k
    Requests:
      cpu:                2
      memory:             6Gi
      nvidia.com/gpu:     1
      nvidia.com/gpumem:  2k

Steps to reproduce

  1. Install Woodpecker Agent on a Kubernetes with NVIDIA GPU;
  2. Run the workflow.

Expected behavior

All values valid for Kubernetes YAML should be accepted, including numbers for this scenario.

System Info

{"source":"https://github.com/woodpecker-ci/woodpecker","version":"2.8.0"}

Additional context

Log

{"level":"error","error":"4 error(s) decoding:\n\n* 'resources.limits[nvidia.com/gpu]' expected type 'string', got unconvertible type 'float64', value: '1'\n* 'resources.limits[nvidia.com/gpumem]' expected type 'string', got unconvertible type 'float64', value: '2000'\n* 'resources.requests[nvidia.com/gpu]' expected type 'string', got unconvertible type 'float64', value: '1'\n* 'resources.requests[nvidia.com/gpumem]' expected type 'string', got unconvertible type 'float64', value: '2000'","time":"2024-12-02T20:00:16Z","message":"could not parse backend options"}

Validations

  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Checked that the bug isn't fixed in the next version already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]