Skip to content

Commit

Permalink
Feat: versioned the context backend values to the app revision (kubev…
Browse files Browse the repository at this point in the history
…ela#5231)

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

Signed-off-by: barnettZQG <barnett.zqg@gmail.com>
  • Loading branch information
barnettZQG committed Jan 30, 2023
1 parent 629bcd8 commit 3158912
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apis/core.oam.dev/v1beta1/applicationrevision_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions apis/core.oam.dev/v1beta1/zz_generated.deepcopy.go

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

5 changes: 5 additions & 0 deletions charts/vela-core/crds/core.oam.dev_applicationrevisions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions pkg/controller/core.oam.dev/v1alpha2/application/revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3158912

Please sign in to comment.