Skip to content
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

hcp.v2.TelemetryState resource and controller implementation #20257

Merged
merged 8 commits into from
Jan 31, 2024
Prev Previous commit
Next Next commit
pbhcp: update proto documentation
  • Loading branch information
nickethier committed Jan 30, 2024
commit fafb900b72a4d40ece74c1f9c68afd9f101321b0
4 changes: 0 additions & 4 deletions agent/hcp/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ type mockTGW struct {
mockError error
}

func (m *mockTGW) GetServiceTopology(params *hcptelemetry.GetServiceTopologyParams, authInfo runtime.ClientAuthInfoWriter, opts ...hcptelemetry.ClientOption) (*hcptelemetry.GetServiceTopologyOK, error) {
return hcptelemetry.NewGetServiceTopologyOK(), nil
}

func (m *mockTGW) AgentTelemetryConfig(params *hcptelemetry.AgentTelemetryConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...hcptelemetry.ClientOption) (*hcptelemetry.AgentTelemetryConfigOK, error) {
return m.mockResponse, m.mockError
}
Expand Down
2 changes: 0 additions & 2 deletions agent/hcp/client/telemetry_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ var (
// TelemetryConfig contains configuration for telemetry data forwarded by Consul servers
// to the HCP Telemetry gateway.
type TelemetryConfig struct {
Endpoint string
MetricsConfig *MetricsConfig
RefreshConfig *RefreshConfig
}
Expand Down Expand Up @@ -91,7 +90,6 @@ func convertAgentTelemetryResponse(ctx context.Context, resp *hcptelemetry.Agent
metricLabels := convertMetricLabels(telemetryConfig.Labels, cfg)

return &TelemetryConfig{
Endpoint: telemetryConfig.Endpoint,
MetricsConfig: &MetricsConfig{
Endpoint: metricsEndpoint,
Labels: metricLabels,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

package telemetrystate

import (
Expand Down Expand Up @@ -45,10 +48,6 @@ func (r *telemetryStateReconciler) Reconcile(ctx context.Context, rt controller.

rt.Logger.Trace("reconciling telemetry-state")

if resource.EqualID(req.ID, globalID) {

}

// First get the link resource in order to build a hcp client. If the link resource
// doesn't exist then the telemetry-state should not exist either.
res, err := getLinkResource(ctx, rt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

package telemetrystate

import (
Expand Down
3 changes: 3 additions & 0 deletions internal/hcp/internal/controllers/telemetrystate/status.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

package telemetrystate

const (
Expand Down
7 changes: 3 additions & 4 deletions internal/hcp/internal/types/telemetry_state.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

package types

import (
Expand Down Expand Up @@ -57,9 +60,5 @@ func validateTelemetryState(res *DecodedTelemetryState) error {
})
}

if res.Data.HcpConfig != nil {
err = multierror.Append(err, validateHCPConfig(res.Data.HcpConfig))
}

return err
}
15 changes: 10 additions & 5 deletions proto-public/pbhcp/v2/hcp_config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion proto-public/pbhcp/v2/hcp_config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ syntax = "proto3";
package hashicorp.consul.hcp.v2;

// HCPConfig is used to configure the HCP SDK for communicating with
// the HashiCorp Cloud Platform
// the HashiCorp Cloud Platform. All configuration is optional with default
// values provided by the SDK.
message HCPConfig {
// AuthUrl is the URL which will be used to authenticate.
string auth_url = 1;

// ApiAddress is the address (<hostname>[:port]) of the HCP api.
string api_address = 2;

// ScadaAddress is the address (<hostname>[:port]) of the HCP SCADA endpoint.
string scada_address = 3;

// TlsInsecureSkipVerify if true will ignore server name verification when making HTTPS requests
bool tls_insecure_skip_verify = 4;
}
10 changes: 5 additions & 5 deletions proto-public/pbhcp/v2/link.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion proto-public/pbhcp/v2/link.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ syntax = "proto3";

package hashicorp.consul.hcp.v2;

import "pbresource/annotations.proto";
import "pbhcp/v2/hcp_config.proto";
import "pbresource/annotations.proto";

enum AccessLevel {
ACCESS_LEVEL_UNSPECIFIED = 0;
Expand Down
43 changes: 30 additions & 13 deletions proto-public/pbhcp/v2/telemetry_state.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 27 additions & 2 deletions proto-public/pbhcp/v2/telemetry_state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,54 @@ syntax = "proto3";

package hashicorp.consul.hcp.v2;

import "pbresource/annotations.proto";
import "pbhcp/v2/hcp_config.proto";
import "pbresource/annotations.proto";

// TelemetryState describes configuration required to forward telemetry to the HashiCorp Cloud Platform.
// This resource is managed internally and is only written if the cluster is linked to HCP. Any
// manual changes to the resource will be reconciled and overwritten with the internally computed
// state.
message TelemetryState {
option (hashicorp.consul.resource.spec) = {scope: SCOPE_CLUSTER};

// ResourceId is the identifier for the cluster linked with HCP.
string resource_id = 1;

// ClientId is the oauth client identifier for cluster.
// This client has capabilities limited to writing telemetry data for this cluster.
string client_id = 2;

// ClientSecret is the oauth secret used to authenticate requests to send telemetry data to HCP.
string client_secret = 3;

HCPConfig hcp_config = 4;
ProxyConfig proxy = 5;
MetricsConfig metrics = 6;
}

// MetricsConfig configures metric specific collection details
message MetricsConfig {
// Endpoint is the HTTPS address and path to forward metrics to
string endpoint = 1;

// IncludeList contains patterns to match against metric names. Only matched metrics are forwarded.
repeated string include_list = 2;
map<string,string> labels = 3;

// Labels contains key value pairs that are associated with all metrics collected and fowarded.
map<string, string> labels = 3;

// Disabled toggles metric forwarding. If true, metric forwarding will stop until disabled is set to false.
bool disabled = 4;
}

// ProxyConfig describes configuration for forwarding requests through an http proxy
message ProxyConfig {
// HttpProxy configures the http proxy to use for HTTP (non-TLS) requests.
string http_proxy = 1;

// HttpsProxy configures the http proxy to use for HTTPS (TLS) requests.
string https_proxy = 2;

// NoProxy can be configured to include domains which should NOT be forwarded through the configured http proxy
repeated string no_proxy = 3;
}