Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

CRD validation on flytepropeller project structure #328

Merged
merged 9 commits into from
Oct 28, 2021

Conversation

pingsutw
Copy link
Member

@pingsutw pingsutw commented Oct 6, 2021

TL;DR

Adding CRD Validation for Flyteworkflw

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

auto-generate CRD YAML with openapi schema

Tracking Issue

flyteorg/flyte#355

Follow-up issue

NA

@pingsutw pingsutw force-pushed the CRD-validation branch 4 times, most recently from f91ce39 to 772c107 Compare October 7, 2021 12:01
@codecov
Copy link

codecov bot commented Oct 7, 2021

Codecov Report

Merging #328 (6a2ad1b) into master (5f37d78) will decrease coverage by 6.29%.
The diff coverage is 11.88%.

❗ Current head 6a2ad1b differs from pull request most recent head fa992f2. Consider uploading reports for the commit fa992f2 to get more accurate results

Copy link
Contributor

@EngHabu EngHabu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is great! I've some comments on the serialization fields... generally speaking, we shouldn't change the current structure, otherwise, deserializing existing workflow objects will fail..

pkg/apis/flyteworkflow/v1alpha1/branch.go Show resolved Hide resolved
@@ -37,7 +37,7 @@ func (in *Error) DeepCopyInto(out *Error) {
}

type BooleanExpression struct {
*core.BooleanExpression
*core.BooleanExpression `json:"-"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not serialize this? that doesn't look right

Copy link
Member Author

@pingsutw pingsutw Oct 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will cause an error from controller-gen if we use json:",inline".
There is no JSON tag in type "BooleanExpression", and that struct is generated from Flyteidl.

type BooleanExpression struct {
	// Types that are valid to be assigned to Expr:
	//	*BooleanExpression_Conjunction
	//	*BooleanExpression_Comparison
	Expr                 isBooleanExpression_Expr `protobuf_oneof:"expr"`
	XXX_NoUnkeyedLiteral struct{}                 `json:"-"`
	XXX_unrecognized     []byte                   `json:"-"`
	XXX_sizecache        int32                    `json:"-"`
}

Error message:

/Users/kevin/go/src/github.com/flyteorg/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/branch.go:40:2: 
encountered struct field "" without JSON tag in type "BooleanExpression"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed json:"-" here.
It seems like controller-gen can still generate a CRD file although there are some errors.
Can we just Ignore those errors?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what that means.... can you run a workflow in sandbox and see what gets serialized in the Workflow CRD, then apply your changes and rerun the workflow... and capture the CRD... the expectation is there there should be no diff... might be helpful to post the diff here as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkg/apis/flyteworkflow/v1alpha1/execution_config.go Outdated Show resolved Hide resolved
pkg/apis/flyteworkflow/v1alpha1/nodes.go Outdated Show resolved Hide resolved
pkg/apis/flyteworkflow/v1alpha1/nodes.go Outdated Show resolved Hide resolved
pkg/apis/flyteworkflow/v1alpha1/tasks.go Outdated Show resolved Hide resolved
pkg/apis/flyteworkflow/v1alpha1/workflow.go Outdated Show resolved Hide resolved
pkg/apis/flyteworkflow/v1alpha1/workflow.go Outdated Show resolved Hide resolved
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
@pingsutw pingsutw force-pushed the CRD-validation branch 3 times, most recently from 87f21e6 to c11107e Compare October 27, 2021 17:54
Signed-off-by: Kevin Su <[email protected]>
@pingsutw
Copy link
Member Author

Few updates:

  • Rename CRD (the name should be the same as the CRD in flyte repo)
  • Add a GitHub action workflow to make sure the CRD file is up to date.
  • Add short name

@EngHabu
Copy link
Contributor

EngHabu commented Oct 28, 2021

I applied the generated CRD and ran:

  • core.advanced.run_merge_sort.merge_sort
  • core.control_flow.run_conditions.multiplier
  • kfmpi.mpi_mnist.horovod_training_wf
  • core.scheduled_workflows.lp_schedules.date_formatter_wf

successfully

@EngHabu EngHabu merged commit 02f2ad9 into flyteorg:master Oct 28, 2021
EngHabu added a commit that referenced this pull request Oct 28, 2021
EngHabu added a commit that referenced this pull request Oct 28, 2021
EngHabu added a commit that referenced this pull request Oct 28, 2021
Comment on lines -161 to -162
Phase WorkflowNodePhase `json:"phase,omitempty"`
ExecutionError *core.ExecutionError `json:"executionError,omitempty"`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should not change this.

eapolinario pushed a commit to eapolinario/flytepropeller that referenced this pull request Aug 9, 2023
* CRD validation

Signed-off-by: Kevin Su <[email protected]>

* CRD validation

Signed-off-by: Kevin Su <[email protected]>

* Revert json tag name

Signed-off-by: Kevin Su <[email protected]>

* Address comment

Signed-off-by: Kevin Su <[email protected]>

* Address comment

Signed-off-by: Kevin Su <[email protected]>

* Fixed test

Signed-off-by: Kevin Su <[email protected]>

* Rebase

Signed-off-by: Kevin Su <[email protected]>

* Updated CRD

Signed-off-by: Kevin Su <[email protected]>

* test

Signed-off-by: Kevin Su <[email protected]>
eapolinario pushed a commit to eapolinario/flytepropeller that referenced this pull request Aug 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants