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

(analytics): Backend updates for Application dashboard CRUD v2 #2889

Merged

Conversation

ishangupta-ds
Copy link
Member

Proposed changes

  • Updated Create dashboard API to support cloning and return ID.
  • Updated Update dashboard API to support panel updates.
  • Added missing fields to DB & API schema such as, query templates for events and verdicts, application meta data etc.
  • Fixed a bug on incorrect panel group updates in DB via Update dashboard API.

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Bugfix (non-breaking change which fixes an issue)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the commit for DCO to be passed.
  • Lint and unit tests pass locally with my changes

Special notes for your reviewer:

App. dashboard CRUD v2 PR #1

Signed-off-by: ishangupta-ds <ishan@chaosnative.com>
Signed-off-by: ishangupta-ds <ishan@chaosnative.com>
Signed-off-by: ishangupta-ds <ishan@chaosnative.com>
Signed-off-by: ishangupta-ds <ishan@chaosnative.com>
Signed-off-by: ishangupta-ds <ishan@chaosnative.com>
@imrajdas imrajdas self-requested a review June 14, 2021 06:03
@@ -395,11 +395,11 @@ type Mutation {
# Analytics
createDataSource(datasource: DSInput): DSResponse @authorized

createDashBoard(dashboard: createDBInput): String! @authorized
createDashBoard(dashboard: createDBInput): listDashboardReponse! @authorized
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: listDashboardReponse -> listDashboardResponse

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure updating it, it may have been present from a long time.

timestamp := strconv.FormatInt(time.Now().Unix(), 10)

if dashboard.DbID == "" && dashboard.DsID == "" {
return "", errors.New("DashBoard ID or Datasource is nil or empty")
return "could not find the dashboard or the connected data source", errors.New("dashBoard ID or data source ID is nil or empty")
Copy link
Contributor

Choose a reason for hiding this comment

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

or -> and

Copy link
Member Author

Choose a reason for hiding this comment

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

error should be or logic is and

Copy link
Member Author

Choose a reason for hiding this comment

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

any one or both can be false

Copy link
Contributor

Choose a reason for hiding this comment

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

You have given && in the if condition, so this error message will be returned only if both are not present

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, thats likely, will update it

Copy link
Member Author

Choose a reason for hiding this comment

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

updated the condition @SarthakJain26


existingDashboard, err := dbOperationsAnalytics.GetDashboard(query)
if err != nil {
return "error fetching dashboard details", fmt.Errorf("error on query from dashboard collection by projectid: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of returning a custom error message(for the err part) every time, we can just return err. User can understand the error by the string that is being returned. (Just a suggestion)

Copy link
Member Author

Choose a reason for hiding this comment

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

yes but the problem then is to return an empty string since on success we are returning a text message it may be a good practice to return the sting and as for the custom part, the error returned may be a database error and we don't want the user to know the specifics of the database error over the graphQL query (it might be better to use a custom message which may be more understandable to the end user and also for logging purposes) its not a panic.

Copy link
Contributor

Choose a reason for hiding this comment

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

We are returning two parameters: string and error, I'm talking about the error part. Instead of adding a custom error message, we can only return err, that we are doing now as well.
I'm just suggesting to replace fmt.Errorf("error on query from dashboard collection by projectid: %v", err) with err

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes as i mentioned that may spill the collection name etc if its a database error or something. custom message will let us control the logging (also sometimes error returned span a lot of lines and corrupt the server logs) it may be better this way cc: @rajdas98 @gdsoumya There had been a similar case where no data in collection user or something was being logged continuously sometime back.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine if you keep it this way, but you are printing err now as well.

}
panels, err := dbOperationsAnalytics.ListPanel(query)
if err != nil {
return "error fetching panels", fmt.Errorf("error on querying from promquery collection: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

Copy link
Member Author

Choose a reason for hiding this comment

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

Have addressed that comment. Please let me know on your views on the reason of the custom error.

Signed-off-by: ishangupta-ds <ishan@chaosnative.com>
@ishangupta-ds
Copy link
Member Author

@SarthakJain26 the changes have been made PTAL again cc: @rajdas98

Signed-off-by: ishangupta-ds <ishan@chaosnative.com>
@imrajdas imrajdas merged commit ac79879 into litmuschaos:master Jun 14, 2021
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.

None yet

3 participants