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

k8s owner reference is not set in CC child pod #88

Closed
jkneubuh opened this issue Feb 9, 2023 · 8 comments
Closed

k8s owner reference is not set in CC child pod #88

jkneubuh opened this issue Feb 9, 2023 · 8 comments
Labels
wontfix This will not be worked on

Comments

@jkneubuh
Copy link
Contributor

jkneubuh commented Feb 9, 2023

When the chaincode pod is created by the k8s builder, it does not currently set the pod owner attribute.
https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/

Update the owner reference for the child pod such that it is set as a dependent resource created by the peer. This will force k8s to run an automatic GC of the chaincode pod if/when the peer is terminated.

Some original context and thread was discussed over on discord at #fabric-kubernetes, reported by @alius.miles

@jt-nti jt-nti added the good first issue Good for newcomers label Feb 9, 2023
@jt-nti jt-nti added this to the Version 1 milestone Feb 9, 2023
@tbondarchuk
Copy link

Example of project using standalone pods but with owner set: cnpg

@jt-nti
Copy link
Member

jt-nti commented Feb 10, 2023

I think there are a couple of cases where an owner reference won't be possible:

  • The peer, and therefore the k8s builder, doesn't always run in kubernetes
  • If the FABRIC_K8S_BUILDER_NAMESPACE environment variable is set the chaincode pod could be in a different namespace to the peer:
    "A valid owner reference consists of the object name and a UID within the same namespace as the dependent object."

@Vikash-8090-Yadav
Copy link
Contributor

Hey, @jt-nti @jkneubuh I want to work on this. Can u please provide more information on what exactly the problem is?

@jt-nti
Copy link
Member

jt-nti commented May 12, 2023

Hi @Vikash-8090-Yadav, the background to this issue is in a Discord thread which is linked above, along with the Kubernetes doc on owners and dependents. This issue is to add the required configuration to the chaincode pod when possible, e.g. see the link Taras put in his comment. The builder would need to be running in Kubernetes, and in the same namespace, which I think it should be possible to check.

@solo-daemon
Copy link

Hi, I would like to work on this issue

@solo-daemon
Copy link

@jt-nti @jkneubuh I have added a pr which checks if a peer pod exist in the same namespace in which we are creating the chain pod it will set the peer pod as an owner. Is this the right approach ?

@jt-nti
Copy link
Member

jt-nti commented May 3, 2024

Hopefully this issue won't be necessary after switching to kubernetes jobs. See #119

@jt-nti jt-nti added wontfix This will not be worked on and removed good first issue Good for newcomers labels May 3, 2024
@jt-nti jt-nti removed this from the Version 1 milestone May 24, 2024
@jt-nti
Copy link
Member

jt-nti commented May 24, 2024

With #119, kubernetes now cleans up chaincode jobs/pods when the peer is terminated

@jt-nti jt-nti closed this as completed May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants