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 keeper sync type in status #636

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dyson
Copy link

@dyson dyson commented Apr 26, 2019

Adds the type of sync a keeper is to the stolonctl status output which can be really useful.

Currently we are doing this through passing the cluster data through jq which isn't ideal.

@dyson dyson force-pushed the dyson-status-show-keeper-sync-type branch from e23fbe2 to 959fb1c Compare April 26, 2019 14:11
@sgotti
Copy link
Member

sgotti commented May 8, 2019

@dyson Thanks for the PR!

In #628 was also added support for json output. To support both your changes should be firstly added to the struct here: https://github.com/sorintlab/stolon/pull/628/files#diff-ca7581917eb32f79f0111a1e9f3217e9R66
so it could be used by both the json and text outputs.

/cc @hmac

@dyson dyson force-pushed the dyson-status-show-keeper-sync-type branch 2 times, most recently from 1d0194c to 3762f25 Compare May 13, 2019 07:39
@dyson
Copy link
Author

dyson commented May 13, 2019

Thanks @sgotti for looking at this! I've updated the PR to also support adding the role to the JSON formatted output.

@dyson dyson force-pushed the dyson-status-show-keeper-sync-type branch from 3762f25 to 4a8f33c Compare May 15, 2019 13:52
@dyson dyson force-pushed the dyson-status-show-keeper-sync-type branch from b55f52a to ba55e97 Compare May 15, 2019 16:32
Copy link
Member

@sgotti sgotti left a comment

Choose a reason for hiding this comment

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

@dyson Sorry for the delay. I had time to try it and discovered a panic when, after a new cluster init there're no dbs.

I added some comments inline.

keepers := make([]KeeperStatus, 0)
kssKeys := cd.Keepers.SortedKeys()
keeperRoles := getKeeperRoles(status.Cluster.MasterDBUID, cd)
Copy link
Member

Choose a reason for hiding this comment

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

status.Cluster.MasterDBUID could be empty making getKeeperRoles panicking when doing db := cd.DBs[dbuid]

keeperRoles[dbuid] = "async"
}
db := cd.DBs[dbuid]
followers := db.Spec.Followers
Copy link
Member

Choose a reason for hiding this comment

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

Instead of making a recursive function can you just iterate over all dbs and use their followConfig to detect the parent?

keeperRoles[dbuid] = "external sync"
} else {
keeperRoles[dbuid] = "async"
}
Copy link
Member

Choose a reason for hiding this comment

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

There can be also a case where a keeper is not set to be a standby (when exceeding MaxStandbys) si it should be noted as "none"

for _, kuid := range kssKeys {
k := cd.Keepers[kuid]
db := cd.FindDB(k)
dbListenAddress := "(no db assigned)"
role := ""
Copy link
Member

Choose a reason for hiding this comment

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

Better to set it to something like none instead of an empty value

Copy link
Contributor

@mos3abof mos3abof Jun 5, 2019

Choose a reason for hiding this comment

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

@sgotti, would setting the none value to no role assigned be acceptable? The reason of proposing this is that I found it a bit confusing displaying (none) next to the keeper. This is how it looks like in both cases:

With none:

...
===== Keepers/DB tree =====

keeper0 (master)
  keeper1 (sync)
  keeper2 (none)

With no role assigned:

...
===== Keepers/DB tree =====

keeper0 (master)
  keeper1 (sync)
  keeper2 (no role assigned)

Which do you think works better?

@dyson
Copy link
Author

dyson commented Jun 5, 2019

@sgotti no problem at all!

Thanks for the review. We'll work through these and get it in shape. Cheers!

This commit fixes a couple of panicking bugs when empty or nil variables
are accessed without protection in some corner cases, like having an
empty `status.Cluster.MasterDBUID`, or having an empty `dbuid` passed to
the `getKeeperRoles()` function.

It also displayes more readable information in case a node has no role
in the cluster yet instead of displaying an empty string. This takes
into consideration whether information is being displayed in the default
format, or in the JSON format.
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.

3 participants