1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

[Logging] Internal client trace (#1077)

This commit is contained in:
Adam Janikowski 2022-08-03 12:33:13 +02:00 committed by GitHub
parent 00efa27e08
commit 78e29b0d17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 119 additions and 14 deletions

View file

@ -12,6 +12,7 @@
- (Documentation) Add docs on setting timezone for containers
- (Bugfix) Ensure that client cache is initialized before using it
- (Feature) (DBServer Maintenance) Agency adjustments
- (Logging) Internal client trace
## [1.2.15](https://github.com/arangodb/kube-arangodb/tree/1.2.15) (2022-07-20)
- (Bugfix) Ensure pod names not too long

View file

@ -26,9 +26,15 @@ import (
"time"
"github.com/arangodb/go-driver"
"github.com/arangodb/kube-arangodb/pkg/logging"
)
func NewClient(c driver.Connection) Client {
func NewClient(c driver.Connection, log logging.Logger) Client {
if log != nil {
c = loggerConnection(c, log)
}
return &client{
c: c,
}

View file

@ -0,0 +1,32 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package client
import (
"github.com/arangodb/go-driver"
"github.com/arangodb/go-driver/util/connection/wrappers"
"github.com/arangodb/kube-arangodb/pkg/logging"
)
func loggerConnection(in driver.Connection, logger logging.Logger) driver.Connection {
return wrappers.NewLoggerConnection(in, newClientLogger(logger), true)
}

View file

@ -0,0 +1,65 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package client
import (
"time"
"github.com/arangodb/go-driver/util/connection/wrappers"
"github.com/arangodb/kube-arangodb/pkg/logging"
)
func newClientLogger(log logging.Logger) wrappers.Logger {
return logger{log: log}
}
type logger struct {
log logging.Logger
}
func (l logger) Int(key string, value int) wrappers.Event {
return logger{log: l.log.Int(key, value)}
}
func (l logger) Str(key, value string) wrappers.Event {
return logger{log: l.log.Str(key, value)}
}
func (l logger) Time(key string, value time.Time) wrappers.Event {
return logger{log: l.log.Time(key, value)}
}
func (l logger) Duration(key string, value time.Duration) wrappers.Event {
return logger{log: l.log.Dur(key, value)}
}
func (l logger) Interface(key string, value interface{}) wrappers.Event {
return logger{log: l.log.Interface(key, value)}
}
func (l logger) Msgf(format string, args ...interface{}) {
l.log.Trace(format, args...)
}
func (l logger) Log() wrappers.Event {
return logger{log: l.log}
}

View file

@ -68,7 +68,7 @@ func (a *encryptionKeyRefreshAction) CheckProgress(ctx context.Context) (bool, b
return true, false, nil
}
client := client.NewClient(c.Connection())
client := client.NewClient(c.Connection(), a.log)
ctxChild, cancel = globals.GetGlobalTimeouts().ArangoD().WithTimeout(ctx)
defer cancel()
e, err := client.RefreshEncryption(ctxChild)

View file

@ -64,7 +64,7 @@ func (a *jwtRefreshAction) CheckProgress(ctx context.Context) (bool, bool, error
ctxChild, cancel := globals.GetGlobalTimeouts().ArangoD().WithTimeout(ctx)
defer cancel()
if invalid, err := isMemberJWTTokenInvalid(ctxChild, client.NewClient(c.Connection()), folder.Data, true); err != nil {
if invalid, err := isMemberJWTTokenInvalid(ctxChild, client.NewClient(c.Connection(), a.log), folder.Data, true); err != nil {
a.log.Err(err).Warn("Error while getting JWT Status")
return true, false, nil
} else if invalid {

View file

@ -78,7 +78,7 @@ func (a *licenseSetAction) Start(ctx context.Context) (bool, error) {
return true, nil
}
client := client.NewClient(c.Connection())
client := client.NewClient(c.Connection(), a.log)
if ok, err := licenseV2Compare(ctxChild, client, l.V2); err != nil {
a.log.Err(err).Error("Unable to verify license")

View file

@ -68,7 +68,7 @@ func (a *refreshTLSKeyfileCertificateAction) CheckProgress(ctx context.Context)
keyfileSha := util.SHA256(keyfile)
client := client.NewClient(c.Connection())
client := client.NewClient(c.Connection(), a.log)
ctxChild, cancel := globals.GetGlobalTimeouts().ArangoD().WithTimeout(ctx)
defer cancel()

View file

@ -74,7 +74,7 @@ func (t *tlsSNIUpdate) CheckProgress(ctx context.Context) (bool, bool, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().ArangoD().WithTimeout(ctx)
defer cancel()
if ok, err := compareTLSSNIConfig(ctxChild, c.Connection(), fetchedSecrets, true); err != nil {
if ok, err := compareTLSSNIConfig(ctxChild, t.log, c.Connection(), fetchedSecrets, true); err != nil {
t.log.Err(err).Warn("Unable to compare TLS config")
return true, false, nil
} else {

View file

@ -170,7 +170,7 @@ func (s shutdownHelperAPI) CheckProgress(ctx context.Context) (bool, bool, error
if err != nil {
s.log.Err(err).Warn("Failed to create member client")
} else {
internal := client.NewClient(c.Connection())
internal := client.NewClient(c.Connection(), s.log)
if err := internal.DeleteExpiredJobs(ctx, ActionShutdownJobExpiredTerminationTimeout); err != nil {
s.log.Err(err).Warn("Unable to kill async jobs on member")

View file

@ -29,6 +29,7 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/deployment/client"
"github.com/arangodb/kube-arangodb/pkg/logging"
"github.com/arangodb/kube-arangodb/pkg/util/constants"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
@ -66,8 +67,8 @@ func mapTLSSNIConfig(sni api.TLSSNISpec, cachedStatus inspectorInterface.Inspect
return fetchedSecrets, nil
}
func compareTLSSNIConfig(ctx context.Context, c driver.Connection, m map[string]string, refresh bool) (bool, error) {
tlsClient := client.NewClient(c)
func compareTLSSNIConfig(ctx context.Context, log logging.Logger, c driver.Connection, m map[string]string, refresh bool) (bool, error) {
tlsClient := client.NewClient(c, log)
f := tlsClient.GetTLS
if refresh {

View file

@ -263,7 +263,7 @@ func (r *Reconciler) isEncryptionKeyUpToDate(ctx context.Context, status api.Dep
return false, true
}
client := client.NewClient(c.Connection())
client := client.NewClient(c.Connection(), log)
ctxChild, cancel := globals.GetGlobalTimeouts().ArangoD().WithTimeout(ctx)
defer cancel()

View file

@ -235,7 +235,7 @@ func (r *Reconciler) isJWTTokenUpToDate(ctx context.Context, status api.Deployme
return false, true
}
if updateRequired, err := isMemberJWTTokenInvalid(ctx, client.NewClient(c.Connection()), folder.Data, false); err != nil {
if updateRequired, err := isMemberJWTTokenInvalid(ctx, client.NewClient(c.Connection(), log), folder.Data, false); err != nil {
log.Err(err).Warn("JWT UpToDate Check failed")
return false, true
} else if updateRequired {

View file

@ -75,7 +75,7 @@ func (r *Reconciler) updateClusterLicense(ctx context.Context, apiObject k8sutil
return nil
}
internalClient := client.NewClient(c.Connection())
internalClient := client.NewClient(c.Connection(), r.log)
if ok, err := licenseV2Compare(ctxChild, internalClient, l.V2); err != nil {
r.log.Err(err).Error("Unable to verify license")

View file

@ -555,7 +555,7 @@ func (r *Reconciler) keyfileRenewalRequired(ctx context.Context, apiObject k8sut
return false, false
}
c := client.NewClient(conn.Connection())
c := client.NewClient(conn.Connection(), r.log)
tls, err := c.GetTLS(ctx)
if err != nil {
r.planLogger.Err(err).Warn("Unable to get tls details")

View file

@ -90,7 +90,7 @@ func (r *Reconciler) createRotateTLSServerSNIPlan(ctx context.Context, apiObject
var ok bool
err = globals.GetGlobalTimeouts().ArangoD().RunWithTimeout(ctx, func(ctxChild context.Context) error {
var err error
ok, err = compareTLSSNIConfig(ctxChild, c.Connection(), fetchedSecrets, false)
ok, err = compareTLSSNIConfig(ctxChild, r.log, c.Connection(), fetchedSecrets, false)
return err
})
if err != nil {