Bug 1664917 - [AO] install memcached operator failed by ansible-operator in OKD 4.0
Summary: [AO] install memcached operator failed by ansible-operator in OKD 4.0
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Service Broker
Version: 4.1.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 4.1.0
Assignee: Shawn Hurley
QA Contact: Zihan Tang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-01-10 02:51 UTC by Zihan Tang
Modified: 2019-06-04 10:41 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-06-04 10:41:42 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:0758 0 None None None 2019-06-04 10:41:48 UTC

Description Zihan Tang 2019-01-10 02:51:06 UTC
Description of problem:
When follow doc https://github.com/operator-framework/operator-sdk/blob/master/doc/ansible/user-guide.md  to install memcached-operator, it failed to create cr, and report the following error: 
{"level":"error","ts":1547017368.487066,"logger":"kubebuilder.controller","msg":"Reconciler error","controller":"memcached-controller","request":"memca/example-memcached","error":"the server could not find the requested resource","stacktrace":"github.com/water-hole/ansible-operator/vendor/github.com/go-logr/zapr.(*zapLogger).Error\n\t/home/travis/gopath/src/github.com/water-hole/ansible-operator/vendor/github.com/go-logr/zapr/zapr.go:128\ngithub.com/water-hole/ansible-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/home/travis/gopath/src/github.com/water-hole/ansible-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:215\ngithub.com/water-hole/ansible-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func1\n\t/home/travis/gopath/src/github.com/water-hole/ansible-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:158\ngithub.com/water-hole/ansible-operator/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil.func1\n\t/home/travis/gopath/src/github.com/water-hole/ansible-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:133\ngithub.com/water-hole/ansible-operator/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil\n\t/home/travis/gopath/src/github.com/water-hole/ansible-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:134\ngithub.com/water-hole/ansible-operator/vendor/k8s.io/apimachinery/pkg/util/wait.Until\n\t/home/travis/gopath/src/github.com/water-hole/ansible-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:88"}

Version-Release number of selected component (if applicable):
oc v4.0.0-0.123.0
kubernetes v1.11.0+406fc897d8
openshift-install v0.9.0 in aws
ansible-operator: 
quay.io/water-hole/ansible-operator:latests (image id: 919c575d8e63)
# docker images
REPOSITORY                                                                                   TAG                 IMAGE ID            CREATED             SIZE
quay.io/water-hole/ansible-operator                                                          latest              919c575d8e63        3 weeks ago         552 MB


How reproducible:
awlays

Steps to Reproduce:
1. clone the latest operator-sdk code, and build operator-sdk tool.
2. create memcached-operator: 
$ operator-sdk new memcached-operator --api-version=cache.example.com/v1alpha1 --kind=Memcached --type=ansible
$ cd memcached-operator

3. edit some files according to doc
[zitang@dhcp-140-42 memcached-operator]$ cat roles/Memcached/defaults/main.yml 
---
# defaults file for Memcached
size: 1
[zitang@dhcp-140-42 memcached-operator]$ cat watches.yaml 
---
- version: v1alpha1
  group: cache.example.com
  kind: Memcached
  role: /opt/ansible/roles/Memcached
[zitang@dhcp-140-42 memcached-operator]$ 
[zitang@dhcp-140-42 memcached-operator]$ cat roles/Memcached/tasks/main.yml
---
# tasks file for Memcached
- name: start memcached
  k8s:
    definition:
      kind: Deployment
      apiVersion: apps/v1
      metadata:
        name: '{{ meta.name }}-memcached'
        namespace: '{{ meta.namespace }}'
      spec:
        replicas: "{{size}}"
        selector:
          matchLabels:
            app: memcached
        template:
          metadata:
            labels:
              app: memcached
          spec:
            containers:
            - name: memcached
              command:
              - memcached
              - -m=64
              - -o
              - modern
              - -v
              image: "docker.io/memcached:1.4.36-alpine"
              ports:
                - containerPort: 11211

4. build operator and push to dockerhub.
$ operator-sdk build docker.io/zitangbj/memcached-operator:v0.0.1
$ docker push docker.io/zitangbj/memcached-operator:v0.0.1

5. copy the deploy files to 4.0 server(in aws)
6. create operator and memcached instance
[root@ip-10-0-13-11 deploy]# oc project memcached 
Now using project "memcached" on server "https://zitang-api.devcluster.openshift.com:6443".
[root@ip-10-0-13-11 deploy]# oc create -f crds/cache_v1alpha1_memcached_crd.yaml
[root@ip-10-0-13-11 deploy]# oc create -f service_account.yaml 
serviceaccount/memcached-operator created
[root@ip-10-0-13-11 deploy]# oc create -f role.yaml 
role.rbac.authorization.k8s.io/memcached-operator created
[root@ip-10-0-13-11 deploy]# oc create -f role_binding.yaml 
rolebinding.rbac.authorization.k8s.io/memcached-operator created
[root@ip-10-0-13-11 deploy]# oc create -f operator.yaml 
deployment.apps/memcached-operator created

