cyclops-ui / cyclops

Developer Friendly Kubernetes 👁️
https://cyclops-ui.com
Apache License 2.0
2.48k stars 779 forks source link

Handle two Modules owning the same resource #163

Open petar-cvit opened 7 months ago

petar-cvit commented 7 months ago

Is your feature request related to a problem? Please describe. Each Module will create its own set of resources. When two Modules create the same resource, one of the Modules will report that it has all the resources it should have, while the other one will just say it's empty and that it misses the resource.

Describe the solution you'd like If a new Module is created and it wants to create a resource that is already owned by another Module, it should report on the UI that there is a clash in resources. I wouldn't go with overriding other Modules resource ownership

Additional context Resource ownership is defined on each resource with the label cyclops.module. For example, Module demo created a Deployment app, and the app Deployment will have the label cyclops.module: demo

hanshal101 commented 6 months ago

I can work on this issue

petar-cvit commented 6 months ago

Thanks @hanshal101!

hanshal101 commented 6 months ago

Hey, @petar-cvit, so my approach over here is to make a checkpoint before creating a module to check the resource already exists or not. If true, then return error; otherwise, pass.

What you think of this? Also, I'm having a hard time finding the Create Logic for Modules, the last code I reached was 😅: https://github.com/cyclops-ui/cyclops/blob/f7f36919635cd7344f2ff6c50dea58509bd0de63/cyclops-ctrl/api/v1alpha1/client/modules.go#L53-L65

petar-cvit commented 6 months ago

Hey @hanshal101. K8s API will take care of duplicate Modules, so we don't have to worry about that. The problem is that two Modules can try the create the "same" object.

For example:

You will need to find a mechanism to track shared ownership of resources when creating/updating children resources

hanshal101 commented 6 months ago

Okay correct me if I am wrong so before creating any module, we need to make sure the current deployment label: cyclops.module=example should check if any existing deployment has the same label , if yes the stop and return err.

petar-cvit commented 6 months ago

Yes, so each time you want to create new resources from a Module, you have to check their cyclops.module label. If it's set to something else then the Module name, you should report an error

ashish111333 commented 3 months ago

@petar-cvit want to work on this,can you assign it to me.

quest-bot[bot] commented 1 month ago

New Quest! image New Quest!

A new Quest has been launched in @cyclops-ui’s repo. Merge a PR that solves this issue to loot the Quest and earn your reward.


Some loot has been stashed in this issue to reward the solver!

🗡 Comment @quest-bot embark to check-in for this Quest and start solving the issue. Other solvers will be notified!

⚔️ When you submit a PR, comment @quest-bot loot #163 to link your PR to this Quest.

Questions? Check out the docs.