Skip to content

resourceFieldRef.divisor when unspecified is set to 0 (documented is 1)  #128865

@VannTen

Description

@VannTen

What happened?

The divisor key in ResourceFieldRef is documented to default to 1.

However, when applying a manifest using a resourceFieldRef without specifying the divisor, then checking the spec, the divisor is set to '0'.

What did you expect to happen?

The field should either not be present when checking the manifests, or having the correct value.

How can we reproduce it (as minimally and precisely as possible)?

On a kubernetes cluster, deploy the following manifest:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: test-divisor
  name: test-divisor
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test-divisor
  template:
    metadata:
      labels:
        app: test-divisor
    spec:
      containers:
      - image: invalid-name
        name: test-divisor
        resources:
          limits:
            memory: 30M
        env:
        - name: GOMEMLIMIT
          valueFrom:
            resourceFieldRef:
              resource: limits.memory

Then run

$ kubectl get deploy test-divisor -o jsonpath='{.spec.template.spec.containers[0].env[0].valueFrom.resourceFieldRef.divisor}{"\n"}'
0

Anything else we need to know?

This cause problem for things like argocd which considers the application perpetually out of sync (see cilium/cilium#3063)

Kubernetes version

$ kubectl version
Client Version: v1.31.2
Kustomize Version: v5.4.2
Server Version: v1.29.10
WARNING: version difference between client (1.31) and server (1.29) exceeds the supported minor version skew of +/-1

Cloud provider

None

OS version

$ cat /etc/os-release
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues"
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
LOGO=archlinux-logo

$ uname -a
Linux framework 6.11.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 01 Nov 2024 03:30:41 +0000 x86_64 GNU/Linux

Install tools

Kubespray

Container runtime (CRI) and version (if applicable)

No response

Related plugins (CNI, CSI, ...) and versions (if applicable)

No response

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.sig/appsCategorizes an issue or PR as relevant to SIG Apps.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

Status

Needs Triage

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions