Skip to content

Commit

Permalink
Merge pull request #62 from SAP/new-metric-project-creation-time
Browse files Browse the repository at this point in the history
introducing project creation time metric
  • Loading branch information
dafe-corporate-sap authored May 31, 2024
2 parents 735f637 + c8811a4 commit 7a6d5ca
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ LISTER_GEN ?= $(shell pwd)/bin/lister-gen

## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.9.2
CONTROLLER_TOOLS_VERSION ?= v0.14.0
CODE_GENERATOR_VERSION ?= v0.23.4

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
Expand Down
1 change: 0 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

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

20 changes: 12 additions & 8 deletions config/crd/bases/core.cs.sap.com_projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.14.0
name: projects.core.cs.sap.com
spec:
group: core.cs.sap.com
Expand All @@ -28,14 +27,19 @@ spec:
description: Project is the Schema for the projects API.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
Expand Down
1 change: 0 additions & 1 deletion config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: manager-role
rules:
- apiGroups:
Expand Down
1 change: 0 additions & 1 deletion config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
creationTimestamp: null
name: validating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down
2 changes: 2 additions & 0 deletions controllers/project_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@ func (r *ProjectReconciler) Reconcile(ctx context.Context, req ctrl.Request) (re
metrics.ProjectTTLSecondsRemaining.WithLabelValues(project.Name).Set(0)
metrics.ProjectExpired.WithLabelValues(project.Name).Set(0)
}
metrics.ProjectCreationTime.WithLabelValues(project.Name).Set(float64(project.CreationTimestamp.Unix()))
} else {
metrics.ProjectReconcileErrors.DeleteLabelValues(project.Name)
metrics.ProjectTTLSecondsInitial.DeleteLabelValues(project.Name)
metrics.ProjectTTLSecondsRemaining.DeleteLabelValues(project.Name)
metrics.ProjectCreationTime.DeleteLabelValues(project.Name)
metrics.ProjectExpired.DeleteLabelValues(project.Name)
}
if skipStatusUpdate {
Expand Down
20 changes: 12 additions & 8 deletions crds/core.cs.sap.com_projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.14.0
name: projects.core.cs.sap.com
spec:
group: core.cs.sap.com
Expand All @@ -28,14 +27,19 @@ spec:
description: Project is the Schema for the projects API.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
Expand Down
8 changes: 8 additions & 0 deletions internal/metrics/project_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ var (
},
[]string{"project"},
)
ProjectCreationTime = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "project_creation_time",
Help: "Creation time of the project in epoch seconds. Zero means that the project has not been created yet.",
},
[]string{"project"},
)
ProjectExpired = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "project_expired",
Expand All @@ -47,6 +54,7 @@ func init() {
ProjectReconcileErrors,
ProjectTTLSecondsInitial,
ProjectTTLSecondsRemaining,
ProjectCreationTime,
ProjectExpired,
)
}

0 comments on commit 7a6d5ca

Please sign in to comment.