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

update fuction for MongoDB custom resource #59

Open
horis233 opened this issue Mar 9, 2020 · 1 comment
Open

update fuction for MongoDB custom resource #59

horis233 opened this issue Mar 9, 2020 · 1 comment
Assignees

Comments

@horis233
Copy link
Contributor

horis233 commented Mar 9, 2020

@kgcarr

Currently, MongoDB operator only supports create and delete function. We need to support update function when users edit MongoDB custom resource.

@horis233 horis233 changed the title Update mongodb cr support Update MongoDB custom resource support Mar 9, 2020
@horis233 horis233 changed the title Update MongoDB custom resource support update fuction for MongoDB custom resource Mar 12, 2020
@horis233
Copy link
Contributor Author

horis233 commented Apr 23, 2020

@kgcarr
I can provide an idea about how to implement the update function.

  1. In the 1Q release, we ignore all the IsAlreadyExists error when creating the resources.
	err = r.client.Create(context.TODO(), obj)
	if err != nil && !errors.IsAlreadyExists(err) {
		return fmt.Errorf("could not Create resource: %v", err)
	}
  1. In the 2Q, we and another check for the IsAlreadyExists, if the resource is already exist, you can choose to update the resource.
	err = r.client.Create(context.TODO(), obj)
	if err != nil && !errors.IsAlreadyExists(err) {
		return fmt.Errorf("could not Create resource: %v", err)
	}
        if errors.IsAlreadyExists(err) {
                 	err = r.client.Update(context.TODO(), obj)
	                 if err != nil {
		                 return fmt.Errorf("could not Update resource: %v", err)
	                 }
        }

I am sure if all the MongoDB resources are permitted to be updated in the day2 option. You may need to take a look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants