Skip to content
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

Concurrency-Issue /Event-Loss while deploying multiple CR of same group using Helm Chart #635

Open
shreegithub opened this issue Jul 28, 2024 · 0 comments
Assignees

Comments

@shreegithub
Copy link

Expected behavior (what you expected to happen):

We have usecases to create Kafka topic on AWS MSK on the fly when any application is deployed within Kubernetes Cluster.

We have written one CR/CRD((Api Group "kafka.abc.io")) having the details of topic information. This CR is deployed as part of the application deployment as Helm Chart.

We have written one hook in operator to listen this CR and do appropriate action to create/update topic based on captured Events(Add/Modify).

When Helm chart deploy multiple CR of same Api Group("kafka.abc.io") then shell-operator should capture all the events for the CR added to the cluster.

Actual behavior (what actually happened):

shell-operator is able to capture "Add" Event of only one CR. Other "Add" Events of different CR are being losses because all the CR are added into K8s cluster at same timestamp by Helm Chart

Steps to reproduce:

Apply the below CR using helm chart :

apiVersion: "kafka.abc.io/v1"
kind: topics
metadata:
  name: topics-1
  namespace: test
spec:
  topicName: "kafka-topic1"
  sharedTopicDep: false
---
apiVersion: "kafka.abc.io/v1"
kind: topics
metadata:
  name: topics-2
  namespace: test
spec:
  topicName: "kafka-topic2"
  sharedTopicDep: false

Environment:

  • Shell-operator version: latest
  • Kubernetes version: 1.28
  • Installation type (kubectl apply, helm chart, etc.): Kubectl apply

Anything else we should know?:
Is there any solution to capture the events which got missed due to concurrency?

Script
#!/usr/bin/env bash

if [[ $1 == "--config" ]] ; then
cat <<EOF
{
"configVersion":"v1",
"kubernetes":[{
"apiVersion": "kafka.abc.io/v1",
"kind": "topics",
"executeHookOnEvent":["Added"]
}]
}
EOF
else
type=$(jq -r '.[0].type' ${BINDING_CONTEXT_PATH})

if [[ $type == "Event" ]] ; then
echo "${BINDING_CONTEXT_PATH} @@@@@@@@@@@@@@@@@@@@@@@@@@"
name=$(jq -r '.[0].object.metadata.name' ${BINDING_CONTEXT_PATH})
kind=$(jq -r '.[0].object.kind' ${BINDING_CONTEXT_PATH})
echo "${kind}/${name} object is added ###################"
fi

fi

Logs
{"binding":"kubernetes","event":"kubernetes","hook":"cr-create-call-topic.sh","level":"info","msg":"Execute hook","queue":"main","task":"HookRun","time":"2024-07-23T11:18:25Z"}
{"binding":"kubernetes","event":"kubernetes","hook":"cr-create-call-topic.sh","level":"info","msg":"/tmp/shell-operator/hook-cr-create-call-topic-sh-binding-context-7a6cdaad-b1a9-4206-977f-8300fe3d456b.json @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@","output":"stdout","queue":"main","task":"HookRun","time":"2024-07-23T11:18:25Z"}
{"binding":"kubernetes","event":"kubernetes","hook":"cr-create-call-topic.sh","level":"info","msg":"topics/topics-1 object is added ###################","output":"stdout","queue":"main","task":"HookRun","time":"2024-07-23T11:18:25Z"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants