Feat: versioned the context backend values to the app revision (#5231)

Signed-off-by: barnettZQG <barnett.zqg@gmail.com>

Signed-off-by: barnettZQG <barnett.zqg@gmail.com>
This commit is contained in:
barnettZQG
2023-01-02 21:23:12 +08:00
committed by GitHub
parent 6c12b968a7
commit d588def0af
6 changed files with 34 additions and 0 deletions
@@ -135,6 +135,8 @@ type ApplicationRevisionStatus struct {
Succeeded bool `json:"succeeded"`
// Workflow the running status of the workflow
Workflow *common.WorkflowStatus `json:"workflow,omitempty"`
// Record the context values to the revision.
WorkflowContext map[string]string `json:"workflowContext,omitempty"`
}
// +kubebuilder:object:root=true
@@ -293,6 +293,13 @@ func (in *ApplicationRevisionStatus) DeepCopyInto(out *ApplicationRevisionStatus
*out = new(common.WorkflowStatus)
(*in).DeepCopyInto(*out)
}
if in.WorkflowContext != nil {
in, out := &in.WorkflowContext, &out.WorkflowContext
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationRevisionStatus.
@@ -5042,6 +5042,11 @@ spec:
- suspend
- terminated
type: object
workflowContext:
additionalProperties:
type: string
description: Record the context values to the revision.
type: object
required:
- succeeded
type: object
@@ -5042,6 +5042,11 @@ spec:
- suspend
- terminated
type: object
workflowContext:
additionalProperties:
type: string
description: Record the context values to the revision.
type: object
required:
- succeeded
type: object
@@ -5042,6 +5042,11 @@ spec:
- suspend
- terminated
type: object
workflowContext:
additionalProperties:
type: string
description: Record the context values to the revision.
type: object
required:
- succeeded
type: object
@@ -1025,6 +1025,16 @@ func (h *AppHandler) UpdateApplicationRevisionStatus(ctx context.Context, appRev
}
appRev.Status.Succeeded = succeed
appRev.Status.Workflow = wfStatus
// Versioned the context backend values.
if wfStatus.ContextBackend != nil {
var cm corev1.ConfigMap
if err := h.r.Client.Get(ctx, ktypes.NamespacedName{Namespace: wfStatus.ContextBackend.Namespace, Name: wfStatus.ContextBackend.Name}, &cm); err != nil {
klog.Error(err, "[UpdateApplicationRevisionStatus] failed to load the context values", "ApplicationRevision", appRev.Name)
}
appRev.Status.WorkflowContext = cm.Data
}
if err := h.r.Client.Status().Update(ctx, appRev); err != nil {
if logCtx, ok := ctx.(monitorContext.Context); ok {
logCtx.Error(err, "[UpdateApplicationRevisionStatus] failed to update application revision status", "ApplicationRevision", appRev.Name)