-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flyteadmin] Show diff structure when re-registration two different task with same ids #4924
[flyteadmin] Show diff structure when re-registration two different task with same ids #4924
Conversation
Thank you for opening this pull request! 🙌 These tips will help get your PR across the finish line:
|
What about e.g., |
What if we just show |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think overall looks well, however I am not familiar with flyteadmin's codebase. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4924 +/- ##
==========================================
+ Coverage 59.00% 59.03% +0.02%
==========================================
Files 645 645
Lines 55672 55726 +54
==========================================
+ Hits 32850 32896 +46
- Misses 20226 20233 +7
- Partials 2596 2597 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks so great! thank you for updating workflow validation as part of this task too
flyteadmin/pkg/errors/errors.go
Outdated
|
||
func NewTaskExistsDifferentStructureError(ctx context.Context, request *admin.TaskCreateRequest, oldSpec *core.TaskTemplate, newSpec *core.TaskTemplate) FlyteAdminError { | ||
errorMsg := "task with different structure already exists:\n" | ||
// omit source code file object storage path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
args/2 is still used for the digest computation, right? any reason to omit it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we still hash the whole task for digest.
The reason to omit file path shown in error message is that it already trapped in "different structure with same id" error, saying code file must be different. So it's trivial to hide the path changed information. cc @pingsutw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another concern of mine is what if the file path value ("s3://my-s3-bucket/flytesnacks/..."
) being stored with different key path
in the future, for example, args/3
.
The code will be broken and hard to locate bugs. Any suggestion?
flyteadmin/pkg/errors/errors.go
Outdated
func NewTaskExistsDifferentStructureError(ctx context.Context, request *admin.TaskCreateRequest, oldSpec *core.TaskTemplate, newSpec *core.TaskTemplate) FlyteAdminError { | ||
errorMsg := "task with different structure already exists:\n" | ||
// omit source code file object storage path | ||
diff, _ := jsondiff.Compare(oldSpec, newSpec, jsondiff.Ignores("/Target/Container/args/2")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need two Compare calls here?
it looks like according to https://pkg.go.dev/github.com/wI2L/jsondiff#Differ.Compare this should output the diff between src & tgt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because jsondiff.Compare returns a json patch file meaning a series of operations of that json.
It only show the modified target
json other than source
json. Since we're talking about diff
message. It must show the difference between changes from source
to target
.
diff = jsondiff.Compare(oldTemplate, newTemplate)
rdiff = jsondiff.Compare(newTemplate, oldTemplate
which prefix r
means reverse
.
Finally compareJsons()
zip the diff
and its complements rdiff
.
2dd7cc0
to
321b2e7
Compare
message TaskErrorExistsDifferentStructure { | ||
core.Identifier id = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! thx
72ce445
to
2b8e6a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great, just one question about map comparison determinism
|
||
func NewTaskExistsDifferentStructureError(ctx context.Context, request *admin.TaskCreateRequest, oldSpec *core.CompiledTask, newSpec *core.CompiledTask) FlyteAdminError { | ||
errorMsg := "task with different structure already exists:\n" | ||
diff, _ := jsondiff.Compare(oldSpec, newSpec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since in golang map ordering is random/never guaranteed, I'm worried that converting the specs to bytes here might lead to non deterministic byte arrays
when we compute the digest, we use pbhash to marshal the protos to json
should we do the same here before calling Compare()?
alternatively, do you mind double checking that jsondiff.Compare() returns no diff for multiple calls comparing 2 identical pb objects that contain maps in the message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can!
I've carefully double checked that jsondiff.Compare()
is an identical operation w.r.t determinism. Also added the test for this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @austin362667 for the super fast turnaround!
in this case, i was more concerned about identical maps not showing a false diff - would you mind double checking that? otherwise PR looks great!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this so awesome, thank you!
Signed-off-by: Austin Liu <austin362667@gmail.com>
Signed-off-by: Austin Liu <austin362667@gmail.com>
Signed-off-by: Austin Liu <austin362667@gmail.com>
Signed-off-by: Austin Liu <austin362667@gmail.com>
Signed-off-by: Austin Liu <austin362667@gmail.com>
Signed-off-by: Austin Liu <austin362667@gmail.com>
Signed-off-by: Austin Liu <austin362667@gmail.com> format Signed-off-by: Austin Liu <austin362667@gmail.com>
Signed-off-by: Austin Liu <austin362667@gmail.com>
Signed-off-by: Austin Liu <austin362667@gmail.com> rollback proto change Signed-off-by: Austin Liu <austin362667@gmail.com>
Signed-off-by: Austin Liu <austin362667@gmail.com>
Signed-off-by: Austin Liu <austin362667@gmail.com>
c6f732d
to
04c34ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Let's merge it when all tests passed
Congrats on merging your first pull request! 🎉 |
Tracking issue
#4762
Why are the changes needed?
To highlight diff, the delta part, of error message for
NewTaskExistsDifferentStructureError()
,NewWorkflowExistsDifferentStructureError()
,NewLaunchPlanExistsDifferentStructureError()
.Usually when user submit two different
task
,workflow
,launchplan
with the same identifier.What changes were proposed in this pull request?
flyteadmin
."wI2L/jsondiff"
go package for computing structural diff.How was this patch tested?
Setup process
project
,domain
,name
,version
.Screenshots
Related PRs
Docs link