Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hack/e2e/values.venafi-kubernetes-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ authentication:

extraArgs:
- --logging-format=json
- --log-level=2
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I changed this so that could see trace level logs in the e2e test.
As it happens, the single controller-runtime log message from venafi-connection-lib is at level 0, so this change is not strictly necessary.

7 changes: 0 additions & 7 deletions pkg/client/client_venconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"net/http"
"time"

"github.com/go-logr/logr"
venapi "github.com/jetstack/venafi-connection-lib/api/v1alpha1"
"github.com/jetstack/venafi-connection-lib/venafi_client"
"github.com/jetstack/venafi-connection-lib/venafi_client/auth"
Expand All @@ -22,7 +21,6 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
ctrlruntimelog "sigs.k8s.io/controller-runtime/pkg/log"

"github.com/jetstack/preflight/api"
"github.com/jetstack/preflight/pkg/version"
Expand Down Expand Up @@ -57,11 +55,6 @@ type VenConnClient struct {
// `restcfg` is not mutated. `trustedCAs` is only used for connecting to Venafi
// Cloud and Vault and can be left nil.
func NewVenConnClient(restcfg *rest.Config, agentMetadata *api.AgentMetadata, installNS, venConnName, venConnNS string, trustedCAs *x509.CertPool, disableCompression bool) (*VenConnClient, error) {
// TODO(mael): The rest of the codebase uses the standard "log" package,
// venafi-connection-lib uses "go-logr/logr", and client-go uses "klog". We
// should standardize on one of them, probably "slog".
ctrlruntimelog.SetLogger(logr.Logger{})
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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


if installNS == "" {
return nil, errors.New("programmer mistake: installNS must be provided")
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"k8s.io/component-base/logs"
logsapi "k8s.io/component-base/logs/api/v1"
_ "k8s.io/component-base/logs/json/register"
"k8s.io/klog/v2"
ctrlruntimelog "sigs.k8s.io/controller-runtime/pkg/log"
)

// venafi-kubernetes-agent follows [Kubernetes Logging Conventions] and writes
Expand Down Expand Up @@ -131,6 +133,11 @@ func Initialize() error {
// to the global log logger. It can be removed when this is fixed upstream
// in vcert: https://github.com/Venafi/vcert/pull/512
vcertLog.SetPrefix("")

// The venafi-connection-lib client uses various controller-runtime packages
// which emit log messages. Make sure those log messages are not discarded.
ctrlruntimelog.SetLogger(klog.Background().WithValues("source", "controller-runtime"))

return nil
}

Expand Down