cyclops icon indicating copy to clipboard operation
cyclops copied to clipboard

Handle two Modules owning the same resource

Open petar-cvit opened this issue 1 year ago • 10 comments

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

petar-cvit avatar Mar 16 '24 21:03 petar-cvit

I can work on this issue

hanshal101 avatar May 02 '24 16:05 hanshal101

Thanks @hanshal101!

petar-cvit avatar May 02 '24 16:05 petar-cvit

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

hanshal101 avatar May 02 '24 17:05 hanshal101

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:

  • Module A creates a Deployment called example
  • Module B want to create the same Deployment example and overrides the cyclops.module label and takes over the Deployment

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

petar-cvit avatar May 05 '24 09:05 petar-cvit

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.

hanshal101 avatar May 05 '24 14:05 hanshal101

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

petar-cvit avatar May 08 '24 17:05 petar-cvit

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

ashish111333 avatar Aug 05 '24 07:08 ashish111333

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.

quest-bot[bot] avatar Oct 04 '24 06:10 quest-bot[bot]

Hey if this issue is still open then I would love to work on this issue please

chetak123 avatar Dec 14 '24 08:12 chetak123

Sure thing @chetak123! Let me know if you need any help

petar-cvit avatar Dec 14 '24 16:12 petar-cvit