-
-
Notifications
You must be signed in to change notification settings - Fork 627
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix use of remote store when in eager cache mode (#11468)
### Problem As described in #11455, in remote cache mode with eager fetching, the only accesses to the remote CAS should be through the remote cache code; the remainder of the Pants code base should only see the local store. Intrinsics, such as download_file_to_digest, still have access to the remote CAS currently, which means that any issues with the remote CAS will cause an error instead of being a warning if the access to the remote CAS had occurred through the remote cache code. The intended behavior is for all problems with the remote CAS to be warnings when in remote cache mode. ### Solution In remote cache mode with eager fetching, only expose the local store to most of the Pants code base. ### Result Added an integration test to test that warnings are generated in remote cache mode. Fixes #11455
- Loading branch information
Tom Dyas
committed
Jan 15, 2021
1 parent
2dc94ca
commit c2065ea
Showing
10 changed files
with
147 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use std::sync::Arc; | ||
|
||
use super::PyExecutor; | ||
use cpython::{exc, py_class, PyErr, PyObject, PyResult, PyString}; | ||
use parking_lot::Mutex; | ||
use testutil_mock::{StubCAS, StubCASBuilder}; | ||
|
||
py_class!(pub class PyStubCASBuilder |py| { | ||
data builder: Arc<Mutex<Option<StubCASBuilder>>>; | ||
|
||
def always_errors(&self) -> PyResult<PyObject> { | ||
let mut builder_opt = self.builder(py).lock(); | ||
let builder = builder_opt | ||
.take() | ||
.ok_or_else(|| PyErr::new::<exc::Exception, _>(py, (PyString::new(py, "unable to unwrap StubCASBuilder"),)))? | ||
.always_errors(); | ||
*builder_opt = Some(builder); | ||
Ok(py.None()) | ||
} | ||
|
||
def build(&self, executor: PyExecutor) -> PyResult<PyStubCAS> { | ||
let executor = executor.executor(py); | ||
executor.enter(|| { | ||
let mut builder_opt = self.builder(py).lock(); | ||
let builder = builder_opt | ||
.take() | ||
.ok_or_else(|| PyErr::new::<exc::Exception, _>(py, (PyString::new(py, "unable to unwrap StubCASBuilder"),)))?; | ||
let cas = builder.build(); | ||
PyStubCAS::create_instance(py, cas) | ||
}) | ||
} | ||
}); | ||
|
||
py_class!(pub class PyStubCAS |py| { | ||
data server: StubCAS; | ||
|
||
@classmethod | ||
def builder(cls) -> PyResult<PyStubCASBuilder> { | ||
let builder = StubCAS::builder(); | ||
PyStubCASBuilder::create_instance(py, Arc::new(Mutex::new(Some(builder)))) | ||
} | ||
|
||
def address(&self) -> PyResult<PyString> { | ||
let server = self.server(py); | ||
let address = server.address(); | ||
Ok(PyString::new(py, &address)) | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
tests/python/pants_test/integration/remote_cache_integration_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
import re | ||
|
||
from pants.engine.internals.native_engine import PyExecutor, PyStubCAS | ||
from pants.option.scope import GLOBAL_SCOPE_CONFIG_SECTION | ||
from pants.testutil.pants_integration_test import run_pants | ||
|
||
|
||
def test_warns_on_remote_cache_errors(): | ||
executor = PyExecutor(2, 4) | ||
builder = PyStubCAS.builder() | ||
builder.always_errors() | ||
cas = builder.build(executor) | ||
address = cas.address() | ||
|
||
pants_run = run_pants( | ||
[ | ||
"--backend-packages=['pants.backend.python']", | ||
"--no-dynamic-ui", | ||
"--level=info", | ||
"package", | ||
"testprojects/src/python/hello/main:main", | ||
], | ||
use_pantsd=False, | ||
config={ | ||
GLOBAL_SCOPE_CONFIG_SECTION: { | ||
"remote_cache_read": True, | ||
"remote_cache_write": True, | ||
"remote_store_server": address, | ||
} | ||
}, | ||
) | ||
|
||
pants_run.assert_success() | ||
assert "Failed to read from remote cache: Unimplemented" in pants_run.stderr | ||
assert ( | ||
re.search( | ||
"Failed to write to remote cache:.*StubCAS is configured to always fail", | ||
pants_run.stderr, | ||
re.MULTILINE, | ||
) | ||
is not None | ||
) |