Skip to content

Commit

Permalink
Fix #484 - 🔗 Add platform reference to workflow status condition
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo Zanini <[email protected]>
  • Loading branch information
ricardozanini committed Jun 11, 2024
1 parent 6db8d34 commit b3aa2c1
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 1 deletion.
3 changes: 3 additions & 0 deletions api/v1alpha08/sonataflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ type SonataFlowStatus struct {
// Services displays which platform services are being used by this workflow
//+operator-sdk:csv:customresourcedefinitions:type=status,displayName="services"
Services *PlatformServicesStatus `json:"services,omitempty"`
// Platform displays which platform is being used by this workflow
//+operator-sdk:csv:customresourcedefinitions:type=status,displayName="platform"
Platform *SonataFlowPlatformRef `json:"platform,omitempty"`
}

func (s *SonataFlowStatus) GetTopLevelConditionType() api.ConditionType {
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha08/sonataflowplatform_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ type SonataFlowClusterPlatformRefStatus struct {
Services *PlatformServicesStatus `json:"services,omitempty"`
}

// PlatformServicesStatus displays which cluster-wide services are being used by a SonataFlowPlatform
// PlatformServicesStatus displays which cluster-wide services are being used by a SonataFlowPlatform or SonataFlow
// +k8s:openapi-gen=true
type PlatformServicesStatus struct {
// DataIndexRef displays information on the cluster-wide Data Index service
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha08/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 @@ -328,6 +328,9 @@ spec:
path: endpoint
- displayName: lastTimeRecoverAttempt
path: lastTimeRecoverAttempt
- description: Platform displays which platform is being used by this workflow
displayName: platform
path: platform
- description: keeps track of how many failure recovers a given workflow had
so far
displayName: recoverFailureAttempts
Expand Down
14 changes: 14 additions & 0 deletions bundle/manifests/sonataflow.org_sonataflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9461,6 +9461,20 @@ spec:
description: The generation observed by the deployment controller.
format: int64
type: integer
platform:
description: Platform displays which platform is being used by this
workflow
properties:
name:
description: Name of the SonataFlowPlatform
type: string
namespace:
description: Namespace of the SonataFlowPlatform
type: string
required:
- name
- namespace
type: object
recoverFailureAttempts:
description: keeps track of how many failure recovers a given workflow
had so far
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/sonataflow.org_sonataflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9462,6 +9462,20 @@ spec:
description: The generation observed by the deployment controller.
format: int64
type: integer
platform:
description: Platform displays which platform is being used by this
workflow
properties:
name:
description: Name of the SonataFlowPlatform
type: string
namespace:
description: Namespace of the SonataFlowPlatform
type: string
required:
- name
- namespace
type: object
recoverFailureAttempts:
description: keeps track of how many failure recovers a given workflow
had so far
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ spec:
path: endpoint
- displayName: lastTimeRecoverAttempt
path: lastTimeRecoverAttempt
- description: Platform displays which platform is being used by this workflow
displayName: platform
path: platform
- description: keeps track of how many failure recovers a given workflow had
so far
displayName: recoverFailureAttempts
Expand Down
6 changes: 6 additions & 0 deletions controllers/profiles/common/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ func (s *StateSupport) PerformStatusUpdate(ctx context.Context, workflow *operat
}
workflow.Status.ObservedGeneration = workflow.Generation
services.SetServiceUrlsInWorkflowStatus(pl, workflow)
if workflow.Status.Platform == nil {
workflow.Status.Platform = &operatorapi.SonataFlowPlatformRef{}
}
workflow.Status.Platform.Name = pl.Name
workflow.Status.Platform.Namespace = pl.Namespace

if err = s.C.Status().Update(ctx, workflow); err != nil {
klog.V(log.E).ErrorS(err, "Failed to update Workflow status")
return false, err
Expand Down
3 changes: 3 additions & 0 deletions controllers/sonataflow_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,8 @@ func TestSonataFlowController(t *testing.T) {

assert.True(t, ksw.Spec.Flow.Start.StateName == "ChooseOnLanguage")
assert.True(t, len(ksw.Spec.Flow.States) == 4)

assert.Equal(t, ksp.Name, afterReconcileWorkflow.Status.Platform.Name)
assert.Equal(t, ksp.Namespace, afterReconcileWorkflow.Status.Platform.Namespace)
})
}
14 changes: 14 additions & 0 deletions operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26358,6 +26358,20 @@ spec:
description: The generation observed by the deployment controller.
format: int64
type: integer
platform:
description: Platform displays which platform is being used by this
workflow
properties:
name:
description: Name of the SonataFlowPlatform
type: string
namespace:
description: Namespace of the SonataFlowPlatform
type: string
required:
- name
- namespace
type: object
recoverFailureAttempts:
description: keeps track of how many failure recovers a given workflow
had so far
Expand Down

0 comments on commit b3aa2c1

Please sign in to comment.