Bug 1462543

Summary: operator Gt, Lt are expected to support for pod affinity
Product: OpenShift Container Platform Reporter: Weihua Meng <wmeng>
Component: NodeAssignee: Avesh Agarwal <avagarwa>
Status: CLOSED NOTABUG QA Contact: DeShuai Ma <dma>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.6.0CC: aos-bugs, decarr, eparis, jokerman, mmccomas
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-06-19 21:30:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Weihua Meng 2017-06-18 17:12:51 UTC
Description of problem:
operator Gt, Lt are expected to support for pod affinity.
docs says: operators for pod affinity and anti-affinity are In, NotIn, Exists, DoesNotExist, Gt, Lt
https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#inter-pod-affinity-and-anti-affinity-beta-feature

Version-Release number of selected component (if applicable):
openshift v3.6.114
kubernetes v1.6.1+5115d708d7

How reproducible:
Always

Steps to Reproduce:
1. $ oc create -f pod-pod-affinity-gt-3.yaml
$ cat pod-pod-affinity-gt-3.yaml
apiVersion: v1
kind: Pod
metadata:
  name: pod-affinity-gt-3
spec:
  affinity:
    podAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
      - labelSelector:
          matchExpressions:
          - key: team
            operator: Gt
            values:
            - "3"
        topologyKey: kubernetes.io/hostname
  containers:
  - name: pod-affinity
    image: docker.io/ocpqe/hello-pod



Actual results:
$ oc create -f pod-pod-affinity-gt-3.yaml
The Pod "pod-affinity-gt-3" is invalid: spec.affinity.podAffinity.requiredDuringSchedulingIgnoredDuringExecution[0].matchExpressions.matchExpressions[0].operator: Invalid value: "Gt": not a valid selector operator

Expected results:
no error.

Additional info:
if replace "Gt" with "Lt", same issue. 
operators "In, NotIn, Exists, DoesNotExist" work as expected.

Comment 1 Avesh Agarwal 2017-06-19 20:53:05 UTC
I had a discussion about it in todays's kube-sig-scheduler meeting and after discussion with David Oppenheimer@google, the conclusion was that the doc is incorrect about pod affinity/anti-affinity and they only honor regular label selector (In, NotIn, Exists, NotExists) but not Gt and Lt. Also, for node affinity/anti-affinity, it is true that they honor all label operators (In, NotIn, Exists, NotExists, Gt, Lt). So I will send a PR to fix the doc but the functonality is working as expected. I am closing this bug working as expected. Please reopen if you disagree.