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
9 changes: 9 additions & 0 deletions pkg/client/client_api_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"k8s.io/client-go/transport"
"k8s.io/klog/v2"

"github.com/jetstack/preflight/api"
"github.com/jetstack/preflight/pkg/version"
Expand Down Expand Up @@ -64,6 +65,14 @@ func (c *APITokenClient) postDataReadings(ctx context.Context, orgID, clusterID
return err
}

klog.FromContext(ctx).V(2).Info(
"uploading data readings",
"url", filepath.Join("/api/v1/org", orgID, "datareadings", clusterID),
"cluster_id", clusterID,
"data_readings_count", len(readings),
"data_size_bytes", len(data),
)

res, err := c.post(ctx, filepath.Join("/api/v1/org", orgID, "datareadings", clusterID), bytes.NewBuffer(data))
if err != nil {
return err
Expand Down
9 changes: 9 additions & 0 deletions pkg/client/client_oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/hashicorp/go-multierror"
"k8s.io/client-go/transport"
"k8s.io/klog/v2"

"github.com/jetstack/preflight/api"
"github.com/jetstack/preflight/pkg/version"
Expand Down Expand Up @@ -119,6 +120,14 @@ func (c *OAuthClient) postDataReadings(ctx context.Context, orgID, clusterID str
return err
}

klog.FromContext(ctx).V(2).Info(
"uploading data readings",
"url", filepath.Join("/api/v1/org", orgID, "datareadings", clusterID),
"cluster_id", clusterID,
"data_readings_count", len(readings),
"data_size_bytes", len(data),
)

res, err := c.post(ctx, filepath.Join("/api/v1/org", orgID, "datareadings", clusterID), bytes.NewBuffer(data))
if err != nil {
return err
Expand Down
9 changes: 9 additions & 0 deletions pkg/client/client_venafi_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/hashicorp/go-multierror"
"github.com/microcosm-cc/bluemonday"
"k8s.io/client-go/transport"
"k8s.io/klog/v2"

"github.com/jetstack/preflight/api"
"github.com/jetstack/preflight/pkg/version"
Expand Down Expand Up @@ -205,6 +206,14 @@ func (c *VenafiCloudClient) PostDataReadingsWithOptions(ctx context.Context, rea
}
venafiCloudUploadURL.RawQuery = query.Encode()

klog.FromContext(ctx).V(2).Info(
"uploading data readings",
"url", venafiCloudUploadURL.String(),
"cluster_name", opts.ClusterName,
"data_readings_count", len(readings),
"data_size_bytes", len(data),
)

res, err := c.post(ctx, venafiCloudUploadURL.String(), bytes.NewBuffer(data))
if err != nil {
return err
Expand Down
16 changes: 11 additions & 5 deletions pkg/client/client_venconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/rest"
"k8s.io/client-go/transport"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"

"github.com/jetstack/preflight/api"
Expand Down Expand Up @@ -154,18 +155,23 @@ func (c *VenConnClient) PostDataReadingsWithOptions(ctx context.Context, reading
DataGatherTime: time.Now().UTC(),
DataReadings: readings,
}

encodedBody := &bytes.Buffer{}

err = json.NewEncoder(encodedBody).Encode(payload)
data, err := json.Marshal(payload)
if err != nil {
return err
}

klog.FromContext(ctx).V(2).Info(
"uploading data readings",
"url", fullURL(details.VCP.URL, "/v1/tlspk/upload/clusterdata/no"),
"cluster_name", opts.ClusterName,
"data_readings_count", len(readings),
"data_size_bytes", len(data),
)
Copy link
Member

Choose a reason for hiding this comment

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

I observed this log message by running the E2E test locally:

$ make test-e2e-gke
...
{
  "ts": 1763137282342.5798,
  "caller": "vcp_oauth/vcp_oauth.go:64",
  "msg": "acquired OAuth token from Certificate Manager SaaS API",
  "v": 0,
  "logger": "Run.gatherAndOutputData.postData",
  "scope": "",
  "token_type": "bearer",
  "valid_until": 1763137282342.5864
}
{
  "ts": 1763137282390.8809,
  "caller": "client/client_venconn.go:163",
  "msg": "uploading data readings",
  "v": 2,
  "logger": "Run.gatherAndOutputData.postData",
  "url": "https://api.venafi.cloud/v1/tlspk/upload/clusterdata/no",
  "cluster_name": "venafi-kubernetes-agent-e2e",
  "data_readings_count": 36,
  "data_size_bytes": 749416
}
{"ts":1763137282973.3423,"caller":"agent/run.go:420","msg":"Data sent successfully","v":0,"logger":"Run.gatherAndOutputData.postData"}
...


// The path parameter "no" is a dummy parameter to make the Venafi Cloud
// backend happy. This parameter, named `uploaderID` in the backend, is not
// actually used by the backend.
req, err := http.NewRequestWithContext(ctx, http.MethodPost, fullURL(details.VCP.URL, "/v1/tlspk/upload/clusterdata/no"), encodedBody)
req, err := http.NewRequestWithContext(ctx, http.MethodPost, fullURL(details.VCP.URL, "/v1/tlspk/upload/clusterdata/no"), bytes.NewReader(data))
if err != nil {
return err
}
Expand Down