Bug 1831243 - Image triggers do not work on v1 StatefulSets
Summary: Image triggers do not work on v1 StatefulSets
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: openshift-controller-manager
Version: 4.5
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: 4.5.0
Assignee: Clayton Coleman
QA Contact: wewang
URL:
Whiteboard:
Depends On:
Blocks: 1831245
TreeView+ depends on / blocked
 
Reported: 2020-05-04 18:15 UTC by Clayton Coleman
Modified: 2020-07-13 17:35 UTC (History)
4 users (show)

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
Clone Of:
: 1831245 (view as bug list)
Environment:
Last Closed: 2020-07-13 17:34:48 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift openshift-controller-manager pull 99 0 None closed Bug 1831243: v1 StatefulSets do not trigger on image changes 2020-07-07 03:27:26 UTC
Red Hat Product Errata RHBA-2020:2409 0 None None None 2020-07-13 17:35:11 UTC

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


Note You need to log in before you can comment on or make changes to this bug.