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

Filter out user devfile errors #433

Merged

Conversation

maysunfaisal
Copy link
Member

What does this PR do?:

  • Filters out the user errors in a devfile so that the prometheus metrics reflect a proper state
  • Adds new test case to test the prometheus metric

Which issue(s)/story(ies) does this PR fixes:

https://issues.redhat.com/browse/DEVHAS-580

PR acceptance criteria:

  • Unit/Functional tests

  • Documentation

  • Client Impact

How to test changes / Special notes to the reviewer:

Test with updated metrics should pass

Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Copy link

sonarqubecloud bot commented Jan 9, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
1.9% Duplication on New Code

See analysis details on SonarCloud

@openshift-ci openshift-ci bot requested a review from yangcao77 January 9, 2024 20:08
@openshift-ci openshift-ci bot added the approved label Jan 9, 2024
@maysunfaisal
Copy link
Member Author

/retest

1 similar comment
@maysunfaisal
Copy link
Member Author

/retest

@@ -2371,7 +2371,7 @@ var _ = Describe("SnapshotEnvironmentBinding controller", func() {
return len(createdBinding.Status.GitOpsRepoConditions) > 0 && createdBinding.Status.GitOpsRepoConditions[0].Reason == "GenerateError"
}, timeout, interval).Should(BeTrue())

Expect(createdBinding.Status.GitOpsRepoConditions[0].Message).Should(ContainSubstring("failed to decode devfile json"))
Expect(createdBinding.Status.GitOpsRepoConditions[0].Message).Should(ContainSubstring("cannot unmarshal string into Go value of type map[string]interface"))
Copy link
Member

Choose a reason for hiding this comment

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

What does the full error message look like with this? The test just checks for the substring, so I wasn't sure.

If it's just cannot unmarshal string into Go value of type map[string]interface, it's not really user friendly (compared to the old message), and we should probably update the error string that's set in the SEB status. If it's just a subset, and it mentions something along the lines of "failed to decode devfile" or "failed to parse devfile", then that's fine.

Copy link
Member Author

@maysunfaisal maysunfaisal Jan 10, 2024

Choose a reason for hiding this comment

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

it looks like,

Expected
        <string>: Component updated failed: error parsing devfile because of non-compliant data due to json: cannot unmarshal string into Go value of type map[string]interface {}
    to contain substring
        <string>: cannot unmarslhal string into Go value of type map[string]interface

WDYT?

so i changed it from

failed to decode devfile json: json: cannot unmarshal string into Go value of type map[string]interface {}

to

error parsing devfile because of non-compliant data due to json: cannot unmarshal string into Go value of type map[string]interface {}

The json: cannot unmarshal string into Go value of type map[string]interface {} is coming from the go module and the first bit is ours.

Copy link
Member

Choose a reason for hiding this comment

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

Looks good

@@ -792,7 +792,7 @@ var _ = Describe("Component controller", func() {

errCondition := updatedHasComp.Status.Conditions[len(updatedHasComp.Status.Conditions)-1]
Expect(errCondition.Status).Should(Equal(metav1.ConditionFalse))
Expect(errCondition.Message).Should(ContainSubstring("failed to decode devfile json"))
Expect(errCondition.Message).Should(ContainSubstring("cannot unmarshal string into Go value of type map[string]interface"))
Copy link
Member

Choose a reason for hiding this comment

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

Same comment that I left for SEB

Copy link

codecov bot commented Jan 10, 2024

Codecov Report

Attention: 91 lines in your changes are missing coverage. Please review.

Comparison is base (2fc5811) 81.39% compared to head (d8f2121) 80.56%.
Report is 2 commits behind head on main.

Files Patch % Lines
controllers/component_controller.go 44.06% 56 Missing and 10 partials ⚠️
pkg/devfile/devfile.go 41.17% 10 Missing ⚠️
pkg/devfile/errors.go 0.00% 8 Missing ⚠️
controllers/update.go 16.66% 5 Missing ⚠️
controllers/errors.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #433      +/-   ##
==========================================
- Coverage   81.39%   80.56%   -0.84%     
==========================================
  Files          32       32              
  Lines        4907     5016     +109     
==========================================
+ Hits         3994     4041      +47     
- Misses        715      770      +55     
- Partials      198      205       +7     

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

Copy link

openshift-ci bot commented Jan 10, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: johnmcollier, maysunfaisal

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [johnmcollier,maysunfaisal]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@maysunfaisal maysunfaisal merged commit 1673763 into redhat-appstudio:main Jan 10, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants