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

Handle two Modules owning the same resource #163

Open
petar-cvit opened this issue Mar 16, 2024 · 8 comments
Open

Handle two Modules owning the same resource #163

petar-cvit opened this issue Mar 16, 2024 · 8 comments
Labels
controller Update on controller go Pull requests that update Go code hacktoberfest help wanted Extra attention is needed kubernetes k8s related issues ⚔️ Quest Tracks quest-bot quests

Comments

@petar-cvit
Copy link
Collaborator

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 petar-cvit added good first issue Good for newcomers go Pull requests that update Go code labels Mar 16, 2024
@hanshal101
Copy link
Contributor

I can work on this issue

@petar-cvit
Copy link
Collaborator Author

Thanks @hanshal101!

@hanshal101
Copy link
Contributor

hanshal101 commented May 2, 2024

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 😅:

func (c *moduleClient) Create(project *cyclopsv1alpha1.Module) (*cyclopsv1alpha1.Module, error) {
result := cyclopsv1alpha1.Module{}
err := c.restClient.
Post().
Namespace(c.ns).
Resource("modules").
Body(project).
Do(context.Background()).
Into(&result)
return &result, err
}

@petar-cvit
Copy link
Collaborator Author

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

@hanshal101
Copy link
Contributor

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
Copy link
Collaborator Author

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 petar-cvit added help wanted Extra attention is needed controller Update on controller kubernetes k8s related issues and removed good first issue Good for newcomers labels Jul 16, 2024
@ashish111333
Copy link
Contributor

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

@quest-bot quest-bot bot added the ⚔️ Quest Tracks quest-bot quests label Oct 4, 2024
Copy link

quest-bot bot commented Oct 4, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
controller Update on controller go Pull requests that update Go code hacktoberfest help wanted Extra attention is needed kubernetes k8s related issues ⚔️ Quest Tracks quest-bot quests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants