-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
UPSTREAM: 53606: use deployment pod template if 0 replicas #16379
UPSTREAM: 53606: use deployment pod template if 0 replicas #16379
Conversation
pkg/oc/cli/cmd/debug.go
Outdated
template, err := f.ApproximatePodTemplateForObject(infos[0].Object) | ||
if err != nil && template == nil { | ||
return fmt.Errorf("cannot debug %s: %v", infos[0].Name, err) | ||
var template *kapi.PodTemplateSpec |
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 wouldn't we always use ApproximatePodTemplateForObject for debug?
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.
ApproximatePodTemplateForObject shouldn't wait for pods under DC
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.
With a deployment object, the default case was being hit here, as its type resolved to *extensions.Deployment
. It then got stuck in the call to f.AttachablePodForObject
. I could add a new case to the switch for *extensions.Deployment
with the same logic as the *deployapi.DeploymentConfig
case. wdyt?
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.
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.
There should be an "approximatepodtemplateforobject" for RCs and RSs and Deployments and StatefulSets and Daemonsets upstream that doesn't depend on pods existing. So I would expect to always be using approximate pod template and for it to never block.
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.
Without adding the case for *extensions.Deployment
, current behavior hits the default case in https://github.com/openshift/origin/blob/master/pkg/cmd/util/clientcmd/factory.go#L209. Then AttachablePodForObject
method is called on factory_object_mapping upstream with a timeout of 1 min.
Here is where the blocking seems to be happening.
Another possible solution could be to skip the call to AttachablePodForObject
altogether if there are 0 replicas, and add a new type switch case for *extensions.Deployment
here that just returns t.Spec.Template
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.
Don't call AttachablePodForObject ever. ApproximatePodTemplateforObject should always be used for debug all the way down, and nothing in APTFO should ever wait for a container to start (it doesn't have to). attach requires a running pod, debug does not.
edb4c59
to
a26a37e
Compare
/retest |
1 similar comment
/retest |
Thanks, added |
/retest |
cfcfe3d
to
19c54c2
Compare
/retest |
a63cf37
to
dca2dc3
Compare
/retest |
ping @smarterclayton |
/unassign |
Test case for test-cmd that uses an RC scaled to zero and a DC scaled to zero to prove it works. |
7588e37
to
c547f05
Compare
Thanks, done |
eb8ee57
to
094634d
Compare
|
||
for i := range pods.Items { | ||
pod := &pods.Items[i] | ||
if fallback == nil || pod.CreationTimestamp.Before(fallback.CreationTimestamp) { |
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 wouldn't you return the first pod no matter what, instead of the fallback?
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.
Are you looking for pods newer than the most recent deployment?
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.
@smarterclayton Yeah, this is existing code that I moved from the clientcmd/factory to clientcmd/factory_object_mapping. Can update the logic to just return the first pod if any exists instead, if that is a better approach
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.
Hrm, it's probably fine. I just wasn't sure why it is here. Add a comment to this section that describes the algorithm.
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, done! Will go ahead and open PR for upstream changes
if everything else looks okay
094634d
to
c8f4eb6
Compare
@smarterclayton friendly ping on #16379 (comment) |
e9cf687
to
2463610
Compare
Thanks, done! |
/retest |
…mplate-factory-method Automatic merge from submit-queue (batch tested with PRs 53606, 49361). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. add ApproximatePodTemplateForObject factory method Makes it possible to get at a pod spec template even if an object is scaled to zero, for use with commands that care about pod templates. **Release note**: ```release-note NONE ``` Related downstream patch and use-case: openshift/origin#16379 cc @smarterclayton
@smarterclayton upstream dep has merged, ptal |
2463610
to
b0e827d
Compare
/test extended_conformance_gce |
/test extended_conformance_gce |
/retest |
1 similar comment
/retest |
/test extended_conformance_gce |
b0e827d
to
0598c2d
Compare
/test extended_conformance_gce |
@smarterclayton friendly ping - wondering if you could tag this for merging |
/kind bug |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: juanvallejo, smarterclayton The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
Automatic merge from submit-queue. |
Fixes #14286
Fixes #14915
Prevent
oc debug
from hanging indefinitely when dealingwith a deployment that has been scaled down to 0.
cc @openshift/cli-review @smarterclayton