kopia lustrzana https://github.com/jupyterhub/repo2docker
Throw error if using --build-memory-limit
rodzic
bd615901cb
commit
34399f8f87
|
@ -140,7 +140,8 @@ def get_argparser():
|
|||
|
||||
argparser.add_argument(
|
||||
"--build-memory-limit",
|
||||
help="Total Memory that can be used by the docker build process",
|
||||
# Removed argument, but we still want to support printing an error message if this is passed
|
||||
help=argparse.SUPPRESS
|
||||
)
|
||||
|
||||
argparser.add_argument(
|
||||
|
@ -434,12 +435,10 @@ def make_r2d(argv=None):
|
|||
sys.exit(1)
|
||||
|
||||
if args.build_memory_limit:
|
||||
# if the string only contains numerals we assume it should be an int
|
||||
# and specifies a size in bytes
|
||||
if args.build_memory_limit.isnumeric():
|
||||
r2d.build_memory_limit = int(args.build_memory_limit)
|
||||
else:
|
||||
r2d.build_memory_limit = args.build_memory_limit
|
||||
# We no longer support build_memory_limit, it must be set in the builder instance
|
||||
print("--build-memory-limit is no longer supported", file=sys.stderr)
|
||||
print("Use `docker buildx create` to create a custom builder with appropriate memory limits instead", file=sys.stderr)
|
||||
sys.exit(-1)
|
||||
|
||||
if args.environment and not r2d.run:
|
||||
print("To specify environment variables, you also need to run " "the container")
|
||||
|
|
|
@ -165,13 +165,20 @@ class Repo2Docker(Application):
|
|||
build_memory_limit = ByteSpecification(
|
||||
0,
|
||||
help="""
|
||||
Total memory that can be used by the docker image building process.
|
||||
Unsupported.
|
||||
|
||||
Set to 0 for no limits.
|
||||
When using docker, please use `docker buildx create` to create a new buildkit
|
||||
builder with appropriate limits instead.
|
||||
""",
|
||||
config=True,
|
||||
)
|
||||
|
||||
@observe("build_memory_limit")
|
||||
def build_memory_limit_changed(self, change):
|
||||
print("Setting build_memory_limit is not supported", file=sys.stderr)
|
||||
print("Use `docker buildx create` to create a custom builder with appropriate memory limits instead", file=sys.stderr)
|
||||
sys.exit(-1)
|
||||
|
||||
volumes = Dict(
|
||||
{},
|
||||
help="""
|
||||
|
@ -856,6 +863,7 @@ class Repo2Docker(Application):
|
|||
for l in picked_buildpack.build(
|
||||
docker_client,
|
||||
self.output_image_spec,
|
||||
# This is deprecated, but passing it anyway to not break backwards compatibility
|
||||
self.build_memory_limit,
|
||||
build_args,
|
||||
self.cache_from,
|
||||
|
|
|
@ -50,11 +50,8 @@ def test_mem_limit():
|
|||
"""
|
||||
Test various ways of passing --build-memory-limit
|
||||
"""
|
||||
r2d = make_r2d(["--build-memory-limit", "1024", "."])
|
||||
assert int(r2d.build_memory_limit) == 1024
|
||||
|
||||
r2d = make_r2d(["--build-memory-limit", "3K", "."])
|
||||
assert int(r2d.build_memory_limit) == 1024 * 3
|
||||
with pytest.raises(SystemExit):
|
||||
r2d = make_r2d(["--build-memory-limit", "1024", "."])
|
||||
|
||||
|
||||
def test_run_required():
|
||||
|
|
Ładowanie…
Reference in New Issue