Skip to content

WIP: feat(status) display failed_reason for a failing Kafka instance#476

Merged
rkpattnaik780 merged 2 commits intomainfrom
fail_reason
Mar 22, 2021
Merged

WIP: feat(status) display failed_reason for a failing Kafka instance#476
rkpattnaik780 merged 2 commits intomainfrom
fail_reason

Conversation

@rkpattnaik780
Copy link
Contributor

Description

Display failed_reason in status of Kafka instances that are failing.

Screenshot from 2021-03-22 12-18-04

Fixes #474

Verification Steps

  1. Select a Kafka instance that has failed status.

go run ./cmd/rhoas kafka use

  1. Run status command to see the status.

go run ./cmd/rhoas status

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • Documentation added for the feature
  • CI and all relevant tests are passing
  • Code Review completed
  • Verified independently by reviewer

Name string `json:"name,omitempty"`
Status string `json:"status,omitempty"`
BootstrapServerHost string `json:"bootstrap_server_host,omitempty" title:"Bootstrap URL"`
FailedReason string `json:"failed_reason,omitempty" title:"Failed Reason"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

omitempty is not getting rid of the FailedReason key when the value is "". Same goes with other fields(tested by hardcoding).

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, we will need to update the status printing logic in printServiceStatus to skip the field if omitempty is set and the value is empty.

}
} else {
logger.Debug("No Kafka instance is currently used, skipping status check")
logger.Debug(localizer.MustLocalizeFromID("status.log.debug.noKafkaSelected"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouild this be logger.Info instead? The user should be able to see this message irrespective of passing the --debug flag, what do you think @craicoverflow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What convention should we follow to localize strings splitted like this?

logger.Info("Run", color.CodeSnippet("rhoas kafka use --id=<kafka-instance-id>"), "to use another Kafka instance.")

Copy link
Contributor

@craicoverflow craicoverflow Mar 22, 2021

Choose a reason for hiding this comment

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

I don't think they need to see that information all the time.

If I use rhoas for only one service "A", and there are 25 other services unused called "B" - "Z", you would get something like this:

$ rhoas status

A
-------------------
Blah:
Blah:
Blah:
Blah:

No B instance is currently used, skipping status check
No C instance is currently used, skipping status check
No D instance is currently used, skipping status check
No E instance is currently used, skipping status check
No F instance is currently used, skipping status check
No G instance is currently used, skipping status check
No H instance is currently used, skipping status check
No I instance is currently used, skipping status check
No J instance is currently used, skipping status check
No K instance is currently used, skipping status check
No L instance is currently used, skipping status check
No M instance is currently used, skipping status check
...

"No B instance is currently used, skipping status check" does not tell the user much more than they can already figure out by there being no status information about the service in the output, but it is useful if they know that this service is currently used, they can check if it is being skipped, which can be useful to debug the problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

What convention should we follow to localize strings splitted like this?

logger.Info("Run", color.CodeSnippet("rhoas kafka use --id=<kafka-instance-id>"), "to use another Kafka instance.")

This was only split because color.CodeSnippet was used so it was easier to mix into the string. The alternative was to use log.Printf.

Since we are using localization now, there will be no need for splitting the strings like this as the full sentence is formed in the locales file.

Copy link
Contributor

@craicoverflow craicoverflow left a comment

Choose a reason for hiding this comment

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

Nice one 👍🏻

@rkpattnaik780 rkpattnaik780 merged commit f585e7c into main Mar 22, 2021
@rkpattnaik780 rkpattnaik780 deleted the fail_reason branch March 22, 2021 15:31
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.

Running rhoas status should show the "failed_reason" field from a Kafka instance status

2 participants