Skip to content

Inline deployer hook logs - #5305

Merged
openshift-bot merged 1 commit into
openshift:masterfrom
ironcladlou:inline-hook-pod-logs
Nov 4, 2015
Merged

openshift-bot merged 1 commit into
openshift:masterfrom
ironcladlou:inline-hook-pod-logs

Conversation

@ironcladlou

Copy link
Copy Markdown
Contributor

Implements inline deployer hook pod logs for #5199.

Logs will be streamed from the hook pod to the deployer pod's stdout.

@ironcladlou

Copy link
Copy Markdown
Contributor Author

I'm always getting 0 bytes written to PodLogDestination from the log stream. Still trying to understand why. The logs are present through docker logs for the hook container, and no errors are reported when dealing with the stream.

@ironcladlou

Copy link
Copy Markdown
Contributor Author

Deferring godocs and tests until I can prove this will work.

@ironcladlou

Copy link
Copy Markdown
Contributor Author

One other thing for discussion: should we wrap the destination writer with something that prefixes the log output with something indicating that the output is from another pod?

Comment thread pkg/cmd/infra/deployer/deployer.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why are we switching away from an interface?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As I mention in the description and linked issue: I can't find any other way to get access to the pod log stream. None of the interfaces expose anything helpful for it that I can find. Suggestions?

Also, I don't necessarily think using the concrete client for initialization code (constructors) called only by other initialization code is a bad thing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if it's to plumb what's needed for logging, can we take a second arg which is an interface with all the required info instead (namespace, name, and PodLogOptions)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To be clear, if there was some interface to pod log streams, I'd certainly use it...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

requiring concrete client implementations (even in constructors) hamstrings us from ever building a joint client, or a client wrapper, etc

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@smarterclayton? I don't have a feel for the effort involved in exposing pod logs through the k8s client interface. Aware of any work in this area?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it can be a second arg to the constructor, just make up your own interface here (I think namespace, name, and PodLogOptions are the only required input), and make an implementation which uses an internal *kclient.Client and pass it in

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see what you mean. Good idea. Nevermind, @smarterclayton.

@ironcladlou
ironcladlou force-pushed the inline-hook-pod-logs branch 5 times, most recently from 573b6d8 to 0c090c0 Compare October 22, 2015 15:43
@openshift-bot openshift-bot removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 22, 2015
@ironcladlou ironcladlou changed the title WIP: Inline deployer hook logs Inline deployer hook logs Oct 23, 2015
@ironcladlou

Copy link
Copy Markdown
Contributor Author

@Kargakis @smarterclayton this is ready for review.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This belongs in its own method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Extracted method

@smarterclayton

Copy link
Copy Markdown
Contributor

Needs an e2e test.

@ironcladlou

Copy link
Copy Markdown
Contributor Author

@smarterclayton

Needs an e2e test.

The e2e tests already use a deployment config with both pre and post hooks which would exercise the log reading from a regression perspective... the most important thing I want verified is that the log reading goroutine won't block unexpectedly and cause the hook execution to stall the deployment, which the existing fixtures should cover.

Did you have something else in mind for a specific scenario?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since we are going to wait for the logs to be consumed, do we really need goroutines and all the sync machinery?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We're not necessarily waiting for the logs to be consumed, we're waiting for our attempt to consume the logs to be completed. There's no use asking for the logs until the pod's in a phase where the server will return them, and even though the pod was observed to be in a log-readable phase, by the time we ask for the stream, the master might return an error or a broken stream anyway. We also need to block until the pod is terminal anyway: an end of the log stream doesn't necessarily mean the pod has reached a terminal phase. It doesn't seem good to ignore the phase updates while blocking synchronously on log streaming.

If you have another algorithm to propose, describe it here and we'll discuss.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

At start I thought there would be no difference between what I was thinking and what you have here (it would just be a simpler impl) but you start returning the logs if the pod is observed as running and that's something that would still need another goroutine in my implementation. So I guess this is fine with me.

@0xmichalis

Copy link
Copy Markdown
Contributor

Code LGTM. I am going to pull the branch and test it.

@0xmichalis

Copy link
Copy Markdown
Contributor

Finally got to rebuild and test this. Works like a charm. We may want to add timestamps by default to the pod hook logs? @ironcladlou

Squash and this is LGTM

@ironcladlou

Copy link
Copy Markdown
Contributor Author

Finally got to rebuild and test this. Works like a charm. We may want to add timestamps by default to the pod hook logs? @ironcladlou

I'm not sure if I want to introduce the complexity of a io.Reader wrapper for this yet (unless you know of some super simple way I'm not thinking of.)

I can also see an argument that if we provide clear lines of demarcation (hook pods begin here/end here) and then print logs verbatim, the hook logs can be more reliably read by other tools without having to strip out our added line prefixes (what if the hook pod logs with its own timestamps, etc.)

Maybe let's discuss that in a followup if there's demand?

@0xmichalis

Copy link
Copy Markdown
Contributor

Adding timestamps is as simple as adding true to PodLogOptions.Timestamps.

@0xmichalis

Copy link
Copy Markdown
Contributor

I don't feel strongly though.. I just didn't enjoy seeing my echo w/o one:)

@ironcladlou

Copy link
Copy Markdown
Contributor Author

Sweet, let's do that. After I wrote my paragraph I also realized it would be easier to parse out "hook logs" if we added a known prefix, but I still don't really want to wrap the reader right now.

