Skip to content

Commit

Permalink
feat(operator): store trace IDs for each phase of AppVersion
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Bacher <[email protected]>
  • Loading branch information
bacherfl authored and odubajDT committed Nov 22, 2022
1 parent 3eb47d0 commit cd2f8cb
Show file tree
Hide file tree
Showing 11 changed files with 378 additions and 149 deletions.
16 changes: 15 additions & 1 deletion operator/api/v1alpha1/common/phases.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package common

import "strings"
import (
"strings"

"go.opentelemetry.io/otel/propagation"
)

type KeptnPhase KeptnPhaseType

Expand Down Expand Up @@ -47,3 +51,13 @@ var (
PhaseCompleted = KeptnPhaseType{LongName: "Completed", ShortName: "Completed"}
PhaseCancelled = KeptnPhaseType{LongName: "Cancelled", ShortName: "Cancelled"}
)

type PhaseTraceID map[string]propagation.MapCarrier

func (pid PhaseTraceID) SetPhaseTraceID(phase string, carrier propagation.MapCarrier) {
pid[phase] = carrier
}

func (pid PhaseTraceID) GetPhaseTraceID(phase string) propagation.MapCarrier {
return pid[phase]
}
21 changes: 14 additions & 7 deletions operator/api/v1alpha1/keptnappversion_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ type KeptnAppVersionStatus struct {
// +kubebuilder:default:=Pending
PostDeploymentEvaluationStatus common.KeptnState `json:"postDeploymentEvaluationStatus,omitempty"`
// +kubebuilder:default:=Pending
WorkloadOverallStatus common.KeptnState `json:"workloadOverallStatus,omitempty"`
WorkloadStatus []WorkloadStatus `json:"workloadStatus,omitempty"`
CurrentPhase string `json:"currentPhase,omitempty"`
PreDeploymentTaskStatus []TaskStatus `json:"preDeploymentTaskStatus,omitempty"`
PostDeploymentTaskStatus []TaskStatus `json:"postDeploymentTaskStatus,omitempty"`
PreDeploymentEvaluationTaskStatus []EvaluationStatus `json:"preDeploymentEvaluationTaskStatus,omitempty"`
PostDeploymentEvaluationTaskStatus []EvaluationStatus `json:"postDeploymentEvaluationTaskStatus,omitempty"`
WorkloadOverallStatus common.KeptnState `json:"workloadOverallStatus,omitempty"`
WorkloadStatus []WorkloadStatus `json:"workloadStatus,omitempty"`
CurrentPhase string `json:"currentPhase,omitempty"`
PreDeploymentTaskStatus []TaskStatus `json:"preDeploymentTaskStatus,omitempty"`
PostDeploymentTaskStatus []TaskStatus `json:"postDeploymentTaskStatus,omitempty"`
PreDeploymentEvaluationTaskStatus []EvaluationStatus `json:"preDeploymentEvaluationTaskStatus,omitempty"`
PostDeploymentEvaluationTaskStatus []EvaluationStatus `json:"postDeploymentEvaluationTaskStatus,omitempty"`
PhaseTraceIDs map[string]propagation.MapCarrier `json:"phaseTraceIDs,omitempty"`
// +kubebuilder:default:=Pending
Status common.KeptnState `json:"status,omitempty"`

Expand Down Expand Up @@ -373,5 +374,11 @@ func (a *KeptnAppVersion) CancelRemainingPhases(phase common.KeptnPhaseType) {
a.Status.PostDeploymentStatus = common.StateCancelled
a.Status.PostDeploymentEvaluationStatus = common.StateCancelled
a.Status.Status = common.StateFailed
}

func (a *KeptnAppVersion) SetPhaseTraceID(phase string, carrier propagation.MapCarrier) {
if a.Status.PhaseTraceIDs == nil {
a.Status.PhaseTraceIDs = map[string]propagation.MapCarrier{}
}
a.Status.PhaseTraceIDs[phase] = carrier
}
24 changes: 16 additions & 8 deletions operator/api/v1alpha1/keptnworkloadinstance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ type KeptnWorkloadInstanceStatus struct {
// +kubebuilder:default:=Pending
PostDeploymentEvaluationStatus common.KeptnState `json:"postDeploymentEvaluationStatus,omitempty"`
// +kubebuilder:default:=Pending
PostDeploymentStatus common.KeptnState `json:"postDeploymentStatus,omitempty"`
PreDeploymentTaskStatus []TaskStatus `json:"preDeploymentTaskStatus,omitempty"`
PostDeploymentTaskStatus []TaskStatus `json:"postDeploymentTaskStatus,omitempty"`
PreDeploymentEvaluationTaskStatus []EvaluationStatus `json:"preDeploymentEvaluationTaskStatus,omitempty"`
PostDeploymentEvaluationTaskStatus []EvaluationStatus `json:"postDeploymentEvaluationTaskStatus,omitempty"`
StartTime metav1.Time `json:"startTime,omitempty"`
EndTime metav1.Time `json:"endTime,omitempty"`
CurrentPhase string `json:"currentPhase,omitempty"`
PostDeploymentStatus common.KeptnState `json:"postDeploymentStatus,omitempty"`
PreDeploymentTaskStatus []TaskStatus `json:"preDeploymentTaskStatus,omitempty"`
PostDeploymentTaskStatus []TaskStatus `json:"postDeploymentTaskStatus,omitempty"`
PreDeploymentEvaluationTaskStatus []EvaluationStatus `json:"preDeploymentEvaluationTaskStatus,omitempty"`
PostDeploymentEvaluationTaskStatus []EvaluationStatus `json:"postDeploymentEvaluationTaskStatus,omitempty"`
StartTime metav1.Time `json:"startTime,omitempty"`
EndTime metav1.Time `json:"endTime,omitempty"`
CurrentPhase string `json:"currentPhase,omitempty"`
PhaseTraceIDs map[string]propagation.MapCarrier `json:"phaseTraceIDs,omitempty"`
// +kubebuilder:default:=Pending
Status common.KeptnState `json:"status,omitempty"`
}
Expand Down Expand Up @@ -411,3 +412,10 @@ func (w *KeptnWorkloadInstance) CancelRemainingPhases(phase common.KeptnPhaseTyp
w.Status.PostDeploymentEvaluationStatus = common.StateCancelled
w.Status.Status = common.StateFailed
}

func (w *KeptnWorkloadInstance) SetPhaseTraceID(phase string, carrier propagation.MapCarrier) {
if w.Status.PhaseTraceIDs == nil {
w.Status.PhaseTraceIDs = map[string]propagation.MapCarrier{}
}
w.Status.PhaseTraceIDs[phase] = carrier
}
35 changes: 35 additions & 0 deletions operator/api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ spec:
endTime:
format: date-time
type: string
phaseTraceIDs:
additionalProperties:
additionalProperties:
type: string
description: MapCarrier is a TextMapCarrier that uses a map held
in memory as a storage medium for propagated key-value pairs.
type: object
type: object
postDeploymentEvaluationStatus:
default: Pending
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ spec:
endTime:
format: date-time
type: string
phaseTraceIDs:
additionalProperties:
additionalProperties:
type: string
description: MapCarrier is a TextMapCarrier that uses a map held
in memory as a storage medium for propagated key-value pairs.
type: object
type: object
postDeploymentEvaluationStatus:
default: Pending
type: string
Expand Down
Loading

0 comments on commit cd2f8cb

Please sign in to comment.