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

Show healthy / desired allocs in job summary #17 #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jawahars16
Copy link
Contributor

What is this about?

Show healthy and desired allocs count in job summary along with a status indicator. (Follow up on #17)

Example : 2/3 ( 2 allocs are healthy out of 3 desired.)

The status indicator represents the below,

  • ⚠️ Deployment cancelled/failed
  • ❌ Unhealthy allocs
  • ✅ Deployment Success and Healthy
  • ⌛ Deployment Running
  • --- Pending

Preview

damon-job-summary

Copy link
Collaborator

@hcjulz hcjulz left a comment

Choose a reason for hiding this comment

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

Hey @jawahars16, I love the solution with the Emojis 👏 I hope in 2021 there is no issues anymore displaying them on every Terminal :D

The PR looks great! I left a few comments. I think now with the fact that the job view requires to get updates for two topics (Job + Alloc) a subscriber should be able to subscribe to multiple topics at a time.

row := []string{
job.ID,
job.Name,
job.Type,
job.Namespace,
job.Status,
fmt.Sprintf("%d/%d", job.StatusSummary.Running, job.StatusSummary.Total),
reaadyStatus,
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think about adding a short variable name here, like rdyStatus or just status. I first thought it was a typo, before I realized this is to avoid the naming crash of the helper function.

@@ -35,6 +35,7 @@ func TestJobTable_Happy(t *testing.T) {
Status: "running",
StatusDescription: "fine",
StatusSummary: models.Summary{Total: 2, Running: 2},
Copy link
Collaborator

Choose a reason for hiding this comment

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

The StatusSummary field isn't used anymore, do you mind removing it?

@@ -47,6 +47,7 @@ func (v *View) Jobs() {
}

v.Watcher.Subscribe(api.TopicJob, update)
v.Watcher.Subscribe(api.TopicAllocation, update)
Copy link
Collaborator

Choose a reason for hiding this comment

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

In Damon, there is always a single subscriber at a time. Here we overwrite the subscription to topic Job with Allocation. This means that the first subscription can be removed.
I understand the reason for this is that the jobs view now requires information when allocations change. I think the easiest way to fix this would be to allow a subscriber to subscribe to multiple topics at a time. So the the Subscribe method should take an slice of Topics rather then a single topic:

v.Watcher.Subscribe([]api.Topic{api.Topic.Job, api.TopicAllocation}, update)

Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hcjulz Sorry a little busy on other works. Just looking at the comments now. 😄

This make sense for views. To update jobs view, we need to subscribe to the changes for both Jobs and Allocations.

w.updateAllocations()
{
w.updateAllocations()
w.updateJobs() // * Need this update, since we show allocation count in job view.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Related to my previous comment, I think if a subscriber can subscribe to multiple topics we can undo this?

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 am not sure about this one. This is happening in watcher. Updating the state of jobs and allocations happening directly in watcher. It is based on the messages coming from the event channel. If the event channel gives AllocationTopic, we should also update the Job's state. Sending multiple topics to subscribe method cannot solve this.

Your thoughts !!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hey @jawahars16, I'm not sure either right now. My thought was: If we change that a view can subscribe to multiple topics the watcher code will have to change to always notify all subscribed topics. I'll have a closer look into this this weekend.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jawahars16 I was able to confirm my theory. When a view can subscribe to multiple topics and it gets notified whenever one of these topics generates an event the view gets updated. I also tried it on top of your PR.

I did the code change to allow multiple subscriptions: #24

If you pull in the changes to your PR here, you only have to subscribe in view/jobs.go in the Jobs() func additionally to the Allocations topic. The Subscribe method slightly changed, the update func comes first:

watcher.Subscribe(notify func(), topics ...api.Topic)

Give it a try. I hope it helps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure @hcjulz I will give it a try. Thanks.

@hashicorp-cla
Copy link

hashicorp-cla commented Mar 12, 2022

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


Jawahar seems not to be a GitHub user.
You need a GitHub account to be able to sign the CLA. If you already have a GitHub account, please add the email address used for this commit to your account.

Have you signed the CLA already but the status is still pending? Recheck it.

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