-
Notifications
You must be signed in to change notification settings - Fork 101
Determine app readiness based on deployment spec.Replicas rather than status.Replicas #1589
Conversation
… status.Replicas Signed-off-by: Grant Linville <grant@acorn.io>
@@ -481,7 +481,11 @@ func AppStatus(req router.Request, resp router.Response) error { | |||
|
|||
status := container[containerName] | |||
status.Ready = dep.Status.ReadyReplicas | |||
status.ReadyDesired = dep.Status.Replicas | |||
if dep.Spec.Replicas != nil { |
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.
Hmm this should be dep.status.Replica?
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.
No, the status.Replicas
has the possibility to be 0 (not set) if something goes wrong. spec.Replicas
is a pointer so I have to do the nil check first before proceeding.
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.
But dep.spec.replicas will never be the replica that is ready? It is the desired replica for a deployment, not the ready replica that we are supposed to set on app.status.
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.
oh wait, this is ReadyDesired
.... yeah setting spec.replica makes sense...
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
(tangent: It would be nice to factor transition logic out s.t. it's easier to write unit tests for changes like this)
Signed-off-by: Grant Linville <grant@acorn.io>
Before this change, we were checking for app readiness by ensuring that the app's Deployment had matching
status.Replicas
andstatus.ReadyReplicas
. If for some reason the Deployment fails to create any replicas (such as a mutating webhook that fails, if Istiod is down for example), then bothstatus.Replicas
andstatus.ReadyReplicas
are set to 0, and Acorn thinks the app is ready even though it is not running at all.With this change, we look at the Deployment spec instead to see the desired number of replicas.
Checklist
This is a title (#1216)
. Here's an example