operator

package
v0.0.0-...-0d7ecfb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2021 License: Apache-2.0 Imports: 77 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIV1ReportGetEndpoint         = "/api/v1/reports/get"
	APIV2ReportEndpointPrefix      = "/api/v2/reports"
	APIV2ReportQueryEndpointPrefix = "/api/v2/reportqueries"
)
View Source
const (

	// DefaultPrometheusQueryInterval - Query Prometheus every 5 minutes
	DefaultPrometheusQueryInterval = time.Minute * 5
	// DefaultPrometheusQueryStepSize - Query data from Prometheus at a 60 second resolution
	// (one data point per minute max)
	DefaultPrometheusQueryStepSize = time.Minute
	// DefaultPrometheusQueryChunkSize the default value for how much data we will insert into Presto per Prometheus query.
	DefaultPrometheusQueryChunkSize = 5 * time.Minute
	// DefaultPrometheusDataSourceMaxQueryRangeDuration is how much data we will query from Prometheus at once
	DefaultPrometheusDataSourceMaxQueryRangeDuration = 10 * time.Minute
	// DefaultPrometheusDataSourceMaxBackfillImportDuration how far we will query for backlogged data.
	DefaultPrometheusDataSourceMaxBackfillImportDuration = 2 * time.Hour
)
View Source
const (
	// AWSUsageHiveRowFormat is the Hadoop serialization/deserialization implementation used with AWS billing data.
	AWSUsageHiveRowFormat = `` /* 291-byte string literal not displayed */

)

Variables

View Source
var (
	AWSUsageHivePartitions = []hive.Column{
		{Name: billingPeriodStartPartitionColumnName, Type: "string"},
		{Name: billingPeriodEndPartitionColumnName, Type: "string"},
	}
)
View Source
var ErrReportIsRunning = errors.New("the report is still running")

Functions

func AWSColumnToHiveColumnType

func AWSColumnToHiveColumnType(c aws.Column) string

AWSColumnToHiveColumnType is the data type a column is created as in Hive.

func GetReportQueryForReport

func GetReportQueryForReport(report *metering.Report, queryGetter reporting.ReportQueryGetter) (*metering.ReportQuery, error)

GetReportQueryForReport returns the ReportQuery that was used in the Report parameter

func IsValidConfig

func IsValidConfig(cfg *Config) error

IsValidConfig checks the validity of all configuration options.

func IsValidHiveConfig

func IsValidHiveConfig(cfg *Config) error

IsValidHiveConfig ensure all Hive* fields are valid if provided.

func IsValidKubeConfig

func IsValidKubeConfig(kubeconfig string) error

IsValidKubeConfig ensures the kube config is set to a valid file if provided.

func IsValidListenConfig

func IsValidListenConfig(cfg *Config) error

IsValidListenConfig ensures all *Listen fields are set to valid host/ports if they have a value set.

func IsValidNamespaceConfig

func IsValidNamespaceConfig(cfg *Config) error

IsValidNamespaceConfig ensures that if you are using target namespaces the all namespace field is correct.

func IsValidPrestoConfig

func IsValidPrestoConfig(cfg *Config) error

IsValidPrestoConfig ensure all Presto* fields are valid if provided.

func IsValidPrometheusConfig

func IsValidPrometheusConfig(cfg *Config) error

IsValidPrometheusConfig ensures prometheus configuration is valid.

func SanetizeAWSColumnForHive

func SanetizeAWSColumnForHive(col aws.Column) string

SanetizeAWSColumnForHive removes and replaces invalid characters in AWS billing columns with characters allowed in hive SQL

Types

type CollectPrometheusMetricsDataRequest

type CollectPrometheusMetricsDataRequest struct {
	StartTime time.Time `json:"startTime"`
	EndTime   time.Time `json:"endTime"`
}

type CollectPrometheusMetricsDataResponse

type CollectPrometheusMetricsDataResponse struct {
	Results []*prometheusImportResults `json:"results"`
}

type Config

