Bug 1831243

Summary: Image triggers do not work on v1 StatefulSets
Product: OpenShift Container Platform Reporter: Clayton Coleman <ccoleman>
Component: openshift-controller-managerAssignee: Clayton Coleman <ccoleman>
Status: CLOSED ERRATA QA Contact: wewang <wewang>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.5CC: adam.kaplan, aos-bugs, mfojtik, sdodson
Target Milestone: ---   
Target Release: 4.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: trigger controller was not aware of the GA version of StatefulSet Consequence: triggers could not work on v1.StatefulSet objects Fix: trigger controller now understands v1.StatefulSet Result: triggers work on v1.StatefulSet objects
Story Points: ---
Clone Of:
: 1831245 (view as bug list) Environment:
Last Closed: 2020-07-13 17:34:48 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:
Bug Depends On:    
Bug Blocks: 1831245    

Description Clayton Coleman 2020-05-04 18:15:55 UTC
When trying to trigger based on a v1 StatefulSet, this message is printed to the logs and no trigger occurs:

I0504 18:07:01.962652       1 image_trigger_controller.go:332] Error syncing resource statefulsets.apps/clayton-ci-search/search: unrecognized object - no trigger update possible for *v1.StatefulSet

Will be backported.

Comment 3 wewang 2020-05-08 11:23:16 UTC
@adam I am not sure my steps are correct to verify the bug, could you help to check, thanks.

Steps:
1. Create pod with the following file: 
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: testapp
spec:
  selector:
    matchLabels:
      app: testapp
  replicas: 1
  template:
    metadata:
      labels:
        app: testapp
    spec:
      containers:
      - name: testapp
        image: centos/ruby-25-centos7:latest
        command:
        - /bin/sleep
        args:
        - infinity

2. Check the pod is running

3. Change containers image like "centos/ruby-26-centos7:latest" , then statefulset rollout and pods is running again.

Comment 4 Clayton Coleman 2020-05-08 15:57:52 UTC
Recreator is a stateful set with a trigger:

kind: ImageStream
apiVersion: image.openshift.io/v1
metadata:
  name: ci-search
  namespace: ci-search
spec:
  lookupPolicy:
    local: true
  tags:
  - name: latest
    importPolicy:
      scheduled: true
    from:
      kind: DockerImage
      name: registry.svc.ci.openshift.org/ci/ci-search:latest

When the ci-search tag is updated (manually or scheduled) then the following stateful set should roll out

kind: StatefulSet
apiVersion: apps/v1
metadata:
  name: search
  namespace: ci-search
  annotations:
    image.openshift.io/triggers: '[{"from":{"kind":"ImageStreamTag","name":"ci-search:latest"},"fieldPath":"spec.template.spec.containers[?(@.name==\"web\")].image"}]'
spec:
  selector:
    matchLabels:
      app: search
  template:
    metadata:
      labels:
        app: search
    spec:
      automountServiceAccountToken: false
      volumes:
      - name: bugzilla-token
        secret:
          secretName: bugzilla-credentials-bugzilla.redhat.com
      containers:
      - name: web
        image: ci-search:latest
        resources:
          requests:
            cpu: 100m
            memory: 1Gi
        volumeMounts:
        - name: bugzilla-token
          mountPath: /etc/bugzilla/
        - mountPath: /var/lib/ci-search/
          name: search
        command:
        - /usr/bin/search

Comment 5 wewang 2020-05-09 10:28:32 UTC
Thanks so much @Clayton Coleman, According your ci-search example, be convenient for QE to auto cases, so I verified the bug with follow steps

Version:
4.5.0-0.nightly-2020-05-08-200452

Steps:
1. $oc create -f statefulset-trigger.yaml 

2. $oc get statefulset/testtrigger -o jsonpath={.metadata.generation}	
   2

3. $ oc tag centos/ruby-25-centos7 rubytest:latest
 
