Skip to content
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

fix(pipelines): Fixed interpretation of missing startTime during inst… #2820

Merged
merged 13 commits into from
Oct 8, 2019
Merged

fix(pipelines): Fixed interpretation of missing startTime during inst… #2820

merged 13 commits into from
Oct 8, 2019

Conversation

ewiseblatt
Copy link

@ewiseblatt ewiseblatt commented Apr 5, 2019

…rumentation

Fixes spinnaker/spinnaker#4244

There are conditions in which CompleteStageHandler can be called without
having a startTime set. Often this is because an exception was thrown
before the startTime was set, but there are various guards within
StartStageHandler as well.

Previously when this happened, a StartTime of 0 was used. This is
particularly bad because the 40-years worth of nanoseconds that is
spit out of spectator is beyond the resolution of "double" for metric
stores that use double for time. This fix changes the assumption
to be the end time, resulting in assuming 0 time. Not that this could
possibly be a different type of issue if the underlying problem was
something else, such as StartStageHandler not even being called for some
reason.

In addition I set the startTime at the beginning of the try block where
exceptions may be thrown in order to ensure there is a startTime when
going through that control flow. I think this might be messy depending
on how time and state are used because it has a startTime but is not in
the RUNNING state. There does not seem to be an appropriate state definition
for this particular phase and am not sure the implications of adding one.
I also dont know if moving the startTime so it includes this extra check
has other implications. If so then the startTime could be reset where it
is currently set.

@robfletcher

@marchello2000
Copy link
Contributor

other than missing stage.status = RUNNING lgtm, I don't think setting startTime earlier will have any consequences and agree with you it would be nice to set startTime somewhere in a generic way that doesn't seem to exist.

@robfletcher correct me if I am wrong

@ewiseblatt
Copy link
Author

ewiseblatt commented Apr 5, 2019 via email

@jtk54
Copy link
Contributor

jtk54 commented Apr 5, 2019

@ewiseblatt I think setting the startTime prior to setting RUNNING is OK since all this state is wrapped in a message that's pushed to the queue.

@ewiseblatt
Copy link
Author

ewiseblatt commented Apr 5, 2019 via email

@robfletcher
Copy link
Contributor

It feels odd to me to not have the state and the startTime set together but it's probably very low impact as that RUNNING state is going to get either set or replaced with TERMINAL in very short order.

…rumentation

Fixes spinnaker/spinnaker#4244

There are conditions in which CompleteStageHandler can be called without
having a startTime set. Often this is because an exception was thrown
before the startTime was set, but there are various guards within
StartStageHandler as well.

Previously when this happened, a StartTime of 0 was used. This is
particularly bad because the 40-years worth of nanoseconds that is
spit out of spectator is beyond the resolution of "double" for metric
stores that use double for time. This fix changes the assumption
to be the end time, resulting in assuming 0 time. Not that this could
possibly be a different type of issue if the underlying problem was
something else, such as StartStageHandler not even being called for some
reason.

In addition I set the startTime at the beginning of the try block where
exceptions may be thrown in order to ensure there is a startTime when
going through that control flow. I think this might be messy depending
on how time and state are used because it has a startTime but is not in
the RUNNING state. There does not seem to be an appropriate state definition
for this particular phase and am not sure the implications of adding one.
I also dont know if moving the startTime so it includes this extra check
has other implications. If so then the startTime could be reset where it
is currently set.
Being in the RUNNING state affected the handler guard checking
for NOT_STARTED (line 71) causing it to be ignored. I dont
really understand the control flow here, and could not follow
along in a debugger because kotlin/mockito jumps all over the
place making it impossible for me to grok that way. I suspect
there is a better fix and could involve adding another status
between NOT_STARTED and RUNNING but that is beyond my level
of intimacy with the model here.

fixed tests to accomodate the second storeStage call.
@ewiseblatt
Copy link
Author

I needed to make a change to satisfy the tests (and fix the cardinality checks in some tests). Please take another look.

stage.withAuth {
stage.plan()
}

stage.status = RUNNING
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's actually better to have this together with stage.startTime as @robfletcher noted. Looking at CompleteStageHandler (https://github.com/spinnaker/orca/blob/master/orca-queue/src/main/kotlin/com/netflix/spinnaker/orca/q/handler/CompleteStageHandler.kt#L56) it seems that it will be harmless. And it will be more accurate

@marchello2000
Copy link
Contributor

@ewiseblatt should we merge this PR?

@cfieber cfieber added the ready to merge Approved and ready for merge label Sep 20, 2019
@robzienert robzienert merged commit e872ce8 into spinnaker:master Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Approved and ready for merge target-release/1.17
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unknown startTime throws off orca stage.invocations.duration Timer
9 participants