Skip to content

Added scrubber support to stream and streams types#23

Merged
laverya merged 6 commits intomasterfrom
laverya/ch2742/support-bundle-option-to-scrub-of-sensitive
Oct 31, 2017
Merged

Added scrubber support to stream and streams types#23
laverya merged 6 commits intomasterfrom
laverya/ch2742/support-bundle-option-to-scrub-of-sensitive

Conversation

@laverya
Copy link
Copy Markdown
Contributor

@laverya laverya commented Oct 27, 2017

Moved RawScrubber generator function to plans/util.go

Moved RawScrubber generator function to plans/util.go
@laverya laverya requested review from areed and dexhorthy October 27, 2017 23:49
Comment thread pkg/plugins/docker/planners/logs.go Outdated

scrubber, err := plans.RawScrubber(spec.Config.Scrub)
if err != nil {
err = errors.Wrap(err, "spec for docker.logs has invalid scrubber spec")
Copy link
Copy Markdown
Contributor

@dexhorthy dexhorthy Oct 28, 2017

Choose a reason for hiding this comment

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

I think for errors.Wrap we usually use a present-tense description of the action, e.g. "create scrubber" or "create scrubber for spec %s"

I don't have a good "why", seems to be the convention

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 completely honest, I don't get what a present tense version of that message would be

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.

the errors occurred when trying to create the scrubber by calling plans.RawScrubber, so I think something like create scrubber would be fine.

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.

The entire point for that error message in particular is that it includes 'docker.logs' though, otherwise it's rather hard to figure out which of your 50 specs is causing the issue

Copy link
Copy Markdown
Contributor

@dexhorthy dexhorthy left a comment

Choose a reason for hiding this comment

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

One thing about wrap, but probably meh-ish on that even. :shipit:

Comment thread pkg/plans/stream-source.go Outdated
line := lineScanner.Bytes()
line = task.RawScrubber(line)

// TODO: actually deal with errors besides 'buffer full'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread pkg/plans/stream-source.go Outdated
scrubbedReader, scrubbedWriter := io.Pipe()
go func(readFrom io.Reader, writeTo *io.PipeWriter) {
lineScanner := bufio.NewScanner(readFrom)
byteWriter := bufio.NewWriter(writeTo)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why do the writes need to be buffered?

}

if task.RawScrubber != nil {
scrubbedReader, scrubbedWriter := io.Pipe()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

there might be enough duplicate code here to warrant factoring it out

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.

yeah +1 if it makes sense

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.

And done

@laverya
Copy link
Copy Markdown
Contributor Author

laverya commented Oct 28, 2017

There's evidently some issues with streams not getting passed properly - something for Monday.

@laverya laverya force-pushed the laverya/ch2742/support-bundle-option-to-scrub-of-sensitive branch 4 times, most recently from 77f4448 to 793d533 Compare October 30, 2017 23:31
Comment thread tests/ginkgo/dockertest.go Outdated
args: ["fileThatDoesNotExist"]
container_id: `+containerID)

err := cmd.Generate(
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.

small optimization -- If you are using the tmpdir stuff, you can just use GenerateBundle() helper if you want

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.

oh looks like maybe these tests are duplicated?

Comment thread pkg/plans/util.go Outdated
line = scrubber(line)

// TODO: actually deal with errors besides 'buffer full'
n, _ := writeTo.Write(line)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can you check the error here and do writeTo.CloseWithError if it's non-nil?

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.

Right - no longer using buffio, so I no longer have to have that loop there
And errors are actually significant instead of normal

Comment thread tests/ginkgo/helpers.go
for {
header, err := tr.Next()
if err == io.EOF {
Expect(err).NotTo(HaveOccurred(), "Failed to find "+targetFile+" in support bundle.")
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.

nice. 👍

Comment thread tests/ginkgo/helpers.go Outdated
return container.ID
}

// RemoveDockerContainer removes a docker container by name as cleanup.
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.

super tiny -- this says remove by name but the param is ID

@laverya laverya force-pushed the laverya/ch2742/support-bundle-option-to-scrub-of-sensitive branch 2 times, most recently from 414df43 to 68b56cd Compare October 31, 2017 00:23
stream-source and streams-source  now properly apply filter regexes

Integration tests added for:
Copy file from container
Run command on container
Run command on container (stderr)
Filter file read from container
Filter output of command run on container
@laverya laverya force-pushed the laverya/ch2742/support-bundle-option-to-scrub-of-sensitive branch from 3cffaee to ddb2965 Compare October 31, 2017 00:31
@laverya laverya merged commit a1a66da into master Oct 31, 2017
@laverya laverya deleted the laverya/ch2742/support-bundle-option-to-scrub-of-sensitive branch October 31, 2017 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants