-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
added validation checks for the werft API #9064
Conversation
2caaedc
to
174a93f
Compare
2476559
to
80de070
Compare
3ce536e
to
3d51b8a
Compare
dee0df7
to
66c200b
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.
Nice improvements, looking forward to making slices and phases more consistent 🙂
I've made one first review round and found a couple of things that look a bit confusing. If others could also provide some feedback here, that would be awesome
werft.done("job config"); | ||
werft.done(sliceId) |
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 super weird to see two slices being closed together at the moment 🤔
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 could be avoided if the above code would use sliceId
for logging instead of "job config".
.werft/util/werft.ts
Outdated
// Create a new slice entry that is already closed if no prior entry exists | ||
if (!this.phases[this.currentPhase].slices[slice]) { | ||
this.phases[this.currentPhase].slices[slice] = { "closed": true }; | ||
} else if (this.phases[this.currentPhase].slices[slice].closed) { | ||
throw new Error(`The slice "${slice}" has already been closed!`); | ||
} else { | ||
this.phases[this.currentPhase].slices[slice].closed = true; | ||
} |
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.
could this be split into a separated method?
I'm still struggling to understand what is the goal 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.
It does happen that a new slice is opened with werft.done()
. This should make sure that a slice is registered although it is closed directly and that a slice is not closed multiple times. Another way would be to enforce opening a new slice with werft.slice(<NAME>)
.
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.
werft.done()
opens a new slice? That doesn't seem right... I expect that a slice is only opened once we log something, or am I missing something here? 🤔
A good thing about splitting this into a new method is that we can keep methods small, and also give names to them. If we can't give a good name to a method, it probably means that it is too complex and could be made simpler 😅
I can still see missing traces [1]. I take a deeper look and work on ending phases explicitly. |
.werft/util/werft.ts
Outdated
private globalSpanAttributes: SpanAttributes = {} | ||
|
||
public phases: { [name: string]: { "span": Span, "closed": boolean, "slices": { [name: string]: { "closed": boolean, "span": Span } } } } = {} |
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 you introduce a Type for this datastructure?
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 can do that. I have already proposed that in the issue [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 created a light version of my datastructures for phases and slices to solve this.
span.end() | ||
delete this.sliceSpans[id] | ||
}) | ||
public endPhase(name?: string) { |
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.
What's the use case for supporting name
as a parameter?
It seems wrong because if I'm not mistaken only on phase can be open at a given time. This implies that this.currentPhase
is always the phase that's being closed.
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.
Adding the name explicitly would make the code more readable and to which phase the current code belongs.
That is the reason why we moved from an error that breaks the deployment process to a warning [1]. |
3d61060
to
1e39a70
Compare
Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com>
1e39a70
to
cf90a0b
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Description
This adds some validation test to the werft.ts API.
UPDATE (2022-04-06): This is also fixing #9100 by ending phases explicitly. I made it optional adding the name of the phase to end it.
Related Issue(s)
Fixes #8707 #9100
How to test
You can test the changes by violating a check that has been implemented by this commit.
Here are some examples:
This commit does not have any problems: https://werft.gitpod-dev.com/job/gitpod-build-wth-test.174/raw
This commit does not close all slices: https://werft.gitpod-dev.com/job/gitpod-build-wth-test.175/raw
This commit adds a log entry when the slice has already been closed: https://werft.gitpod-dev.com/job/gitpod-build-wth-test.176/raw
This commit creates a phase that has already been created: https://werft.gitpod-dev.com/job/gitpod-build-wth-test.178/raw
Release Notes
Documentation