[root@ip-10-0-13-11 deploy]# cat crds/cache_v1alpha1_memcached_cr.yaml 
apiVersion: cache.example.com/v1alpha1
kind: Memcached
metadata:
  name: example-memcached
spec:
  # Add fields here
  size: 3
[root@ip-10-0-13-11 deploy]# oc create -f crds/cache_v1alpha1_memcached_cr.yaml 
memcached.cache.example.com/example-memcached created

Actual results:
memcached instance created failed. 
[root@ip-10-0-13-11 deploy]# oc get pod 
NAME                                  READY     STATUS    RESTARTS   AGE
memcached-operator-566b86f785-fbndw   1/1       Running   0          20m

[root@ip-10-0-13-11 deploy]# oc get memcached -o yaml
apiVersion: v1
items:
- apiVersion: cache.example.com/v1alpha1
  kind: Memcached
  metadata:
    creationTimestamp: 2019-01-09T09:03:33Z
    generation: 1
    name: example-memcached
    namespace: memcached
    resourceVersion: "2022282"
    selfLink: /apis/cache.example.com/v1alpha1/namespaces/memcached/memcacheds/example-memcached
    uid: 70abff82-13ed-11e9-bc0e-020cd1a2255a
  spec:
    size: 3
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""


the error of memcached-operator:

time="2019-01-09T09:03:04Z" level=info msg="Watching memcached namespace."
time="2019-01-09T09:03:04Z" level=info msg="Go Version: go1.10.5"
time="2019-01-09T09:03:04Z" level=info msg="Go OS/Arch: linux/amd64"
time="2019-01-09T09:03:04Z" level=info msg="operator-sdk Version: v0.2.1+git"
{"level":"info","ts":1547024584.5337646,"logger":"proxy","msg":"Starting to serve","Address":"127.0.0.1:8888"}
{"level":"info","ts":1547024584.5341206,"logger":"ansible-controller","msg":"Watching resource","Options.Group":"cache.example.com","Options.Version":"v1alpha1","Options.Kind":"Memcached"}
{"level":"info","ts":1547024584.5356114,"logger":"kubebuilder.controller","msg":"Starting EventSource","controller":"memcached-controller","source":"kind source: cache.example.com/v1alpha1, Kind=Memcached"}
{"level":"info","ts":1547024584.636922,"logger":"kubebuilder.controller","msg":"Starting Controller","controller":"memcached-controller"}
{"level":"info","ts":1547024584.7371154,"logger":"kubebuilder.controller","msg":"Starting workers","controller":"memcached-controller","worker count":1}
{"level":"error","ts":1547024613.0369105,"logger":"kubebuilder.controller","msg":"Reconciler error","controller":"memcached-controller","request":"memcached/example-memcached","error":"the server could not find the requested resource","stacktrace":"github.com/water-hole/ansible-operator/vendor/github.com/go-logr/zapr.(*zapLogger).Error\n\t/home/travis/gopath/src/github.com/water-hole/ansible-operator/vendor/github.com/go-logr/zapr/zapr.go:128\ngithub.com/water-hole/ansible-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/home/travis/gopath/src/github.com/water-hole/ansible-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:215\ngithub.com/water-hole/ansible-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func1\n\t/home/travis/gopath/src/github.com/water-hole/ansible-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:158\ngithub.com/water-hole/ansible-operator/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil.func1\n\t/home/travis/gopath/src/github.com/water-hole/ansible-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:133\ngithub.com/water-hole/ansible-operator/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil\n\t/home/travis/gopath/src/github.com/water-hole/ansible-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:134\ngithub.com/water-hole/ansible-operator/vendor/k8s.io/apimachinery/pkg/util/wait.Until\n\t/home/travis/gopath/src/github.com/water-hole/ansible-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:88"}


Expected results:
memcached instance create successfully

Additional info:

Comment 2 Shawn Hurley 2019-03-27 18:44:39 UTC
Can you please create a reproducer I am unable to reproduce this bug.

I believe that the issue your seeing is the CRD that you define does not contain the:

....
  subresources:
    status:{}
 

which is required

Comment 3 Zhang Cheng 2019-03-28 02:25:49 UTC
zitang is in vacation. I double checked today, was unable to reproduce this bug. Thanks.

Comment 5 errata-xmlrpc 2019-06-04 10:41:42 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-2019:0758


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