Skip to content

Commit 7a6d5ca

Browse files
Merge pull request #62 from SAP/new-metric-project-creation-time
introducing project creation time metric
2 parents 735f637 + c8811a4 commit 7a6d5ca

File tree

8 files changed

+35
-20
lines changed

8 files changed

+35
-20
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ LISTER_GEN ?= $(shell pwd)/bin/lister-gen
138138

139139
## Tool Versions
140140
KUSTOMIZE_VERSION ?= v3.8.7
141-
CONTROLLER_TOOLS_VERSION ?= v0.9.2
141+
CONTROLLER_TOOLS_VERSION ?= v0.14.0
142142
CODE_GENERATOR_VERSION ?= v0.23.4
143143

144144
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"

api/v1alpha1/zz_generated.deepcopy.go

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/core.cs.sap.com_projects.yaml

+12-8
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.9.2
7-
creationTimestamp: null
6+
controller-gen.kubebuilder.io/version: v0.14.0
87
name: projects.core.cs.sap.com
98
spec:
109
group: core.cs.sap.com
@@ -28,14 +27,19 @@ spec:
2827
description: Project is the Schema for the projects API.
2928
properties:
3029
apiVersion:
31-
description: 'APIVersion defines the versioned schema of this representation
32-
of an object. Servers should convert recognized schemas to the latest
33-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
30+
description: |-
31+
APIVersion defines the versioned schema of this representation of an object.
32+
Servers should convert recognized schemas to the latest internal value, and
33+
may reject unrecognized values.
34+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
3435
type: string
3536
kind:
36-
description: 'Kind is a string value representing the REST resource this
37-
object represents. Servers may infer this from the endpoint the client
38-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
37+
description: |-
38+
Kind is a string value representing the REST resource this object represents.
39+
Servers may infer this from the endpoint the client submits requests to.
40+
Cannot be updated.
41+
In CamelCase.
42+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
3943
type: string
4044
metadata:
4145
type: object

config/rbac/role.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRole
44
metadata:
5-
creationTimestamp: null
65
name: manager-role
76
rules:
87
- apiGroups:

config/webhook/manifests.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
apiVersion: admissionregistration.k8s.io/v1
33
kind: ValidatingWebhookConfiguration
44
metadata:
5-
creationTimestamp: null
65
name: validating-webhook-configuration
76
webhooks:
87
- admissionReviewVersions:

controllers/project_controller.go

+2
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,12 @@ func (r *ProjectReconciler) Reconcile(ctx context.Context, req ctrl.Request) (re
116116
metrics.ProjectTTLSecondsRemaining.WithLabelValues(project.Name).Set(0)
117117
metrics.ProjectExpired.WithLabelValues(project.Name).Set(0)
118118
}
119+
metrics.ProjectCreationTime.WithLabelValues(project.Name).Set(float64(project.CreationTimestamp.Unix()))
119120
} else {
120121
metrics.ProjectReconcileErrors.DeleteLabelValues(project.Name)
121122
metrics.ProjectTTLSecondsInitial.DeleteLabelValues(project.Name)
122123
metrics.ProjectTTLSecondsRemaining.DeleteLabelValues(project.Name)
124+
metrics.ProjectCreationTime.DeleteLabelValues(project.Name)
123125
metrics.ProjectExpired.DeleteLabelValues(project.Name)
124126
}
125127
if skipStatusUpdate {

crds/core.cs.sap.com_projects.yaml

+12-8
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.9.2
7-
creationTimestamp: null
6+
controller-gen.kubebuilder.io/version: v0.14.0
87
name: projects.core.cs.sap.com
98
spec:
109
group: core.cs.sap.com
@@ -28,14 +27,19 @@ spec:
2827
description: Project is the Schema for the projects API.
2928
properties:
3029
apiVersion:
31-
description: 'APIVersion defines the versioned schema of this representation
32-
of an object. Servers should convert recognized schemas to the latest
33-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
30+
description: |-
31+
APIVersion defines the versioned schema of this representation of an object.
32+
Servers should convert recognized schemas to the latest internal value, and
33+
may reject unrecognized values.
34+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
3435
type: string
3536
kind:
36-
description: 'Kind is a string value representing the REST resource this
37-
object represents. Servers may infer this from the endpoint the client
38-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
37+
description: |-
38+
Kind is a string value representing the REST resource this object represents.
39+
Servers may infer this from the endpoint the client submits requests to.
40+
Cannot be updated.
41+
In CamelCase.
42+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
3943
type: string
4044
metadata:
4145
type: object

internal/metrics/project_metrics.go

+8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ var (
3333
},
3434
[]string{"project"},
3535
)
36+
ProjectCreationTime = prometheus.NewGaugeVec(
37+
prometheus.GaugeOpts{
38+
Name: "project_creation_time",
39+
Help: "Creation time of the project in epoch seconds. Zero means that the project has not been created yet.",
40+
},
41+
[]string{"project"},
42+
)
3643
ProjectExpired = prometheus.NewGaugeVec(
3744
prometheus.GaugeOpts{
3845
Name: "project_expired",
@@ -47,6 +54,7 @@ func init() {
4754
ProjectReconcileErrors,
4855
ProjectTTLSecondsInitial,
4956
ProjectTTLSecondsRemaining,
57+
ProjectCreationTime,
5058
ProjectExpired,
5159
)
5260
}

0 commit comments

Comments
 (0)