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

blobs: enforce disabled external-io-dir #45858

Merged
merged 2 commits into from
Mar 10, 2020
Merged

Conversation

dt
Copy link
Member

@dt dt commented Mar 8, 2020

The nodelocal cloud storage implementation previously did its own
file IO, and checked for and enforced the ExternalIODirectory, including
checking when it was disabled completely ("").

However after the switch to backing nodelocal with the local-or-remote
blob service, this enforcement now needs to be done in that service,
when it actually goes to do local IO, as it is a per-node decision if
and where to allow IO.

Release note (security update): ensure --external-io-dir=disabled applies to nodelocal upload requests as well.

Release justification: Bug fix.

Separately: add a zero-byte write at the end of upload to ensure any errors in the pipe are flushed (otherwise zero-byte files never saw errors).

@dt dt requested a review from a team as a code owner March 8, 2020 23:05
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@dt dt requested review from ajwerner and knz March 8, 2020 23:08
Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

LGTM but I'd like to see a test that COPY does the right thing now too.

Reviewed 2 of 2 files at r1, 4 of 4 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @dt)


pkg/blobs/local_storage.go, line 58 at r2 (raw file):

func (l *LocalStorage) prependExternalIODir(path string) (string, error) {
	if l == nil {
		return "", errors.Errorf("local file access is disabled")

might be worth defining the error object as a global var so as to enable errors.Is() elsewhere.


pkg/sql/copy_file_upload.go, line 146 at r1 (raw file):

	}

	// Issue a final zero-byte write to ensure we observe any errors in the pipe.

This feels like it could use a test.

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

I would also recommend a Release note (security update): ... which would outline the overall security rules for nodelocal/COPY. That would ensure it lands in the right place in docs.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @dt)

Copy link
Member Author

@dt dt left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @dt, and @knz)


pkg/sql/copy_file_upload.go, line 146 at r1 (raw file):

Previously, knz (kena) wrote…

This feels like it could use a test.

that's what the empty file case is above:

c.Run(fmt.Sprintf("nodelocal upload %s /test/file1.csv", empty))

@knz
Copy link
Contributor

knz commented Mar 8, 2020

Oh I see I had missed that nodelocal upload was implemented using COPY 😅
carry on. LGTM

@dt dt force-pushed the disable-nodelocal branch 2 times, most recently from 6de9f19 to 9d67c71 Compare March 9, 2020 01:35
dt added 2 commits March 10, 2020 13:21
The row processing function in the COPY machine is where we actually
check for some error cases so it is important to call it at least on
the final batch, even if there are no pending rows.

Additional, in the file-upload machine, that function needs to include
a final zero-byte Write to its pipe to ensure there isn’t an error in
that pipe from the reader side that was set since the last call to Write
(which could be never for zero-byte files).

Release note: none.
The `nodelocal` cloud storage implementation previously did its own
file IO, and checked for and enforced the ExternalIODirectory, including
checking when it was disabled completely ("").

However after the switch to backing `nodelocal` with the local-or-remote
blob service, this enforcement now needs to be done in that service,
when it actually goes to do local IO,  as it is a per-node decision if
and where to allow IO.

Release note (security update): ensure --external-io-dir=disabled applies to `nodelocal upload` requests as well.
@dt
Copy link
Member Author

dt commented Mar 10, 2020

bors r=knz

@craig
Copy link
Contributor

craig bot commented Mar 10, 2020

Build failed

@dt
Copy link
Member Author

dt commented Mar 10, 2020

bors r+

@craig
Copy link
Contributor

craig bot commented Mar 10, 2020

Build succeeded

@craig craig bot merged commit f9155f8 into cockroachdb:master Mar 10, 2020
@dt dt deleted the disable-nodelocal branch March 16, 2020 22:12
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.

None yet

3 participants