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 · 6 comments · May be fixed by #262
Open

Handle two Modules owning the same resource #163

petar-cvit opened this issue Mar 16, 2024 · 6 comments · May be fixed by #262
Assignees
Labels
go Pull requests that update Go code good first issue Good for newcomers

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

@hanshal101 hanshal101 linked a pull request May 8, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants