feature (worker): add worker events around authentication (#2157)

This commit is contained in:
Jim authored and GitHub committed 2022-06-09 11:28:12 -04:00
1 parent d357a583ed
commit f6c4e3c896
4 files changed
+16 -3

No files matched your search

+1 -1
View File
@@ -92,7 +92,7 @@ require github.com/hashicorp/go-dbw v0.0.0-20220412153211-c470aec9369f // this i
require (
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/hashicorp/go-kms-wrapping/extras/kms/v2 v2.0.0-20220515130442-cac0b5ac133b
github.com/hashicorp/nodeenrollment v0.0.0-20220607152131-4f253e6da747
github.com/hashicorp/nodeenrollment v0.0.0-20220609044242-598c08a89c45
)
require (
+2 -2
View File
@@ -740,8 +740,8 @@ github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+l
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/nodeenrollment v0.0.0-20220607152131-4f253e6da747 h1:/S1ePrvxgLI3jgL6XLVVQAOm3Ua0wS4PvRhmiTgG6hQ=
github.com/hashicorp/nodeenrollment v0.0.0-20220607152131-4f253e6da747/go.mod h1:8l3RSuZJAibZKnqX6tvLaeoFzPhDf4oCRVsyFjU5Soc=
github.com/hashicorp/nodeenrollment v0.0.0-20220609044242-598c08a89c45 h1:vnRJfKOMBoan6+PFw5P5CItnl3Z6lJJI1JaBM1tlLCo=
github.com/hashicorp/nodeenrollment v0.0.0-20220609044242-598c08a89c45/go.mod h1:8l3RSuZJAibZKnqX6tvLaeoFzPhDf4oCRVsyFjU5Soc=
github.com/hashicorp/vault/api v1.3.1 h1:pkDkcgTh47PRjY1NEFeofqR4W/HkNUi9qIakESO2aRM=
github.com/hashicorp/vault/api v1.3.1/go.mod h1:QeJoWxMFt+MsuWcYhmwRLwKEXrjwAFFywzhptMsTIUw=
github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M=
@@ -71,6 +71,7 @@ func (w *Worker) StartControllerConnections() error {
}
func (w *Worker) controllerDialerFunc() func(context.Context, string) (net.Conn, error) {
const op = "worker.(Worker).controllerDialerFunc"
return func(ctx context.Context, addr string) (net.Conn, error) {
var conn net.Conn
var err error
@@ -89,9 +90,20 @@ func (w *Worker) controllerDialerFunc() func(context.Context, string) (net.Conn,
}
}
}
switch err {
case nil:
case nodeenrollment.ErrNotAuthorized:
// We don't event in this case, because the function retries often
// and will spam the logs. The status function will event indicating
// that it can't send status because it's not authorized, so that
// will be a fine hint to the user as to the issue.
default:
event.WriteError(ctx, op, err)
}
if !w.everAuthenticated.Load() && err == nil && conn != nil {
w.everAuthenticated.Store(true)
event.WriteSysEvent(ctx, op, "worker has successfully authenticated")
}
return conn, err
+1
View File
@@ -95,6 +95,7 @@ func (w *Worker) sendWorkerStatus(cancelCtx context.Context) {
// any session information anyways and this will produce a ton of noise in
// observability, so suppress it
if !w.everAuthenticated.Load() {
event.WriteSysEvent(cancelCtx, op, "worker is not authenticated to an upstream, not sending status")
return
}