resources

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: Apache-2.0 Imports: 36 Imported by: 7

Documentation

Index

Constants

View Source
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
)
View Source
const (
	DefaultPostgresMaintenanceMetricName      = "cro_postgres_service_maintenance"
	DefaultPostgresInfoMetricName             = "cro_postgres_info"
	DefaultPostgresAvailMetricName            = "cro_postgres_available"
	DefaultPostgresConnectionMetricName       = "cro_postgres_connection"
	DefaultPostgresStatusMetricName           = "cro_postgres_status_phase"
	DefaultPostgresDeletionMetricName         = "cro_postgres_deletion_timestamp"
	DefaultPostgresSnapshotStatusMetricName   = "cro_postgres_snapshot_status_phase"
	DefaultPostgresAllocatedStorageMetricName = "cro_postgres_current_allocated_storage"
	DefaultPostgresMaxMemoryMetricName        = "cro_postgres_max_memory"
	DefaultRedisMaintenanceMetricName         = "cro_redis_service_maintenance"
	DefaultRedisInfoMetricName                = "cro_redis_info"
	DefaultRedisAvailMetricName               = "cro_redis_available"
	DefaultRedisConnectionMetricName          = "cro_redis_connection"
	DefaultRedisStatusMetricName              = "cro_redis_status_phase"
	DefaultRedisDeletionMetricName            = "cro_redis_deletion_timestamp"
	DefaultRedisSnapshotStatusMetricName      = "cro_redis_snapshot_status_phase"
	DefaultRedisSnapshotNotAvailable          = "cro_redis_snapshot_not_found"
	DefaultPostgresSnapshotNotAvailable       = "cro_postgres_snapshot_not_found"
	DefaultBlobStorageStatusMetricName        = "cro_blobstorage_status_phase"
	DefaultVpcActionMetricName                = "cro_vpc_action"

	BytesInGibiBytes = 1073741824
)
View Source
const (
	LoggingKeyAction = "action"
)

Variables

View Source
var (
	// MetricVecs create the map of vectors
	MetricVecs map[string]prometheus.GaugeVec
)

Functions

func Btof64

func Btof64(b bool) float64

Boolean to float64

func Contains

func Contains(list []string, s string) bool

Contains checks if a string exists in a slice of strings

func CreateFinalizer

func CreateFinalizer(ctx context.Context, c client.Client, inst client.Object, df string) error

func DeletePrometheusRule

func DeletePrometheusRule(ctx context.Context, client client.Client, ruleName, ns string) error

DeletePrometheusRule will delete a prometheus rule object

func GeneratePassword

func GeneratePassword() (string, error)

func GetAWSRegion

func GetAWSRegion(ctx context.Context, c client.Client) (string, error)

func GetClusterID

func GetClusterID(ctx context.Context, c client.Client) (string, error)

func GetClusterInfrastructure

func GetClusterInfrastructure(ctx context.Context, c client.Client) (*v1.Infrastructure, error)

func GetConfigMapOrDefault

func GetConfigMapOrDefault(ctx context.Context, c client.Client, name types.NamespacedName, def *v1.ConfigMap) (*v1.ConfigMap, error)

func GetForcedReconcileTimeOrDefault

func GetForcedReconcileTimeOrDefault(defaultTo time.Duration) time.Duration

GetForcedReconcileTimeOrDefault returns envar for reconcile time else returns default time

func GetK8Client

func GetK8Client() (*kubernetes.Clientset, error)

func GetMetricReconcileTimeOrDefault

func GetMetricReconcileTimeOrDefault(defaultTo time.Duration) time.Duration

GetMetricReconcileTimeOrDefault returns envar for reconcile time else returns default time

func GetOrganizationTag

func GetOrganizationTag() string

func HasFinalizer

func HasFinalizer(om *controllerruntime.ObjectMeta, finalizer string) bool

func NewActionLogger

func NewActionLogger(logger *logrus.Entry, action string) *logrus.Entry

func NewActionLoggerWithFields

func NewActionLoggerWithFields(logger *logrus.Entry, fields logrus.Fields) *logrus.Entry

func ReconcilePrometheusRule

func ReconcilePrometheusRule(ctx context.Context, client client.Client, ruleName, ns, alertName, desc string, alertExp intstr.IntOrString, labels map[string]string) (*prometheusv1.PrometheusRule, error)

CreatePrometheusRule will create a PrometheusRule object

func RemoveFinalizer

func RemoveFinalizer(om *controllerruntime.ObjectMeta, finalizer string)

func ResetMetric added in v0.33.0

func ResetMetric(name string)

func ResetVpcAction added in v0.35.0

func ResetVpcAction()

ResetVpcAction resets cro_vpc_action metric

func SafeStringDereference

func SafeStringDereference(s *string) string

func SafeTimeDereference

func SafeTimeDereference(t *time.Time) time.Time

func SetMetric

func SetMetric(name string, labels map[string]string, value float64)

SetMetric Set exports a Prometheus Gauge

func SetMetricCurrentTime

func SetMetricCurrentTime(name string, labels map[string]string)

SetMetricCurrentTime Set current time wraps set metric

func SetVpcAction added in v0.35.0

func SetVpcAction(action string, status string, err string, code float64)

SetVpcAction sets cro_vpc_action metric

func ShortenString

func ShortenString(s string, n int) string

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

func StringOrDefault(str, defaultTo string) string

StringOrDefault checks string and returns given default string if empty

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 VerifyVersionUpgradeNeeded

func VerifyVersionUpgradeNeeded(currentVersion string, desiredVersion string) (bool, error)

Types

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 (*ReconcileResourceProvider) ReconcileResultSecret

func (r *ReconcileResourceProvider) ReconcileResultSecret(ctx context.Context, o client.Object, d map[string][]byte) error

Jump to

Keyboard shortcuts

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