@ironcladlou

Copy link
Copy Markdown
Contributor Author

In this case it's head closing the pipe, but that doesn't explain why it works w/ a sleep before the command, and why the grep-ing and head-ing all over the place doesn't fail for the same reason.

@ironcladlou

Copy link
Copy Markdown
Contributor Author

Asset failure, [test]

@smarterclayton

Copy link
Copy Markdown
Contributor

Only -q fails. Don't use -q

On Tue, Nov 3, 2015 at 1:25 PM, Dan Mace [email protected] wrote:

Asset failure, [test]

—
Reply to this email directly or view it on GitHub
#5305 (comment).

@ironcladlou

Copy link
Copy Markdown
Contributor Author

There is no -q. The line that's failing is:

POD_NAME=`oc get pods -o name -n test | head -n 1`

The question is why does this fix it:

sleep 10
POD_NAME=`oc get pods -o name -n test | head -n 1`

@smarterclayton

Copy link
Copy Markdown
Contributor

Head may have the same behavior.

On Tue, Nov 3, 2015 at 1:29 PM, Dan Mace [email protected] wrote:

There is no -q. The line that's failing is:

POD_NAME=oc get pods -o name -n test | head -n 1

The question is why does this fix it:

sleep 10
POD_NAME=oc get pods -o name -n test | head -n 1

—
Reply to this email directly or view it on GitHub
#5305 (comment).

@smarterclayton

Copy link
Copy Markdown
Contributor

$ seq 1 10000 | head -11

$ echo ${PIPESTATUS[@]}141 0

On Tue, Nov 3, 2015 at 1:33 PM, Clayton Coleman [email protected] wrote:

Head may have the same behavior.

On Tue, Nov 3, 2015 at 1:29 PM, Dan Mace [email protected] wrote:

There is no -q. The line that's failing is:

POD_NAME=oc get pods -o name -n test | head -n 1

The question is why does this fix it:

sleep 10
POD_NAME=oc get pods -o name -n test | head -n 1

—
Reply to this email directly or view it on GitHub
#5305 (comment).

@ironcladlou

Copy link
Copy Markdown
Contributor Author

I realize that head is also susceptible. What I'm still not seeing any explanation for is why a sleep before executing the piped command consistently fixes it.

@smarterclayton

Copy link
Copy Markdown
Contributor

There are less pods or exactly one pod?

On Tue, Nov 3, 2015 at 1:34 PM, Dan Mace [email protected] wrote:

I realize that head is also susceptible. What I'm still not seeing any
explanation for is why a sleep before executing the piped command
consistently fixes it.

—
Reply to this email directly or view it on GitHub
#5305 (comment).

@ironcladlou

Copy link
Copy Markdown
Contributor Author

There are less pods or exactly one pod?

I have output demonstrating that when the pipe failure occurs, the client got a full PodList/200 OK. It's never failing due to a lack of pods returned from the oc get.

@smarterclayton

Copy link
Copy Markdown
Contributor

The PIPEFAIL is due to the amount of lines - if the buffer still has
content when the pipe is written. So it depends almost entirely on the
size of the buffer and the amount of content written. How many pods are
returned after 10s

On Tue, Nov 3, 2015 at 1:36 PM, Dan Mace [email protected] wrote:

There are less pods or exactly one pod?

I have output demonstrating that when the pipe failure occurs, the client
got a full PodList/200 OK. It's never failing due to a lack of pods
returned from the oc get.

—
Reply to this email directly or view it on GitHub
#5305 (comment).

@ironcladlou

Copy link
Copy Markdown
Contributor Author

The PIPEFAIL is due to the amount of lines - if the buffer still has content when the pipe is written. So it depends almost entirely on the size of the buffer and the amount of content written. How many pods are returned after 10s

That makes sense... double wow. Nice research

@ironcladlou

Copy link
Copy Markdown
Contributor Author

Followup: why isn't this broken for everybody else?

@ironcladlou

Copy link
Copy Markdown
Contributor Author

Replaced piped calls to head with oc ... --template and now it's stable. Thanks @smarterclayton!

@ironcladlou

Copy link
Copy Markdown
Contributor Author

I've got a local make test running for this... will update with results.

Inline deployer hook logs into the deployer strategy pod output. This
is useful for debugging hook pods, which are prone to being GC'd before
users can get to the logs.
@ironcladlou

Copy link
Copy Markdown
Contributor Author

TestRouterPathSpecificity and TestRouterDuplications flaked (?) locally. No more time tonight for more runs.

@smarterclayton

Copy link
Copy Markdown
Contributor

Can you paste errors?

On Nov 3, 2015, at 8:11 PM, Dan Mace [email protected] wrote:

TestRouterPathSpecificity and TestRouterDuplications flaked (?) locally. No
more time tonight for more runs.

—
Reply to this email directly or view it on GitHub
#5305 (comment).

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to 630fa13

@openshift-bot

Copy link
Copy Markdown
Contributor

@smarterclayton smarterclayton added this to the 1.1.0 milestone Nov 4, 2015
@smarterclayton smarterclayton added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 4, 2015
@smarterclayton

Copy link
Copy Markdown
Contributor

[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin/6859/) (Image: devenv-rhel7_2638)

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to 630fa13

openshift-bot pushed a commit that referenced this pull request Nov 4, 2015
@openshift-bot
openshift-bot merged commit d85fa7a into openshift:master Nov 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants