Skip to content

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

Closed
@laxmikantbpandhare

Description

@laxmikantbpandhare

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.

Metadata

Metadata

Labels

kind/bugCategorizes issue or PR as related to a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions