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

feat(ui): Added Last run status and error messages to check, tasks, and notification rules #16325

Closed
wants to merge 13 commits into from

Conversation

asalem1
Copy link
Contributor

@asalem1 asalem1 commented Dec 23, 2019

Closes #15844
Closes #15838

Problem

check rules and notification rules would not receive relevant data from the API. The UI wasn't built out to display the data. Using the client library vs the generatedRoutes results in a lot of TS issues

Solution

Refactored a good chunk of the client library usage related to the ticket to utilize the generatedRoutes to resolve TS issues. Updated the UI to display newly returned data with the help of @alexpaxton

  • CHANGELOG.md updated with a link to the PR (not the Issue)

@asalem1 asalem1 requested review from a team December 23, 2019 23:08
@asalem1 asalem1 requested a review from a team as a code owner December 23, 2019 23:08
@ghost ghost requested review from drdelambre and ebb-tide and removed request for a team December 23, 2019 23:08
http/notification_rule.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ebb-tide ebb-tide left a comment

Choose a reason for hiding this comment

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

This PR makes a lot more functional changes than is expressed in the PR description. Every place we replace @influxdata/influx with src/client is a place where we are changing the behavior of the app. I would like for us to make these changes for each resource one by one in separate PRs, rather than as part of making Label types match. The @influxdata/influx client adds default properties to labels so that the UI can rely on there existing a color and description property for each label by applying defaults if they don't exist even though they are not guaranteed by the API. oats returns values as they are provided by the API. I am not certain how we should go about replacing this functionality. One option is to add defaults to labels every time we fetch a resource? In this PR we are going in the direction of removing label defaults from resources that used to have them, rather than adding defaults to labels that don't currently have them and I'm not sure this is the direction to go.

Also, I think it's a bad idea for us to make API calls relating to a particular resource through more than one client. Clients have slightly different expectations/behaviors, and getting from one and posting with another is really difficult to reason about.

"status": "active"
"status": "active",
"latestCompleted": "0001-01-01T00:00:00Z",
"latestScheduled": "0001-01-01T00:00:00Z"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure- but would this not also include LastRunStatus and LastRunError ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I completely agree in that we need to test out the LastRunStatus and LastRunError. They should be included for tests that result in an error

ui/src/alerting/components/CheckCard.tsx Show resolved Hide resolved
import {Check, Label, AppState} from 'src/types'

import {Check, AppState} from 'src/types'
import {Label, Labels} from 'src/client'
Copy link
Contributor

Choose a reason for hiding this comment

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

Labels are going to be such a mess as we switch from @influxdata/influx to oats!

name: telegrafConfigName,
description: telegrafConfigDescription,
plugins,
const resp = await api.putTelegraf({
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you comparing this function from oats to the one you are replacing from the other client as you go and making sure they are entirely equivalent? It is making me really nervous that we are essentially rewriting the behavior of the app with these changes just to get label types to match. I would strongly prefer if we made these switches from one client to another each in a separate PR instead of one mega PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @ebb-tide , great question since the putTelegraf was the only one that's been a question in my mind with respect to this refactor. I did use the generateRoutes file in conjunction with the old apis to ensure that the endpoints, data, etc... were all the same:

https://raw.githubusercontent.com/influxdata/influxdb-client-js/master/src/api/api.ts

As I mentioned earlier, this putTelegraf one was (and still is) a question mark since we currently don't require the addition of plugins for putTelegraf as part of the parameters. I'd love to discuss this if you're around today

ui/src/tasks/actions/index.ts Show resolved Hide resolved
@@ -296,7 +312,7 @@ export const updateTaskStatus = (task: Task) => async dispatch => {

export const updateTaskName = (task: Task) => async dispatch => {
try {
await client.tasks.update(task.id, task)
await api.patchTask({taskID: task.id, data: task})
Copy link
Contributor

Choose a reason for hiding this comment

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

These two functions are not equivalent. client.tasks.update has:

    if (!!updates.cron) {
      delete original.every
    }

    if (!!updates.every) {
      delete original.cron
    }

which we would have to do in the UI code if we are switching from one client to the other

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great point, let me know if you're around to talk strategy on it

ui/src/telegrafs/actions/index.ts Show resolved Hide resolved
@asalem1
Copy link
Contributor Author

asalem1 commented Dec 26, 2019

This PR makes a lot more functional changes than is expressed in the PR description. Every place we replace @influxdata/influx with src/client is a place where we are changing the behavior of the app. I would like for us to make these changes for each resource one by one in separate PRs, rather than as part of making Label types match. The @influxdata/influx client adds default properties to labels so that the UI can rely on there existing a color and description property for each label by applying defaults if they don't exist even though they are not guaranteed by the API. oats returns values as they are provided by the API. I am not certain how we should go about replacing this functionality. One option is to add defaults to labels every time we fetch a resource? In this PR we are going in the direction of removing label defaults from resources that used to have them, rather than adding defaults to labels that don't currently have them and I'm not sure this is the direction to go.

Also, I think it's a bad idea for us to make API calls relating to a particular resource through more than one client. Clients have slightly different expectations/behaviors, and getting from one and posting with another is really difficult to reason about.

I totally hear where you're coming from and would agree with you in that this should've been compartmentalized. The issue kind of transformed itself into what it was based on resolving linter errors, hence the reason for its crazy scope. Once Tasks were transformed to update the type, there was a cascade of linter errors that had to be addressed that ran me down from tasks -> labels -> templates -> variables

@asalem1 asalem1 requested review from ebb-tide and kelwang December 26, 2019 15:38
PostCheck,
} from 'src/types'
import {Label} from 'src/client'
Copy link
Contributor

Choose a reason for hiding this comment

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

if you're for serious about this, it'd be easier to just import the Label definition into 'src/types' instead

@@ -148,7 +144,7 @@ const EndpointCard: FC<Props> = ({
}
const labelsComponent = (
<InlineLabels
selectedLabels={endpoint.labels as Label[]}
selectedLabels={endpoint.labels}
Copy link
Contributor

Choose a reason for hiding this comment

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

dope

@@ -16,7 +16,7 @@ import {
updateView as updateViewAJAX,
} from 'src/dashboards/apis'
import {createDashboardFromTemplate as createDashboardFromTemplateAJAX} from 'src/templates/api'

import * as api from 'src/client'
Copy link
Contributor

Choose a reason for hiding this comment

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

be explicit here. it's a contract between modules

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but convention

@@ -3,13 +3,13 @@ import _ from 'lodash'

// Apis
import {client} from 'src/utils/api'
import * as api from 'src/client'
Copy link
Contributor

Choose a reason for hiding this comment

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

be explicit

@asalem1 asalem1 closed this Dec 31, 2019
@jacobmarble jacobmarble deleted the last-run-status branch January 2, 2024 22:43
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.

Display lastRunStatus/Error in the task UI add last run status to checks/rules
5 participants