Skip to content

Modified code in utils.go to ignore error when error text contains 'cannot be deleted.' and the error code is 1 (DCNE-380) #1354

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shrsr
Copy link
Collaborator

@shrsr shrsr commented May 15, 2025

No description provided.

…ntains 'cannot be deleted.' and the error code is 1
@shrsr shrsr self-assigned this May 15, 2025
@shrsr shrsr linked an issue May 15, 2025 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented May 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.75%. Comparing base (63f3d21) to head (9f4ebe5).
Report is 70 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1354      +/-   ##
==========================================
- Coverage   86.64%   84.75%   -1.89%     
==========================================
  Files         133      163      +30     
  Lines       76831    96563   +19732     
==========================================
+ Hits        66569    81842   +15273     
- Misses       8198    12234    +4036     
- Partials     2064     2487     +423     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions bot changed the title Modified code in utils.go to ignore error when error text contains 'cannot be deleted.' and the error code is 1 Modified code in utils.go to ignore error when error text contains 'cannot be deleted.' and the error code is 1 (DCNE-380) May 15, 2025
akinross
akinross previously approved these changes May 15, 2025
Copy link
Collaborator

@akinross akinross left a comment

Choose a reason for hiding this comment

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

LGTM

samiib
samiib previously approved these changes May 19, 2025
Copy link
Collaborator

@samiib samiib left a comment

Choose a reason for hiding this comment

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

LGTM

// Ignore errors of type "Cannot create object", "Cannot delete object", "Request in progress" and error text containing "can not be deleted." when the error code is 120
if errCode == "103" || errCode == "107" || errCode == "202" || (errCode == "120" && strings.HasSuffix(errText, "can not be deleted.")) {
// Ignore errors of type "Cannot create object", "Cannot delete object", "Request in progress", error text containing "can not be deleted." when the error code is 120 and error text containing "cannot be deleted." when the error code is 1
if errCode == "103" || errCode == "107" || errCode == "202" || (errCode == "120" && strings.HasSuffix(errText, "can not be deleted.")) || (errCode == "1" && strings.HasSuffix(errText, "cannot be deleted.")) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is a . dot always present at the end of an error message?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure. I think a few messages returned by the API have a dot but a few don't

Copy link
Collaborator

Choose a reason for hiding this comment

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

If so, shouldn't you remove the dot at the end since you're using the HasSuffix? it should then pass whenever or not the error message has a dot at the end

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@gmicol I was referring to all the error messages not just the one that has "cannot be deleted."

Copy link
Collaborator

Choose a reason for hiding this comment

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

Would using string.Contains(errText, "cannot be deleted") be possible to use instead? This way it will handle a full stop at the end or not. It may also handle the same error if additional message text is added to the error in future versions.

gmicol
gmicol previously approved these changes May 20, 2025
Copy link
Collaborator

@gmicol gmicol left a comment

Choose a reason for hiding this comment

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

LGTM

…estroy goes through successfully for undeletable objects
@shrsr shrsr dismissed stale reviews from gmicol, samiib, and akinross via 9f4ebe5 May 22, 2025 14:38
@shrsr shrsr requested review from gmicol, akinross, samiib and sajagana and removed request for gmicol, akinross and samiib May 22, 2025 14:39
// Ignore errors of type "Cannot create object", "Cannot delete object", "Request in progress" and error text containing "can not be deleted." when the error code is 120
if errCode == "103" || errCode == "107" || errCode == "202" || (errCode == "120" && strings.HasSuffix(errText, "can not be deleted.")) {
// Ignore errors of type "Cannot create object", "Cannot delete object", "Request in progress", error text containing "can not be deleted." when the error code is 120 and error text containing "cannot be deleted." when the error code is 1
if errCode == "103" || errCode == "107" || errCode == "202" || (errCode == "120" && strings.HasSuffix(errText, "can not be deleted.")) || (errCode == "1" && strings.HasSuffix(errText, "cannot be deleted.")) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If so, shouldn't you remove the dot at the end since you're using the HasSuffix? it should then pass whenever or not the error message has a dot at the end

@shrsr shrsr requested a review from gmicol May 22, 2025 16:22
// Ignore errors of type "Cannot create object", "Cannot delete object", "Request in progress" and error text containing "can not be deleted." when the error code is 120
if errCode == "103" || errCode == "107" || errCode == "202" || (errCode == "120" && strings.HasSuffix(errText, "can not be deleted.")) {
// Ignore errors of type "Cannot create object", "Cannot delete object", "Request in progress", error text containing "can not be deleted." when the error code is 120 and error text containing "cannot be deleted." when the error code is 1
if errCode == "103" || errCode == "107" || errCode == "202" || (errCode == "120" && strings.HasSuffix(errText, "can not be deleted.")) || (errCode == "1" && strings.HasSuffix(errText, "cannot be deleted.")) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would using string.Contains(errText, "cannot be deleted") be possible to use instead? This way it will handle a full stop at the end or not. It may also handle the same error if additional message text is added to the error in future versions.

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

Successfully merging this pull request may close these issues.

aci_rest_managed resource fails with 400 on destroy (DCNE-380)
6 participants