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

add already exists check in object creation #2683

Merged
merged 2 commits into from
Mar 20, 2020
Merged

add already exists check in object creation #2683

merged 2 commits into from
Mar 20, 2020

Conversation

jmccormick2001
Copy link
Contributor

Description of the change:
this PR fixes a situation where an operator being tested with scorecard, creates CRs in its implementation (seeded), this would cause scorecard to fail since it was trying to create the same CRs already seeded. With this change, if a CR is already created, the scorecard will just print a message to the user to let them know when a CR already exists.

Motivation for the change:

Closes #2677

@@ -129,7 +130,9 @@ func createFromYAMLFile(cfg BasicAndOLMPluginConfig, yamlPath string) error {
}
}
err = runtimeClient.Create(context.TODO(), obj)
if err != nil {
if errors.IsAlreadyExists(err) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 👍

Missing just add changelog entry for the fix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, added the changelog entry.

Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 19, 2020
if err != nil {
if errors.IsAlreadyExists(err) {
fmt.Printf("already exists, %s, not creating.", yamlPath)
} else if err != nil {
_, restErr := restMapper.RESTMappings(obj.GetObjectKind().GroupVersionKind().GroupKind())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test for the scenario would be great as well. If it is not too much work

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 20, 2020
Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 20, 2020
Copy link
Member

@jmrodri jmrodri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scorecard failed when the operator generates its seed custom resource.
4 participants