[wewang@wangwen ~]$ oc get pods -w
NAME            READY   STATUS        RESTARTS   AGE
testtrigger-0   1/1     Terminating   0          2m35s
testtrigger-0   0/1     Terminating   0          3m4s
testtrigger-0   0/1     Terminating   0          3m5s
testtrigger-0   0/1     Terminating   0          3m5s
testtrigger-0   0/1     Pending       0          0s
testtrigger-0   0/1     Pending       0          0s
testtrigger-0   0/1     ContainerCreating   0          0s
testtrigger-0   0/1     ContainerCreating   0          2s
testtrigger-0   0/1     ContainerCreating   0          11s
testtrigger-0   1/1     Running             0          22s

4. oc get statefulset/testtrigger -o jsonpath={.metadata.generation}
 3

```
[wewang@wangwen ~]$ cat statefulset-trigger.yaml 
apiVersion: v1
kind: List
items:
- apiVersion: image.openshift.io/v1
  kind: ImageStream
  metadata:
    name: rubytest
  spec:
    lookupPolicy:
      local: true
    tags:
    - name: latest
      importPolicy:
        scheduled: true
      from:
        kind: DockerImage
        name: quay.io/openshifttest/ruby-25-centos7
- apiVersion: apps/v1
  kind: StatefulSet
  metadata:
    name: testtrigger
    annotations:
      image.openshift.io/triggers: '[{"from":{"kind":"ImageStreamTag","name":"rubytest:latest"},"fieldPath":"spec.template.spec.containers[?(@.name==\"testtrigger\")].image"}]'
  spec:
    selector:
      matchLabels:
        app: testtrigger
    replicas: 1
    template:
      metadata:
        labels:
          app: testtrigger
      spec:
        containers:
        - name: testtrigger
          image: rubytest:latest
          command:
          - /bin/sleep
          args:
          - infinity
```

Comment 6 wewang 2020-05-09 10:30:23 UTC
Thanks so much @Clayton Coleman, According your ci-search example, be convenient for QE to auto cases, so I verified the bug with follow steps

Version:
4.5.0-0.nightly-2020-05-08-200452

Steps:
1. $oc create -f statefulset-trigger.yaml 

2. $oc get statefulset/testtrigger -o jsonpath={.metadata.generation}	
   2

3. $ oc tag centos/ruby-25-centos7 rubytest:latest
 
[wewang@wangwen ~]$ oc get pods -w
NAME            READY   STATUS        RESTARTS   AGE
testtrigger-0   1/1     Terminating   0          2m35s
testtrigger-0   0/1     Pending       0          0s
testtrigger-0   0/1     ContainerCreating   0          0s
testtrigger-0   1/1     Running             0          22s

4. oc get statefulset/testtrigger -o jsonpath={.metadata.generation}
 3

```
[wewang@wangwen ~]$ cat statefulset-trigger.yaml 
apiVersion: v1
kind: List
items:
- apiVersion: image.openshift.io/v1
  kind: ImageStream
  metadata:
    name: rubytest
  spec:
    lookupPolicy:
      local: true
    tags:
    - name: latest
      importPolicy:
        scheduled: true
      from:
        kind: DockerImage
        name: quay.io/openshifttest/ruby-25-centos7
- apiVersion: apps/v1
  kind: StatefulSet
  metadata:
    name: testtrigger
    annotations:
      image.openshift.io/triggers: '[{"from":{"kind":"ImageStreamTag","name":"rubytest:latest"},"fieldPath":"spec.template.spec.containers[?(@.name==\"testtrigger\")].image"}]'
  spec:
    selector:
      matchLabels:
        app: testtrigger
    replicas: 1
    template:
      metadata:
        labels:
          app: testtrigger
      spec:
        containers:
        - name: testtrigger
          image: rubytest:latest
          command:
          - /bin/sleep
          args:
          - infinity
```

Comment 7 wewang 2020-05-09 10:33:02 UTC
Oh, because of network, I clicked submit twice.

Comment 8 errata-xmlrpc 2020-07-13 17:34:48 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:2409