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

Add hostname's to stolonctl output #848

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

Conversation

deepdivenow
Copy link

Add stolon components hostnames to stolonctl output.
`# stolonctl status
=== Active sentinels ===

ID LEADER HOSTNAME
06d77408 false centos19
0a2ab67c false centos18
58b4fab7 true centos17

=== Active proxies ===

ID HOSTNAME
4332e2ae centos18
71a18a24 centos17
b157e411 centos19
b5b6326f centos17
c38c5d6e centos18
e0d908fc centos19

=== Keepers ===

UID HEALTHY PG LISTENADDRESS PG HEALTHY PG WANTEDGENERATION PG CURRENTGENERATION
pgcentos17 true 10.10.1.117:5432 true 3 3
pgcentos18 true 10.10.1.118:5432 true 2 2
pgcentos19 true 10.10.1.119:5432 true 2 2

=== Cluster Info ===

Master Keeper: pgcentos17
`

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.

@deepdivenow Thanks for the PR.

  • I don't see the keeper hostname reported in the keepers list (the keeper uid could be something else than the keeper hostname).
  • Just a minor inline comment.

internal/common/common.go Outdated Show resolved Hide resolved
internal/common/common.go Outdated Show resolved Hide resolved
@@ -51,6 +51,7 @@ type Status struct {
Proxies []ProxyStatus `json:"proxies"`
Keepers []KeeperStatus `json:"keepers"`
Cluster ClusterStatus `json:"cluster"`
DBs cluster.DBs `json:"-"`
Copy link
Author

Choose a reason for hiding this comment

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

Added for use only once getClusterData(e)
PS: sometimes second getClusterData fail with error 'context deadline exceeded'

internal/common/common.go Outdated Show resolved Hide resolved
@sgotti
Copy link
Member

sgotti commented Oct 7, 2021

@deepdivenow Looks like your code isn't correctly formatted (use you editor plugin for go or just gofmt).

# gofmt -d .

diff -u cmd/stolonctl/cmd/status.go.orig cmd/stolonctl/cmd/status.go
--- cmd/stolonctl/cmd/status.go.orig    2021-10-07 09:21:37.924036875 +0200
+++ cmd/stolonctl/cmd/status.go 2021-10-07 09:21:37.924036875 +0200
@@ -154,7 +154,7 @@
        } else {
                fmt.Fprintf(tabOut, "UID\tHEALTHY\tPG LISTENADDRESS\tPG HEALTHY\tPG WANTEDGENERATION\tPG CURRENTGENERATION\tHOSTNAME\n")
                for _, k := range status.Keepers {
-                       fmt.Fprintf(tabOut, "%s\t%t\t%s\t%t\t%d\t%d\t%s\n", k.UID, k.Healthy, k.ListenAddress, k.PgHealthy, k.PgWantedGeneration, k.PgCurrentGeneration,k.Hostname)
+                       fmt.Fprintf(tabOut, "%s\t%t\t%s\t%t\t%d\t%d\t%s\n", k.UID, k.Healthy, k.ListenAddress, k.PgHealthy, k.PgWantedGeneration, k.PgCurrentGeneration, k.Hostname)
                        tabOut.Flush()
                }
        }
@@ -303,9 +303,9 @@
                                dbListenAddress = fmt.Sprintf("%s:%s", db.Status.ListenAddress, db.Status.Port)
                        }
                }
-               hostName:=""
-               if ki,ok := keeInfo[kuid]; ok && ki != nil {
-                       hostName=ki.Hostname
+               hostName := ""
+               if ki, ok := keeInfo[kuid]; ok && ki != nil {
+                       hostName = ki.Hostname
                }
                keeper := KeeperStatus{
                        UID:                 kuid,
diff -u internal/common/common.go.orig internal/common/common.go
--- internal/common/common.go.orig      2021-10-07 09:21:37.937370408 +0200
+++ internal/common/common.go   2021-10-07 09:21:37.937370408 +0200
@@ -48,7 +48,7 @@
        RoleStandby,
 }
 
-func init(){
+func init() {
        setHostname()
 }

@deepdivenow
Copy link
Author

Reformated

@sgotti
Copy link
Member

sgotti commented Oct 12, 2021

@deepdivenow Just noticed that, with this implementation, if a keeper is down, its hostname won't be shown. Since keepers are persistent and recorded in the cluster data while sentinel and proxies are ephemeral they'll be always shown also if down but the hostname is available only in the keeperinfo that will disappear after the store key ttl timeout.

Is this ok for you? If you always want to show the keeper hostname (or the last known hostname) it should be recorded in the cluster data keeper status.

@deepdivenow
Copy link
Author

@sgotti I want firstly see names for proxy&sentinels. (i always know where my keepers)
I create this AS IS because sentinel change info about keepers only if is new keeper.
I try add this info in CD but hostname shown only for new keepers, for backward compatibility previous version of stolon, i create AS IS.

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.

2 participants