Skip to content

Commit 54257b4

Browse files
aiharosmjuraga
authored andcommitted
MINOR: add more app logging
1 parent adb9315 commit 54257b4

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

configuration/cluster_sync.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,12 @@ func (c *ClusterSync) monitorBootstrapKey() {
198198
for {
199199
select {
200200
case <-c.cfg.Notify.BootstrapKeyChanged.Subscribe("monitorBootstrapKey"):
201+
log.Warningf("detected change in configured bootstrap key")
201202
key := c.cfg.Cluster.BootstrapKey.Load()
202203
c.cfg.Cluster.CertificateFetched.Store(false)
203204
if key == "" {
204205
// do we need to delete cert here maybe?
206+
log.Warningf("setting bootstrap key to empty")
205207
c.cfg.Cluster.ActiveBootstrapKey.Store("")
206208
err := c.cfg.Save()
207209
if err != nil {
@@ -270,12 +272,14 @@ func (c *ClusterSync) monitorBootstrapKey() {
270272
if method, ok := data["register-method"]; ok {
271273
registerMerhod = method
272274
}
275+
log.Warningf("issuing cluster join request to cluster %s at %s", data["name"], data["address"])
273276
err = c.issueJoinRequest(url, data["port"], data["api-base-path"], c.cfg.Cluster.APIRegisterPath.Load(), registerMerhod, csr, key)
274277
if err != nil {
275278
log.Warning(err)
276279
break
277280
}
278281
if !c.cfg.Cluster.CertificateFetched.Load() {
282+
log.Warningf("starting certificate fetch")
279283
c.certFetch <- struct{}{}
280284
}
281285
case <-c.Context.Done():
@@ -377,7 +381,9 @@ func (c *ClusterSync) issueJoinRequest(url, port, basePath string, registerPath
377381
return err
378382
}
379383
if resp.StatusCode != expectedResponseCodes[registerMethod] {
380-
return fmt.Errorf("status code not proper [%d] %s", resp.StatusCode, string(body))
384+
return fmt.Errorf("invalid status code [%d] %s", resp.StatusCode, string(body))
385+
} else {
386+
log.Warningf("success sending local info, joining in progress")
381387
}
382388
var responseData Node
383389
err = json.Unmarshal(body, &responseData)
@@ -444,7 +450,7 @@ func (c *ClusterSync) issueJoinRequest(url, port, basePath string, registerPath
444450
c.cfg.Cluster.Name.Store(responseData.Name)
445451
c.cfg.Cluster.Token.Store(resp.Header.Get("X-Node-Key"))
446452
c.cfg.Cluster.ActiveBootstrapKey.Store(c.cfg.Cluster.BootstrapKey.Load())
447-
log.Info("Cluster joined")
453+
log.Warning("cluster joined")
448454
_, err = c.checkCertificate(responseData)
449455
if err != nil {
450456
return err
@@ -550,6 +556,7 @@ func (c *ClusterSync) fetchCert() {
550556
if !certFetched {
551557
time.AfterFunc(time.Minute, func() {
552558
if !c.cfg.Cluster.CertificateFetched.Load() {
559+
log.Warningf("retrying certificate fetch")
553560
c.certFetch <- struct{}{}
554561
}
555562
})

handlers/cluster.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package handlers
1717

1818
import (
1919
"fmt"
20+
log "github.com/sirupsen/logrus"
2021

2122
"github.com/go-openapi/runtime/middleware"
2223
"github.com/google/renameio"
@@ -101,8 +102,10 @@ func (h *CreateClusterHandlerImpl) Handle(params cluster.PostClusterParams, prin
101102
if err != nil {
102103
return h.err406(err, nil)
103104
}
105+
log.Warningf("received instructions from %s to join cluster %s at %s", params.HTTPRequest.RemoteAddr, key["name"], key["address"])
104106
errStorageDir := configuration.CheckIfStorageDirIsOK(key["storage-dir"], h.Config)
105107
if errStorageDir != nil {
108+
log.Warningf("configured storage dir incompatible with cluster configuration: %s", errStorageDir)
106109
return h.err409(errStorageDir, nil)
107110
}
108111

@@ -123,7 +126,9 @@ func (h *CreateClusterHandlerImpl) Handle(params cluster.PostClusterParams, prin
123126
}
124127
if params.Data.Mode == "single" && h.Config.Mode.Load() != params.Data.Mode {
125128
// by default we are cleaning configuration
129+
log.Warningf("received instructions from %s to switch to standalone mode", params.HTTPRequest.RemoteAddr)
126130
if params.Configuration == nil || *params.Configuration != "keep" {
131+
log.Warning("clearing configuration as requested")
127132
version, errVersion := h.Client.Configuration.GetVersion("")
128133
if errVersion != nil || version < 1 {
129134
// silently fallback to 1
@@ -216,6 +221,7 @@ func (h *CreateClusterHandlerImpl) Handle(params cluster.PostClusterParams, prin
216221
h.Config.Status.Store("active")
217222
h.Config.Cluster.Clear()
218223
defer func() {
224+
log.Warning("reloading to apply configuration changes")
219225
h.Config.Notify.Reload.Notify()
220226
}()
221227
}

0 commit comments

Comments
 (0)