Documentation ¶
Index ¶
- Constants
- Variables
- func AddLabel(object metav1.Object, key, value string)
- func Btof64(b bool) float64
- func BuildGenericMetricLabels(objectMeta metav1.ObjectMeta, clusterID, instanceID, providerName string) map[string]string
- func BuildInfoMetricLabels(r metav1.ObjectMeta, status string, clusterID, cacheName, providerName string) map[string]string
- func BuildInfraName(ctx context.Context, c client.Client, postfix string, n int) (string, error)
- func BuildInfraNameFromObject(ctx context.Context, c client.Client, om controllerruntime.ObjectMeta, n int) (string, error)
- func BuildStatusMetricsLabels(r metav1.ObjectMeta, clusterID, cacheName, providerName string, ...) map[string]string
- func BuildTimestampedInfraNameFromObject(ctx context.Context, c client.Client, om controllerruntime.ObjectMeta, n int) (string, error)
- func BuildTimestampedInfraNameFromObjectCreation(ctx context.Context, c client.Client, om controllerruntime.ObjectMeta, n int) (string, error)
- func Contains(list []string, s string) bool
- func CreateFinalizer(ctx context.Context, c client.Client, inst client.Object, df string) error
- func GeneratePassword() (string, error)
- func GetAWSRegion(ctx context.Context, c client.Client) (string, error)
- func GetClusterID(ctx context.Context, c client.Client) (string, error)
- func GetClusterInfrastructure(ctx context.Context, c client.Client) (*configv1.Infrastructure, error)
- func GetConfigMapOrDefault(ctx context.Context, c client.Client, name types.NamespacedName, ...) (*v1.ConfigMap, error)
- func GetForcedReconcileTimeOrDefault(defaultTo time.Duration) time.Duration
- func GetGCPProject(ctx context.Context, c client.Client) (string, error)
- func GetGCPRegion(ctx context.Context, c client.Client) (string, error)
- func GetK8Client() (*kubernetes.Clientset, error)
- func GetLabel(object metav1.Object, key string) string
- func GetMetricReconcileTimeOrDefault(defaultTo time.Duration) time.Duration
- func GetOrganizationTag() string
- func GetPlatformType(ctx context.Context, c client.Client) (configv1.PlatformType, error)
- func HasFinalizer(om *controllerruntime.ObjectMeta, finalizer string) bool
- func HasLabel(object metav1.Object, key string) bool
- func HasLabelWithValue(object metav1.Object, key, value string) bool
- func IsCompoundMetric(metric string) bool
- func IsComputedCpuMetric(metric string) bool
- func IsConflictError(err error) bool
- func IsLastResource(ctx context.Context, c client.Client) (bool, error)
- func IsNotFoundError(err error) bool
- func NewActionLogger(logger *logrus.Entry, action string) *logrus.Entry
- func NewActionLoggerWithFields(logger *logrus.Entry, fields logrus.Fields) *logrus.Entry
- func NewMockAPIError(grpcCode grpcCodes.Code) *googleGRPC.APIError
- func RemoveFinalizer(om *controllerruntime.ObjectMeta, finalizer string)
- func RemoveLabel(object metav1.Object, key string)
- func ResetMetric(name string)
- func ResetSTSCredentialsSecretMetric()
- func ResetVpcAction()
- func SafeStringDereference(s *string) string
- func SafeTimeDereference(t *time.Time) time.Time
- func SetMetric(name string, labels map[string]string, value float64)
- func SetMetricCurrentTime(name string, labels map[string]string)
- func SetSTSCredentialsSecretMetric(ns string, err error)
- func SetVpcAction(action string, status string, err string, code float64)
- func ShortenString(s string, n int) string
- func StartGaugeVector()
- func StringOrDefault(str, defaultTo string) string
- func TagsContains(tags []*Tag, key, value string) bool
- func TagsContainsAll(as []*Tag, bs []*Tag) bool
- func UpdatePhase(ctx context.Context, client client.Client, inst client.Object, ...) error
- func UpdateSnapshotPhase(ctx context.Context, client client.Client, inst client.Object, ...) error
- func VerifyPostgresMaintenanceWindow(ctx context.Context, client k8sclient.Client, namespace string, name string) (bool, error)
- func VerifyRedisMaintenanceWindow(ctx context.Context, client k8sclient.Client, namespace string, name string) (bool, error)
- func VerifyVersionUpgradeNeeded(currentVersion string, desiredVersion string) (bool, error)
- type ConnectionTestManager
- type ConnectionTester
- type ConnectionTesterMock
- type ErrorGRPC
- type MonitoringResourceType
- type OpenShiftPodCommander
- type PodCommander
- type PodCommanderMock
- type ReconcileResourceProvider
- type Tag
Constants ¶
const ( EnvForceReconcileTimeout = "ENV_FORCE_RECONCILE_TIMEOUT" EnvMetricsReconcileTimeout = "ENV_METRIC_RECONCILE_TIMEOUT" DefaultTagKeyPrefix = "integreatly.org/" // Set the reconcile duration for this controller. // Currently it will be called once every 5 minutes MetricsWatchDuration = 5 * time.Minute )
const ( BytesInGibiBytes = 1073741824 DefaultBlobStorageStatusMetricName = "cro_blobstorage_status_phase" DefaultPostgresAvailMetricName = "cro_postgres_available" DefaultPostgresConnectionMetricName = "cro_postgres_connection" DefaultPostgresDeletionMetricName = "cro_postgres_deletion_timestamp" DefaultPostgresInfoMetricName = "cro_postgres_info" DefaultPostgresMaintenanceMetricName = "cro_postgres_service_maintenance" DefaultPostgresSnapshotStatusMetricName = "cro_postgres_snapshot_status_phase" DefaultPostgresStatusMetricName = "cro_postgres_status_phase" DefaultRedisAvailMetricName = "cro_redis_available" DefaultRedisConnectionMetricName = "cro_redis_connection" DefaultRedisDeletionMetricName = "cro_redis_deletion_timestamp" DefaultRedisInfoMetricName = "cro_redis_info" DefaultRedisMaintenanceMetricName = "cro_redis_service_maintenance" DefaultRedisSnapshotNotAvailable = "cro_redis_snapshot_not_found" DefaultRedisSnapshotStatusMetricName = "cro_redis_snapshot_status_phase" DefaultRedisStatusMetricName = "cro_redis_status_phase" DefaultSTSCredentialsSecretMetricName = "cro_sts_credentials_secret" // #nosec G101 -- false positive (ref: https://securego.io/docs/rules/g101.html) DefaultVpcActionMetricName = "cro_vpc_action" MonitoringResourceTypeRedisInstance MonitoringResourceType = "redis_instance" MonitoringResourceTypeCloudsqlDatabase MonitoringResourceType = "cloudsql_database" PostgresFreeStorageAverageMetricName = "cro_postgres_free_storage_average" PostgresCPUUtilizationAverageMetricName = "cro_postgres_cpu_utilization_average" PostgresFreeableMemoryAverageMetricName = "cro_postgres_freeable_memory_average" PostgresMaxMemoryMetricName = "cro_postgres_max_memory" PostgresAllocatedStorageMetricName = "cro_postgres_current_allocated_storage" RedisMemoryUsagePercentageAverageMetricName = "cro_redis_memory_usage_percentage_average" RedisFreeableMemoryAverageMetricName = "cro_redis_freeable_memory_average" RedisCPUUtilizationAverageMetricName = "cro_redis_cpu_utilization_average" RedisEngineCPUUtilizationAverageMetricName = "cro_redis_engine_cpu_utilization_average" )
const ( LabelClusterIDKey = "clusterID" LabelResourceIDKey = "resourceID" LabelNamespaceKey = "namespace" LabelInstanceIDKey = "instanceID" LabelProductNameKey = "productName" LabelStrategyKey = "strategy" LabelStatusKey = "status" LabelStatusPhaseKey = "statusPhase" )
const ( TagDisplayName = "Name" TagManagedKey = "red-hat-managed" TagManagedVal = "true" )
const (
LoggingKeyAction = "action"
)
Variables ¶
var ( // MetricVecs create the map of vectors MetricVecs map[string]prometheus.GaugeVec )
Functions ¶
func BuildGenericMetricLabels ¶ added in v1.0.0
func BuildGenericMetricLabels(objectMeta metav1.ObjectMeta, clusterID, instanceID, providerName string) map[string]string
BuildGenericMetricLabels returns generic labels to be added to every metric
func BuildInfoMetricLabels ¶ added in v1.0.0
func BuildInfoMetricLabels(r metav1.ObjectMeta, status string, clusterID, cacheName, providerName string) map[string]string
BuildInfoMetricLabels adds extra information to labels around resource
func BuildInfraName ¶ added in v1.0.0
BuildInfraName builds and returns an id used for infra resources
func BuildInfraNameFromObject ¶ added in v1.0.0
func BuildInfraNameFromObject(ctx context.Context, c client.Client, om controllerruntime.ObjectMeta, n int) (string, error)
func BuildStatusMetricsLabels ¶ added in v1.0.0
func BuildStatusMetricsLabels(r metav1.ObjectMeta, clusterID, cacheName, providerName string, phase croType.StatusPhase) map[string]string
func BuildTimestampedInfraNameFromObject ¶ added in v1.0.0
func BuildTimestampedInfraNameFromObject(ctx context.Context, c client.Client, om controllerruntime.ObjectMeta, n int) (string, error)
func BuildTimestampedInfraNameFromObjectCreation ¶ added in v1.0.0
func BuildTimestampedInfraNameFromObjectCreation(ctx context.Context, c client.Client, om controllerruntime.ObjectMeta, n int) (string, error)
func CreateFinalizer ¶
func GeneratePassword ¶
func GetConfigMapOrDefault ¶
func GetForcedReconcileTimeOrDefault ¶
GetForcedReconcileTimeOrDefault returns envar for reconcile time else returns default time
func GetGCPProject ¶ added in v1.0.0
func GetGCPRegion ¶ added in v1.0.0
func GetK8Client ¶
func GetK8Client() (*kubernetes.Clientset, error)
func GetMetricReconcileTimeOrDefault ¶
GetMetricReconcileTimeOrDefault returns envar for reconcile time else returns default time
func GetOrganizationTag ¶
func GetOrganizationTag() string
func GetPlatformType ¶ added in v1.0.0
func HasFinalizer ¶
func HasFinalizer(om *controllerruntime.ObjectMeta, finalizer string) bool
func HasLabelWithValue ¶ added in v1.1.0
HasLabelWithValue returns true if the label with corresponding value matches
func IsCompoundMetric ¶ added in v1.0.0
func IsComputedCpuMetric ¶ added in v1.0.0
func IsConflictError ¶ added in v1.0.0
func IsLastResource ¶ added in v1.0.0
func IsNotFoundError ¶ added in v1.0.0
func NewMockAPIError ¶ added in v1.0.0
func NewMockAPIError(grpcCode grpcCodes.Code) *googleGRPC.APIError
NewMockAPIError is used for mocking errors from package github.com/googleapis/gax-go/v2/apierror
func RemoveFinalizer ¶
func RemoveFinalizer(om *controllerruntime.ObjectMeta, finalizer string)
func RemoveLabel ¶ added in v1.1.0
RemoveLabel makes sure that the provided label is removed
func ResetMetric ¶ added in v0.33.0
func ResetMetric(name string)
func ResetSTSCredentialsSecretMetric ¶ added in v0.40.0
func ResetSTSCredentialsSecretMetric()
ResetSTSCredentialsSecretMetric resets cro_sts_credentials_secret metric
func ResetVpcAction ¶ added in v0.35.0
func ResetVpcAction()
ResetVpcAction resets cro_vpc_action metric
func SafeStringDereference ¶
func SetMetricCurrentTime ¶
SetMetricCurrentTime Set current time wraps set metric
func SetSTSCredentialsSecretMetric ¶ added in v0.40.0
SetSTSCredentialsSecretMetric sets cro_sts_credentials_secret metric
func SetVpcAction ¶ added in v0.35.0
SetVpcAction sets cro_vpc_action metric
func ShortenString ¶
ShortenString Cut string size, but maintain a reference to the original string using a hash of the full string in the result
func StartGaugeVector ¶
func StartGaugeVector()
StartGaugeVector periodic loop that is wiping all known vectors.
func StringOrDefault ¶
StringOrDefault checks string and returns given default string if empty
func TagsContains ¶ added in v1.0.0
func TagsContainsAll ¶ added in v1.0.0
TagsContainsAll checks whether all tags in first parameter are contained within second parameter
func UpdatePhase ¶
func UpdatePhase(ctx context.Context, client client.Client, inst client.Object, phase croType.StatusPhase, msg croType.StatusMessage) error
UpdatePhase Updates the custom resource with the current phase
func UpdateSnapshotPhase ¶
func UpdateSnapshotPhase(ctx context.Context, client client.Client, inst client.Object, phase croType.StatusPhase, msg croType.StatusMessage) error
UpdateSnapshotPhase Updates the snapshot custom resource with the current phase
func VerifyPostgresMaintenanceWindow ¶ added in v0.41.0
func VerifyRedisMaintenanceWindow ¶ added in v0.41.0
Types ¶
type ConnectionTestManager ¶ added in v1.0.0
type ConnectionTestManager struct{}
func NewConnectionTestManager ¶ added in v1.0.0
func NewConnectionTestManager() *ConnectionTestManager
func (*ConnectionTestManager) TCPConnection ¶ added in v1.0.0
func (m *ConnectionTestManager) TCPConnection(host string, port int) bool
TCPConnection trys to create a tcp connection, if none can be made it returns an error
type ConnectionTester ¶ added in v1.0.0
type ConnectionTesterMock ¶ added in v1.0.0
type ConnectionTesterMock struct { // TCPConnectionFunc mocks the TCPConnection method. TCPConnectionFunc func(host string, port int) bool // contains filtered or unexported fields }
ConnectionTesterMock is a mock implementation of ConnectionTester.
func TestSomethingThatUsesConnectionTester(t *testing.T) { // make and configure a mocked ConnectionTester mockedConnectionTester := &ConnectionTesterMock{ TCPConnectionFunc: func(host string, port int) bool { panic("mock out the TCPConnection method") }, } // use mockedConnectionTester in code that requires ConnectionTester // and then make assertions. }
func BuildMockConnectionTester ¶ added in v1.0.0
func BuildMockConnectionTester() *ConnectionTesterMock
func (*ConnectionTesterMock) TCPConnection ¶ added in v1.0.0
func (mock *ConnectionTesterMock) TCPConnection(host string, port int) bool
TCPConnection calls TCPConnectionFunc.
func (*ConnectionTesterMock) TCPConnectionCalls ¶ added in v1.0.0
func (mock *ConnectionTesterMock) TCPConnectionCalls() []struct { Host string Port int }
TCPConnectionCalls gets all the calls that were made to TCPConnection. Check the length with:
len(mockedConnectionTester.TCPConnectionCalls())
type ErrorGRPC ¶ added in v1.0.0
type ErrorGRPC struct {
// contains filtered or unexported fields
}
func (ErrorGRPC) GRPCStatus ¶ added in v1.0.0
type MonitoringResourceType ¶ added in v1.0.0
type MonitoringResourceType string
type OpenShiftPodCommander ¶
type OpenShiftPodCommander struct {
ClientSet *kubernetes.Clientset
}
func (*OpenShiftPodCommander) ExecIntoPod ¶
func (pc *OpenShiftPodCommander) ExecIntoPod(dpl *appsv1.Deployment, cmd string) error
type PodCommander ¶
type PodCommander interface {
ExecIntoPod(dpl *appsv1.Deployment, cmd string) error
}
type PodCommanderMock ¶
type PodCommanderMock struct { // ExecIntoPodFunc mocks the ExecIntoPod method. ExecIntoPodFunc func(dpl *appsv1.Deployment, cmd string) error // contains filtered or unexported fields }
PodCommanderMock is a mock implementation of PodCommander.
func TestSomethingThatUsesPodCommander(t *testing.T) { // make and configure a mocked PodCommander mockedPodCommander := &PodCommanderMock{ ExecIntoPodFunc: func(dpl *appsv1.Deployment, cmd string) error { panic("mock out the ExecIntoPod method") }, } // use mockedPodCommander in code that requires PodCommander // and then make assertions. }
func (*PodCommanderMock) ExecIntoPod ¶
func (mock *PodCommanderMock) ExecIntoPod(dpl *appsv1.Deployment, cmd string) error
ExecIntoPod calls ExecIntoPodFunc.
func (*PodCommanderMock) ExecIntoPodCalls ¶
func (mock *PodCommanderMock) ExecIntoPodCalls() []struct { Dpl *appsv1.Deployment Cmd string }
ExecIntoPodCalls gets all the calls that were made to ExecIntoPod. Check the length with:
len(mockedPodCommander.ExecIntoPodCalls())
type ReconcileResourceProvider ¶
type ReconcileResourceProvider struct { Client client.Client Scheme *runtime.Scheme Logger *logrus.Entry }
func NewResourceProvider ¶
func (*ReconcileResourceProvider) ReconcileResultSecret ¶
type Tag ¶ added in v1.0.0
generic key-value tag
func BuildManagedTag ¶ added in v1.0.0
func BuildManagedTag() *Tag