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 notification rule & checks last run status & error #16338

Merged
merged 5 commits into from
Dec 27, 2019

Conversation

asalem1
Copy link
Contributor

@asalem1 asalem1 commented Dec 27, 2019

Closes #15838

Solution

Added lastrunstatus check and error handling for notification rules and check rules

Screen Shot 2019-12-27 at 09 34 16
Screen Shot 2019-12-27 at 09 34 19

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

@asalem1 asalem1 requested review from a team December 27, 2019 17:34
@asalem1 asalem1 requested a review from a team as a code owner December 27, 2019 17:34
@ghost ghost requested review from 121watts and hoorayimhelping and removed request for a team December 27, 2019 17:34
Copy link
Contributor

@kelwang kelwang left a comment

Choose a reason for hiding this comment

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

the go part LGTM

@@ -182,6 +182,18 @@ export const saveCheckFromTimeMachine = () => async (
}
}

export const updateCheck = (check: Partial<Check>) => async (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was previously removed and caused a breaking change. It has been added back here with the intention of refactoring this implementation with a different ticket

Copy link
Contributor

Choose a reason for hiding this comment

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

does this still cause a breaking change? can you link the relevant tickets please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, when I had originally submitted the comment I hadn't had the chance to write up the issue. Here's the breaking change PR:

#16333
but it seems like the changes made to updateCheck weren’t updated here:
https://github.com/influxdata/influxdb/blob/master/ui/src/alerting/components/CheckCard.tsx#L17

and here's the issue that is intended on resolving it :

#16339

<>{relativeTimestampFormatter(check.updatedAt, 'Last updated ')}</>,
<LastRunTaskStatus
key={2}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added the key here to resolve linter errors

Copy link
Contributor

Choose a reason for hiding this comment

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

is this a react warning or a lint error? if react is generating a warning then that's the issue we should address. if lint is mistakenly saying we need a key, we should comment an override here, because it's adding meaning to the code to get around a tool issue. do you understand the difference? a real react warning about a list item not having a key is something we should fix, a mistaken lint error trying to head off that warning is something we should comment about, but not change our code to make go away.

if it's an actual react warning, we should give this a more unique name, if possible. react says to only use the item's list index as a last resort

When you don’t have stable IDs for rendered items, you may use the item index as a key as a last resort:

We don’t recommend using indexes for keys if the order of items may change. This can negatively impact performance and may cause issues with component state.

https://reactjs.org/docs/lists-and-keys.html#keys

same comment and any changes that need to happen apply to RuleCard's key change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was a lint error - i imagine stemming from the way clockface handles metaData being passed dom nodes

<>{relativeTimestampFormatter(rule.updatedAt, 'Last updated ')}</>,
<LastRunTaskStatus
key={2}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added key prop here to resolve linter errors

@asalem1 asalem1 merged commit 79c5c79 into master Dec 27, 2019
Copy link
Contributor

@hoorayimhelping hoorayimhelping left a comment

Choose a reason for hiding this comment

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

Some comments that appear to be too late.

@@ -1130,7 +1140,9 @@ func TestService_handleUpdateCheck(t *testing.T) {
"statusMessageTemplate": "",
"tags": null,
"type": "deadman",
"labels": []
"labels": [],
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like there's some spacing issue here?

@@ -147,7 +147,9 @@ func Test_newNotificationRuleResponses(t *testing.T) {
],
"type": "slack",
"updatedAt": "0001-01-01T00:00:00Z",
"status": "active"
"status": "active",
"latestCompleted": "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.

spacing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hoorayimhelping go won't allow for weird formatting. This may look strange but it's kosher in the actual files

Copy link
Contributor

Choose a reason for hiding this comment

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

i know gfmt controls spacing, but those things can get weird sometimes, it's always good to confirm and not just trust the machines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for sure. It's all good

"updatedAt": "0001-01-01T00:00:00Z"
"updatedAt": "0001-01-01T00:00:00Z",
"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.

spacing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as above

@@ -182,6 +182,18 @@ export const saveCheckFromTimeMachine = () => async (
}
}

export const updateCheck = (check: Partial<Check>) => async (
Copy link
Contributor

Choose a reason for hiding this comment

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

does this still cause a breaking change? can you link the relevant tickets please?

<>{relativeTimestampFormatter(check.updatedAt, 'Last updated ')}</>,
<LastRunTaskStatus
key={2}
Copy link
Contributor

Choose a reason for hiding this comment

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

is this a react warning or a lint error? if react is generating a warning then that's the issue we should address. if lint is mistakenly saying we need a key, we should comment an override here, because it's adding meaning to the code to get around a tool issue. do you understand the difference? a real react warning about a list item not having a key is something we should fix, a mistaken lint error trying to head off that warning is something we should comment about, but not change our code to make go away.

if it's an actual react warning, we should give this a more unique name, if possible. react says to only use the item's list index as a last resort

When you don’t have stable IDs for rendered items, you may use the item index as a key as a last resort:

We don’t recommend using indexes for keys if the order of items may change. This can negatively impact performance and may cause issues with component state.

https://reactjs.org/docs/lists-and-keys.html#keys

same comment and any changes that need to happen apply to RuleCard's key change

} from '@influxdata/clockface'

// Styles
import './LastRunTaskStatus.scss'
Copy link
Contributor

Choose a reason for hiding this comment

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

is this where we want to import this? or should it be imported in in chronograf.scss ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hoorayimhelping this was input by @alexpaxton. I'm not entirely sure on best practices but if it's the case that it should be input into the chronograf file I can go ahead and do that

const triggerRef = useRef<HTMLDivElement>(null)
const [highlight, setHighlight] = useState<boolean>(false)

let color = ComponentColor.Success
Copy link
Contributor

Choose a reason for hiding this comment

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

are there implications to setting the default state to success? if a task run fails and we don't know about it, and we set the status to success, there might be a nonzero impact on the user? what kind of thought have we put into that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If a task run fails and we don't know about it, that's a failure on the API

let icon = IconFont.Checkmark
let text = 'Task ran successfully!'

if (lastRunStatus === 'failed' || lastRunError !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

lastRunError !== undefined

is this this check we want here (rather than a more greedy falsy check)? lastRunError = false | null | '' | {} will pass this check and make the app enter an error state. is that desirable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a great point and definitely something to consider. My thinking here was that since the lastRunError is an optional parameter (it can be undefined), and since the lastRunError should be a string if it is defined, the check for explicitly not undefined (meaning a string should exist) should be sufficient. Anything besides a string should trigger an error for us since our API would be behaving unexpectedly if it did return a more generally false check (like false null). In this case, an empty string being passed in would be more indicative of improper error handling, but not a reason to prevent the functionality

@asalem1 asalem1 deleted the notification-rules branch December 27, 2019 22:17
alexpaxton pushed a commit that referenced this pull request Jan 9, 2020
…16338)

feat(ui): added last run status checks for notification rules and check rules, readded updateCheck to fix linter and functionality issues with program and added tests to ensure check creation and update stability
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.

add last run status to checks/rules
3 participants