-
Notifications
You must be signed in to change notification settings - Fork 25
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
[VC-36032] Pass the context to Venafi clients and enable debug roundtripper #627
Changes from all commits
68bbb8f
79aa13f
02aa2f9
6ad7079
45fb767
fcca2f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -146,7 +146,16 @@ affinity: {} | |||||||
command: [] | ||||||||
|
||||||||
# Specify additional arguments to pass to the agent binary. | ||||||||
# Example: `["--strict", "--oneshot"]` | ||||||||
# For example, to enable JSON logging use `--logging-format`, or | ||||||||
# to increase the logging verbosity use `--log-level`. | ||||||||
# The log levels are: 0=Info, 1=Debug, 2=Trace. | ||||||||
# Use 6-9 for increasingly verbose HTTP request logging. | ||||||||
# The default log level is 0. | ||||||||
# | ||||||||
# Example: | ||||||||
# extraArgs: | ||||||||
# - --logging-format=json | ||||||||
# - --log-level=6 # To enable HTTP request logging | ||||||||
extraArgs: [] | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Matches what is now used in the E2E test: jetstack-secure/hack/e2e/values.venafi-kubernetes-agent.yaml Lines 11 to 13 in fcca2f1
|
||||||||
|
||||||||
# Additional volumes to add to the Venafi Kubernetes Agent container. This is | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ authentication: | |
|
||
extraArgs: | ||
- --logging-format=json | ||
- --log-level=2 | ||
- --log-level=6 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import ( | |
"github.com/spf13/cobra" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"k8s.io/klog/v2" | ||
"k8s.io/klog/v2/ktesting" | ||
|
||
"github.com/jetstack/preflight/pkg/client" | ||
|
@@ -620,6 +621,12 @@ func Test_ValidateAndCombineConfig(t *testing.T) { | |
func Test_ValidateAndCombineConfig_VenafiCloudKeyPair(t *testing.T) { | ||
t.Run("server, uploader_id, and cluster name are correctly passed", func(t *testing.T) { | ||
t.Setenv("POD_NAMESPACE", "venafi") | ||
|
||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
log := ktesting.NewLogger(t, ktesting.NewConfig(ktesting.Verbosity(10))) | ||
ctx = klog.NewContext(ctx, log) | ||
|
||
srv, cert, setVenafiCloudAssert := testutil.FakeVenafiCloud(t) | ||
setVenafiCloudAssert(func(t testing.TB, gotReq *http.Request) { | ||
// Only care about /v1/tlspk/upload/clusterdata/:uploader_id?name= | ||
|
@@ -648,7 +655,7 @@ func Test_ValidateAndCombineConfig_VenafiCloudKeyPair(t *testing.T) { | |
testutil.TrustCA(t, cl, cert) | ||
assert.Equal(t, VenafiCloudKeypair, got.AuthMode) | ||
|
||
err = cl.PostDataReadingsWithOptions(nil, client.Options{ClusterName: "test cluster name"}) | ||
err = cl.PostDataReadingsWithOptions(ctx, nil, client.Options{ClusterName: "test cluster name"}) | ||
require.NoError(t, err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing gets logged by the client in this test
|
||
}) | ||
} | ||
|
@@ -724,6 +731,11 @@ func Test_ValidateAndCombineConfig_VenafiConnection(t *testing.T) { | |
}) | ||
|
||
t.Run("the server field is ignored when VenafiConnection is used", func(t *testing.T) { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
log := ktesting.NewLogger(t, ktesting.NewConfig(ktesting.Verbosity(10))) | ||
ctx = klog.NewContext(ctx, log) | ||
|
||
expected := srv.URL | ||
setVenafiCloudAssert(func(t testing.TB, gotReq *http.Request) { | ||
assert.Equal(t, expected, "https://"+gotReq.Host) | ||
|
@@ -738,13 +750,13 @@ func Test_ValidateAndCombineConfig_VenafiConnection(t *testing.T) { | |
withCmdLineFlags("--venafi-connection", "venafi-components", "--install-namespace", "venafi")) | ||
require.NoError(t, err) | ||
|
||
testutil.VenConnStartWatching(t, cl) | ||
testutil.VenConnStartWatching(ctx, t, cl) | ||
testutil.TrustCA(t, cl, cert) | ||
|
||
// TODO(mael): the client should keep track of the cluster ID, we | ||
// shouldn't need to pass it as an option to | ||
// PostDataReadingsWithOptions. | ||
err = cl.PostDataReadingsWithOptions(nil, client.Options{ClusterName: cfg.ClusterID}) | ||
err = cl.PostDataReadingsWithOptions(ctx, nil, client.Options{ClusterName: cfg.ClusterID}) | ||
require.NoError(t, err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/jetstack/jetstack-secure/blob/VC-36032/context-to-client/deploy/charts/venafi-kubernetes-agent/README.md#extraargs--array