type Config struct {
	// Hostname is used as the identity of the resource lock for leader election as well as the event
	// source when recording events.
	Hostname string

	// OwnNamespace is the namespace the operator is running in.  It is also used as the informer namespace
	// if AllNamespaces or TargetNamespaces are not defined.  OwnNamespace is also the target sink for event
	// recording.
	OwnNamespace string
	// AllNamespaces should be set to true if the operator should watch all namespaces for metering.openshift.io
	// resources.  This should be set to true if more than one namespace is passed in TargetNamespaces.
	AllNamespaces bool
	// TargetNamespaces are the the namespaces for reporting-operator to watch for metering.openshift.io resources.
	TargetNamespaces []string

	// Kubeconfig is the path to the kubeconfig file.  If unset default config loading rules will be used.
	Kubeconfig string

	// APIListen configures the ip:port to listen on for the reporting API.
	APIListen string
	// MetricsListen configures the ip:port to listen on for Prometheus metrics.
	MetricsListen string
	// PprofListen configures the ip:port to listen on for the pprof debug info.
	PprofListen string

	// HiveHost configures the hostname:port for connecting to Hive.
	HiveHost string
	// HiveUseTLS, when set to true, enables TLS when connecting to Hive.  When set, HiveCAFile should also be set.
	HiveUseTLS bool
	// HiveCAFile configures the path to the certificate authority to use to connect to Hive. If empty, defaults to
	// system CAs.  Should be set when HiveUseTLS is set to true.
	HiveCAFile string
	// HiveTLSInsecureSkipVerify is not for production use.  Setting to true disables TLS verification when connecting
	// to Hive.  For testing only.
	HiveTLSInsecureSkipVerify bool

	// HiveUseClientCertAuth enables TLS client certificate authentication when HiveUseTLS is also enabled.
	HiveUseClientCertAuth bool
	// HiveClientCertFile configures the path to the client certificate to use to connect to Hive.
	HiveClientCertFile string
	// HiveClientKeyFile configures the path to the client key to use to connect to Hive.
	HiveClientKeyFile string

	// PrestoHost configures the hostname:port for connecting to Presto.
	PrestoHost string
	// PrestoUseTLS enables TLS when connecting to Presto.
	PrestoUseTLS bool
	// PrestoCAFile configures path to the certificate authority to use to connect to Presto.
	PrestoCAFile string
	// PrestoTLSInsecureSkipVerify is not for production use.  Setting to true disables TLS verification when connecting
	// to Presto.  For testing only.
	PrestoTLSInsecureSkipVerify bool

	// PrestoUseClientCertAuth enables TLS client certificate authentication when PrestoUseTLS is also enabled.
	PrestoUseClientCertAuth bool
	// PrestoClientCertFile configures the path to the client certificate to use to connect to Presto.
	PrestoClientCertFile string
	// PrestoClientKeyFile configures the path to the client key to use to connect to Presto.
	PrestoClientKeyFile string

	// PrestoMaxQueryLength configures the capacity of the buffer pool for the Presto store.
	// TODO: why would someone set this?
	PrestoMaxQueryLength int

	// DisablePrometheusMetricsImporter disables collecting Prometheus metrics periodically.
	DisablePrometheusMetricsImporter bool
	// EnableFinalizers, if enabled, then finalizers will be set on some resources to ensure the reporting-operator
	// is able to perform cleanup before the resource is deleted from the API.
	EnableFinalizers bool

	// LogDMLQueries controls if we log data manipulation queries made via Presto (SELECT, INSERT, etc).
	LogDMLQueries bool
	// LogDDLQueries controls if we log data definition language queries made via Hive (CREATE TABLE, DROP TABLE, etc).
	LogDDLQueries bool

	// PrometheusQueryConfig holds the PrometheusQueryConfig api configuration.
	PrometheusQueryConfig metering.PrometheusQueryConfig
	// PrometheusDataSourceMaxQueryRangeDuration if non-zero specifies the maximum duration of time to query from
	// Prometheus. When back filling, this value is used for the chunkSize when querying Prometheus.
	PrometheusDataSourceMaxQueryRangeDuration time.Duration
	// PrometheusDataSourceMaxBackfillImportDuration if non-zero specifies the maximum duration of time before the
	// current to look back for data when back filling. Only one of PrometheusDataSourceMaxBackfillImportDuration and
	// PrometheusDataSourceGlobalImportFromTime should be set.
	PrometheusDataSourceMaxBackfillImportDuration time.Duration
	// PrometheusDataSourceGlobalImportFromTime, if non-empty, indicates when Prometheus ReportDataSource data should
	// be back filled from.
	PrometheusDataSourceGlobalImportFromTime *time.Time

	// ProxyTrustedCABundle configures the path to the certificate authority bundle used to connect to the cluster-wide
	// https proxy.
	ProxyTrustedCABundle string

	// LeaderLeaseDuration is the duration that non-leader candidates will wait to force acquire leadership.  This
	// value, halved, will be used as the renewal deadline duration for the acting master.
	LeaderLeaseDuration time.Duration

	// APITLSConfig configures TLS options for API traffic.
	APITLSConfig TLSConfig
	// MetricsTLSConfig configures TLS options for Prometheus metrics endpoint traffic.
	MetricsTLSConfig TLSConfig
	// PrometheusConfig configures connectivity options for Prometheus.
	PrometheusConfig PrometheusConfig
}

