Skip to content

Bug [2099580] - Deployment is not deleted when CR is deleted in Java operator #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
laxmikantbpandhare opened this issue Jul 6, 2022 · 4 comments · Fixed by #97
Closed
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@laxmikantbpandhare
Copy link
Member

laxmikantbpandhare commented Jul 6, 2022

Bug Report

Description of problem:
Generate one java operator through docs :https://github.com/operator-framework/java-operator-plugins/blob/main/docs/tutorial.md. The CR related resources can't be deleted when CR is deleted.

Version-Release number of selected component (if applicable):
operator-sdk version: "v1.20.0-ocp", commit: "4db4731ae75f2cccae951dd7ed98484662179c55", kubernetes version: "v1.24.1", go version: "go1.18.3", GOOS: "linux", GOARCH: "amd64"

How reproducible:
always

Steps to Reproduce:
1.generate one operator through https://github.com/operator-framework/java-operator-plugins/blob/main/docs/tutorial.md

The Reconciler logic:
https://github.com/operator-framework/java-operator-plugins/blob/main/testdata/quarkus/memcached-quarkus-operator/src/main/java/com/example/MemcachedReconciler.java

2.install the operator
$operator-sdk run bundle quay.io/olmqe/memcached-quarkus-bundle:v0.0.1-kaka
3.create CR
1)$oc create -f resources/memcached-sample.yaml
apiVersion: cache.example.com/v1
kind: Memcached
metadata:
name: memcached-sample
spec:

Add fields here
size: 1
2)$oc get pods
NAME READY STATUS RESTARTS AGE
a65d5ecef355e05847eed8fce0ae58c150f36c48bd5f6589061304ac75dpgpk 0/1 Completed 0 12m
memcached-quarkus-operator-operator-57495bcfcf-hfw6f 1/1 Running 0 37s
memcached-sample-67866884d5-pzcjh 1/1 Running 0 29s
quay-io-olmqe-memcached-quarkus-bundle-v0-0-1-kaka 1/1 Running 0 13m

4.delete CR
1)$ oc delete Memcached memcached-sample
memcached.cache.example.com "memcached-sample" deleted
2)$ oc get pods
NAME READY STATUS RESTARTS AGE
a65d5ecef355e05847eed8fce0ae58c150f36c48bd5f6589061304ac75dpgpk 0/1 Completed 0 33m
memcached-quarkus-operator-operator-57495bcfcf-hfw6f 1/1 Running 0 21m
memcached-sample-67866884d5-pzcjh 1/1 Running 0 21m
quay-io-olmqe-memcached-quarkus-bundle-v0-0-1-kaka 1/1 Running 0 34m

Actual results:
Delete CR success but the related deployment still exists.

Expected results:
CR Memcached memcached-sample and related deployment are deleted success

Additional info:
no logs about Reconciler detail

$oc logs memcached-quarkus-operator-operator-57495bcfcf-hfw6f
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ // / // / __ |/ , / ,< / // /\ \
--_____// |//|//||__/__/
2022-06-21 08:14:05,381 INFO [io.jav.ope.Operator] (main) Registered reconciler: 'memcachedreconciler' for resource: 'class com.example.Memcached' for namespace(s): [all namespaces]
2022-06-21 08:14:05,396 INFO [io.qua.ope.run.AppEventListener] (main) Quarkus Java Operator SDK extension 3.0.7 (commit: 22fed83 on branch: 22fed8391b7b153616bd79c5f829cdd8a7edd5bd) built on Thu Apr 07 14:13:21 GMT 2022
2022-06-21 08:14:05,396 INFO [io.jav.ope.Operator] (main) Operator SDK 2.1.4 (commit: 5af3fec) built on Thu Apr 07 08:31:06 GMT 2022 starting...
2022-06-21 08:14:05,397 INFO [io.jav.ope.Operator] (main) Client version: 5.12.2
2022-06-21 08:14:06,139 INFO [io.quarkus] (main) memcached-quarkus-operator 0.0.1-SNAPSHOT on JVM (powered by Quarkus 2.7.5.Final) started in 2.113s. Listening on: http://0.0.0.0:8080/
2022-06-21 08:14:06,139 INFO [io.quarkus] (main) Profile prod activated.
2022-06-21 08:14:06,140 INFO [io.quarkus] (main) Installed features: [cdi, kubernetes, kubernetes-client, micrometer, openshift-client, operator-sdk, smallrye-context-propagation, smallrye-health, vertx]

What did you do?

Created operator and ran it using OLM. Creation and updating of Custom Resource is working but when I deleted CR it did not delete the created Pods.

What did you expect to see?

It should delete the Pods created by using the Custom resource.

What did you see instead? Under which circumstances?

Pods did not get deleted.

Environment

Operator type:

Quarkus Operator - Memcached Sample

Kubernetes cluster type:

Kind

$ operator-sdk version

operator-sdk version: "v1.22.0-22-gdfb2e8b3-dirty", commit: "dfb2e8b35f1d4412182ffae03c0f8952e03a30c2", kubernetes version: "v1.24.1", go version: "go1.18.3", GOOS: "darwin", GOARCH: "amd64"

$ java -version (if language is Java)

openjdk version "16.0.2" 2021-07-20
OpenJDK Runtime Environment (build 16.0.2+7-67)
OpenJDK 64-Bit Server VM (build 16.0.2+7-67, mixed mode, sharing)

$ kubectl version

Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0", GitCommit:"2c6062082e8dbbf36936b35dcc27c6882d3a2f67", GitTreeState:"clean", BuildDate:"2022-01-11T19:37:02Z", GoVersion:"go1.15.14", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.1", GitCommit:"5e58841cce77d4bc13713ad2b91fa0d961e69192", GitTreeState:"clean", BuildDate:"2021-05-21T23:01:33Z", GoVersion:"go1.16.4", Compiler:"gc", Platform:"linux/amd64"}

Possible Solution

The Cleaner class is not imported which will take care of the finalizers. Check with the Java operator SDK team.

@laxmikantbpandhare laxmikantbpandhare added the kind/bug Categorizes issue or PR as related to a bug. label Jul 6, 2022
@laxmikantbpandhare laxmikantbpandhare self-assigned this Jul 6, 2022
@laxmikantbpandhare
Copy link
Member Author

I am able to recreate the issue and got the idea about the fix as well. I started fixing this.

@csviri
Copy link

csviri commented Jul 6, 2022

As we already discussed with @laxmikantbpandhare seems to be missing owner reference on the created pods.

@laxmikantbpandhare
Copy link
Member Author

this issue is fixed now.

@laxmikantbpandhare
Copy link
Member Author

QE team verified the fix and everything looks good now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants