From cb871dbe58440735e8f7fea8fe783142547f6fd9 Mon Sep 17 00:00:00 2001 From: odubajDT Date: Thu, 29 Feb 2024 15:20:25 +0100 Subject: [PATCH] feat(lifecycle-operator): introduce ObservabilityTimeout parameter in KeptnWorkload Signed-off-by: odubajDT --- .../scripts/.helm-tests/default/result.yaml | 21 +++++++++++++++++++ .../.helm-tests/lifecycle-only/result.yaml | 21 +++++++++++++++++++ .../lifecycle-with-certs/result.yaml | 21 +++++++++++++++++++ .../api-reference/lifecycle/v1beta1/index.md | 3 +++ .../lifecycle/v1beta1/keptnworkload_types.go | 8 +++++++ .../v1beta1/keptnworkloadversion_types.go | 3 +++ .../v1beta1/zz_generated.deepcopy.go | 2 ++ .../chart/templates/keptnworkload-crd.yaml | 8 +++++++ .../templates/keptnworkloadversion-crd.yaml | 13 ++++++++++++ .../lifecycle.keptn.sh_keptnworkloads.yaml | 8 +++++++ ...ecycle.keptn.sh_keptnworkloadversions.yaml | 13 ++++++++++++ .../lifecycle_v1beta1_keptnworkload.yaml | 1 + ...ifecycle_v1beta1_keptnworkloadversion.yaml | 1 + 13 files changed, 123 insertions(+) diff --git a/.github/scripts/.helm-tests/default/result.yaml b/.github/scripts/.helm-tests/default/result.yaml index b487a5c633..7a873c7941 100644 --- a/.github/scripts/.helm-tests/default/result.yaml +++ b/.github/scripts/.helm-tests/default/result.yaml @@ -7302,6 +7302,14 @@ spec: description: Metadata contains additional key-value pairs for contextual information. type: object + observabilityTimeout: + default: 5m + description: |- + ObservabilityTimeout specifies the maximum time to observe the deployment phase of KeptnWorkload. + If the workload does not deploy successfully within this time frame, it will be + considered as failed. + pattern: ^0|([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ + type: string postDeploymentEvaluations: description: |- PostDeploymentEvaluations is a list of all evaluations to be performed @@ -7791,6 +7799,14 @@ spec: description: Metadata contains additional key-value pairs for contextual information. type: object + observabilityTimeout: + default: 5m + description: |- + ObservabilityTimeout specifies the maximum time to observe the deployment phase of KeptnWorkload. + If the workload does not deploy successfully within this time frame, it will be + considered as failed. + pattern: ^0|([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ + type: string postDeploymentEvaluations: description: |- PostDeploymentEvaluations is a list of all evaluations to be performed @@ -7884,6 +7900,11 @@ spec: - PostDeploymentTasks - PostDeploymentEvaluations type: string + deploymentStartTime: + description: DeploymentStartTime represents the start time of the + deployment phase + format: date-time + type: string deploymentStatus: default: Pending description: DeploymentStatus indicates the current status of the diff --git a/.github/scripts/.helm-tests/lifecycle-only/result.yaml b/.github/scripts/.helm-tests/lifecycle-only/result.yaml index 8363f1f4a9..165e5716f7 100644 --- a/.github/scripts/.helm-tests/lifecycle-only/result.yaml +++ b/.github/scripts/.helm-tests/lifecycle-only/result.yaml @@ -7248,6 +7248,14 @@ spec: description: Metadata contains additional key-value pairs for contextual information. type: object + observabilityTimeout: + default: 5m + description: |- + ObservabilityTimeout specifies the maximum time to observe the deployment phase of KeptnWorkload. + If the workload does not deploy successfully within this time frame, it will be + considered as failed. + pattern: ^0|([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ + type: string postDeploymentEvaluations: description: |- PostDeploymentEvaluations is a list of all evaluations to be performed @@ -7737,6 +7745,14 @@ spec: description: Metadata contains additional key-value pairs for contextual information. type: object + observabilityTimeout: + default: 5m + description: |- + ObservabilityTimeout specifies the maximum time to observe the deployment phase of KeptnWorkload. + If the workload does not deploy successfully within this time frame, it will be + considered as failed. + pattern: ^0|([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ + type: string postDeploymentEvaluations: description: |- PostDeploymentEvaluations is a list of all evaluations to be performed @@ -7830,6 +7846,11 @@ spec: - PostDeploymentTasks - PostDeploymentEvaluations type: string + deploymentStartTime: + description: DeploymentStartTime represents the start time of the + deployment phase + format: date-time + type: string deploymentStatus: default: Pending description: DeploymentStatus indicates the current status of the diff --git a/.github/scripts/.helm-tests/lifecycle-with-certs/result.yaml b/.github/scripts/.helm-tests/lifecycle-with-certs/result.yaml index 4d9acc6f2f..7c309337da 100644 --- a/.github/scripts/.helm-tests/lifecycle-with-certs/result.yaml +++ b/.github/scripts/.helm-tests/lifecycle-with-certs/result.yaml @@ -7282,6 +7282,14 @@ spec: description: Metadata contains additional key-value pairs for contextual information. type: object + observabilityTimeout: + default: 5m + description: |- + ObservabilityTimeout specifies the maximum time to observe the deployment phase of KeptnWorkload. + If the workload does not deploy successfully within this time frame, it will be + considered as failed. + pattern: ^0|([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ + type: string postDeploymentEvaluations: description: |- PostDeploymentEvaluations is a list of all evaluations to be performed @@ -7772,6 +7780,14 @@ spec: description: Metadata contains additional key-value pairs for contextual information. type: object + observabilityTimeout: + default: 5m + description: |- + ObservabilityTimeout specifies the maximum time to observe the deployment phase of KeptnWorkload. + If the workload does not deploy successfully within this time frame, it will be + considered as failed. + pattern: ^0|([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ + type: string postDeploymentEvaluations: description: |- PostDeploymentEvaluations is a list of all evaluations to be performed @@ -7865,6 +7881,11 @@ spec: - PostDeploymentTasks - PostDeploymentEvaluations type: string + deploymentStartTime: + description: DeploymentStartTime represents the start time of the + deployment phase + format: date-time + type: string deploymentStatus: default: Pending description: DeploymentStatus indicates the current status of the diff --git a/docs/docs/reference/api-reference/lifecycle/v1beta1/index.md b/docs/docs/reference/api-reference/lifecycle/v1beta1/index.md index bc0db5d8d8..4b688d57ec 100644 --- a/docs/docs/reference/api-reference/lifecycle/v1beta1/index.md +++ b/docs/docs/reference/api-reference/lifecycle/v1beta1/index.md @@ -827,6 +827,7 @@ _Appears in:_ | `postDeploymentEvaluations` _string array_ | PostDeploymentEvaluations is a list of all evaluations to be performed during the post-deployment phase of the KeptnWorkload. The items of this list refer to the names of KeptnEvaluationDefinitions located in the same namespace as the KeptnWorkload, or in the Keptn namespace. || ✓ | | `resourceReference` _[ResourceReference](#resourcereference)_ | ResourceReference is a reference to the Kubernetes resource (Deployment, DaemonSet, StatefulSet or ReplicaSet) the KeptnWorkload is representing. || x | | `metadata` _object (keys:string, values:string)_ | Metadata contains additional key-value pairs for contextual information. || ✓ | +| `observabilityTimeout` _[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#duration-v1-meta)_ | ObservabilityTimeout specifies the maximum time to observe the deployment phase of KeptnWorkload. If the workload does not deploy successfully within this time frame, it will be considered as failed. |5m| ✓ | #### KeptnWorkloadStatus @@ -896,6 +897,7 @@ _Appears in:_ | `postDeploymentEvaluations` _string array_ | PostDeploymentEvaluations is a list of all evaluations to be performed during the post-deployment phase of the KeptnWorkload. The items of this list refer to the names of KeptnEvaluationDefinitions located in the same namespace as the KeptnWorkload, or in the Keptn namespace. || ✓ | | `resourceReference` _[ResourceReference](#resourcereference)_ | ResourceReference is a reference to the Kubernetes resource (Deployment, DaemonSet, StatefulSet or ReplicaSet) the KeptnWorkload is representing. || x | | `metadata` _object (keys:string, values:string)_ | Metadata contains additional key-value pairs for contextual information. || ✓ | +| `observabilityTimeout` _[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#duration-v1-meta)_ | ObservabilityTimeout specifies the maximum time to observe the deployment phase of KeptnWorkload. If the workload does not deploy successfully within this time frame, it will be considered as failed. |5m| ✓ | | `workloadName` _string_ | WorkloadName is the name of the KeptnWorkload. || x | | `previousVersion` _string_ | PreviousVersion is the version of the KeptnWorkload that has been deployed prior to this version. || ✓ | | `traceId` _object (keys:string, values:string)_ | TraceId contains the OpenTelemetry trace ID. || ✓ | @@ -927,6 +929,7 @@ _Appears in:_ | `phaseTraceIDs` _[MapCarrier](https://pkg.go.dev/go.opentelemetry.io/otel/propagation#MapCarrier)_ | PhaseTraceIDs contains the trace IDs of the OpenTelemetry spans of each phase of the KeptnWorkloadVersion || ✓ | | `status` _string_ | Status represents the overall status of the KeptnWorkloadVersion. |Pending| ✓ | | `appContextMetadata` _object (keys:string, values:string)_ | AppContextMetadata contains metadata from the related KeptnAppVersion. || ✓ | +| `deploymentStartTime` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#time-v1-meta)_ | DeploymentStartTime represents the start time of the deployment phase || ✓ | #### Objective diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkload_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkload_types.go index 560b4fd800..6960383caf 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkload_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkload_types.go @@ -61,6 +61,14 @@ type KeptnWorkloadSpec struct { // +optional // Metadata contains additional key-value pairs for contextual information. Metadata map[string]string `json:"metadata,omitempty"` + // ObservabilityTimeout specifies the maximum time to observe the deployment phase of KeptnWorkload. + // If the workload does not deploy successfully within this time frame, it will be + // considered as failed. + // +kubebuilder:default:="5m" + // +kubebuilder:validation:Pattern="^0|([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$" + // +kubebuilder:validation:Type:=string + // +optional + ObservabilityTimeout metav1.Duration `json:"observabilityTimeout,omitempty"` } // KeptnWorkloadStatus defines the observed state of KeptnWorkload diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkloadversion_types.go b/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkloadversion_types.go index 7517d86b73..5f32491c53 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkloadversion_types.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/keptnworkloadversion_types.go @@ -117,6 +117,9 @@ type KeptnWorkloadVersionStatus struct { // AppContextMetadata contains metadata from the related KeptnAppVersion. // +optional AppContextMetadata map[string]string `json:"appContextMetadata,omitempty"` + // DeploymentStartTime represents the start time of the deployment phase + // +optional + DeploymentStartTime metav1.Time `json:"deploymentStartTime,omitempty"` } // +kubebuilder:object:root=true diff --git a/lifecycle-operator/apis/lifecycle/v1beta1/zz_generated.deepcopy.go b/lifecycle-operator/apis/lifecycle/v1beta1/zz_generated.deepcopy.go index 78e5f1a3d2..5400f25e15 100644 --- a/lifecycle-operator/apis/lifecycle/v1beta1/zz_generated.deepcopy.go +++ b/lifecycle-operator/apis/lifecycle/v1beta1/zz_generated.deepcopy.go @@ -1191,6 +1191,7 @@ func (in *KeptnWorkloadSpec) DeepCopyInto(out *KeptnWorkloadSpec) { (*out)[key] = val } } + out.ObservabilityTimeout = in.ObservabilityTimeout } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KeptnWorkloadSpec. @@ -1358,6 +1359,7 @@ func (in *KeptnWorkloadVersionStatus) DeepCopyInto(out *KeptnWorkloadVersionStat (*out)[key] = val } } + in.DeploymentStartTime.DeepCopyInto(&out.DeploymentStartTime) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KeptnWorkloadVersionStatus. diff --git a/lifecycle-operator/chart/templates/keptnworkload-crd.yaml b/lifecycle-operator/chart/templates/keptnworkload-crd.yaml index 6459e37fe3..3797c4e56c 100644 --- a/lifecycle-operator/chart/templates/keptnworkload-crd.yaml +++ b/lifecycle-operator/chart/templates/keptnworkload-crd.yaml @@ -343,6 +343,14 @@ spec: description: Metadata contains additional key-value pairs for contextual information. type: object + observabilityTimeout: + default: 5m + description: |- + ObservabilityTimeout specifies the maximum time to observe the deployment phase of KeptnWorkload. + If the workload does not deploy successfully within this time frame, it will be + considered as failed. + pattern: ^0|([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ + type: string postDeploymentEvaluations: description: |- PostDeploymentEvaluations is a list of all evaluations to be performed diff --git a/lifecycle-operator/chart/templates/keptnworkloadversion-crd.yaml b/lifecycle-operator/chart/templates/keptnworkloadversion-crd.yaml index 572606164c..3290084459 100644 --- a/lifecycle-operator/chart/templates/keptnworkloadversion-crd.yaml +++ b/lifecycle-operator/chart/templates/keptnworkloadversion-crd.yaml @@ -409,6 +409,14 @@ spec: description: Metadata contains additional key-value pairs for contextual information. type: object + observabilityTimeout: + default: 5m + description: |- + ObservabilityTimeout specifies the maximum time to observe the deployment phase of KeptnWorkload. + If the workload does not deploy successfully within this time frame, it will be + considered as failed. + pattern: ^0|([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ + type: string postDeploymentEvaluations: description: |- PostDeploymentEvaluations is a list of all evaluations to be performed @@ -502,6 +510,11 @@ spec: - PostDeploymentTasks - PostDeploymentEvaluations type: string + deploymentStartTime: + description: DeploymentStartTime represents the start time of the + deployment phase + format: date-time + type: string deploymentStatus: default: Pending description: DeploymentStatus indicates the current status of the diff --git a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloads.yaml b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloads.yaml index 650639dad3..9d9f85b079 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloads.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloads.yaml @@ -335,6 +335,14 @@ spec: description: Metadata contains additional key-value pairs for contextual information. type: object + observabilityTimeout: + default: 5m + description: |- + ObservabilityTimeout specifies the maximum time to observe the deployment phase of KeptnWorkload. + If the workload does not deploy successfully within this time frame, it will be + considered as failed. + pattern: ^0|([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ + type: string postDeploymentEvaluations: description: |- PostDeploymentEvaluations is a list of all evaluations to be performed diff --git a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadversions.yaml b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadversions.yaml index 69607e4eac..f50bde187c 100644 --- a/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadversions.yaml +++ b/lifecycle-operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadversions.yaml @@ -401,6 +401,14 @@ spec: description: Metadata contains additional key-value pairs for contextual information. type: object + observabilityTimeout: + default: 5m + description: |- + ObservabilityTimeout specifies the maximum time to observe the deployment phase of KeptnWorkload. + If the workload does not deploy successfully within this time frame, it will be + considered as failed. + pattern: ^0|([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ + type: string postDeploymentEvaluations: description: |- PostDeploymentEvaluations is a list of all evaluations to be performed @@ -494,6 +502,11 @@ spec: - PostDeploymentTasks - PostDeploymentEvaluations type: string + deploymentStartTime: + description: DeploymentStartTime represents the start time of the + deployment phase + format: date-time + type: string deploymentStatus: default: Pending description: DeploymentStatus indicates the current status of the diff --git a/lifecycle-operator/config/samples/lifecycle_v1beta1_keptnworkload.yaml b/lifecycle-operator/config/samples/lifecycle_v1beta1_keptnworkload.yaml index f655625285..3aee64d961 100644 --- a/lifecycle-operator/config/samples/lifecycle_v1beta1_keptnworkload.yaml +++ b/lifecycle-operator/config/samples/lifecycle_v1beta1_keptnworkload.yaml @@ -3,6 +3,7 @@ kind: KeptnWorkload metadata: name: keptnworkload-sample spec: + observabilityTimeout: 5m app: "some-keptn-app2" version: "0.2.7" preDeploymentTasks: diff --git a/lifecycle-operator/config/samples/lifecycle_v1beta1_keptnworkloadversion.yaml b/lifecycle-operator/config/samples/lifecycle_v1beta1_keptnworkloadversion.yaml index 16cac85886..0def6f43c5 100644 --- a/lifecycle-operator/config/samples/lifecycle_v1beta1_keptnworkloadversion.yaml +++ b/lifecycle-operator/config/samples/lifecycle_v1beta1_keptnworkloadversion.yaml @@ -5,6 +5,7 @@ metadata: traceparent: my-trace-parent name: some-keptn-workload-version spec: + observabilityTimeout: 5m app: podtato-head resourceReference: kind: ReplicaSet