Config holds the user-facing configuration options for running the reporting operator.

type DependencyResolver

type DependencyResolver interface {
	// ResolveDependencies determines, for the given namespace and report query inputs, any report, report
	// query, and data source dependencies.
	ResolveDependencies(namespace string, inputDefs []metering.ReportQueryInputDefinition, inputVals []metering.ReportQueryInputValue) (*reporting.DependencyResolutionResult, error)
}

DependencyResolver analyzes report dependencies for reports, report queries, and data sources.

type GetReportResults

type GetReportResults struct {
	Results []ReportResultEntry `json:"results"`
}

type PrometheusConfig

type PrometheusConfig struct {
	// Address is the URL to reach Prometheus.
	Address string
	// SkipTLSVerify should not be used in a production environment.  This is used to configure
	// the transport to not verify the sever it is connecting too.  For testing only.
	SkipTLSVerify bool
	// BearerToken is the bearer token for authentication.
	BearerToken string
	// BearerTokenFile is a path to a file that contains the bearer token.  If configured the
	// the contents are periodically read and the last successfully read value takes precedence over
	// BearerToken.
	BearerTokenFile string
	// CAFile is the path of the PEM-encoded server trusted root certificates.
	CAFile string
}

PrometheusConfig provides the configuration options to set up a Prometheus connections from a URL.

type RenderReportQueryRequest

type RenderReportQueryRequest struct {
	Inputs metering.ReportQueryInputValues `json:"inputs,omitempty"`
	Start  time.Time                       `json:"start,omitempty"`
	End    time.Time                       `json:"end,omitempty"`
}

type ReportResultEntry

type ReportResultEntry struct {
	Values []ReportResultValues `json:"values"`
}

type ReportResultValues

type ReportResultValues struct {
	Name        string      `json:"name"`
	Value       interface{} `json:"value"`
	TableHidden bool        `json:"tableHidden"`
	Unit        string      `json:"unit,omitempty"`
}

type ReportingOperator

type ReportingOperator interface {
	Run(ctx context.Context) error
}

func New

func New(logger log.FieldLogger, cfg Config) (ReportingOperator, error)

type StorePrometheusMetricsDataRequest

type StorePrometheusMetricsDataRequest []*prestostore.PrometheusMetric

type TLSConfig

type TLSConfig struct {
	// UseTLS if true TLS is requested and cert/key must be provided for valid config.
	// TODO: we should just key on the existence of this, not a bool, unless we want to
	// configure TLS and not use it.
	UseTLS bool
	// TLSCert is the certificate used to serve TLS.
	TLSCert string
	// TLSKey is the key used to serve TLS.
	TLSKey string
}

TLSConfig allows configuration of using TLS (on/off) as well as the cert and key.

Directories

Path Synopsis
mock
Package mockprestostore is a generated GoMock package.
Package mockprestostore is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL