Skip to content

Commit 34399f8

Browse files
committed
Throw error if using --build-memory-limit
1 parent bd61590 commit 34399f8

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

repo2docker/__main__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ def get_argparser():
140140

141141
argparser.add_argument(
142142
"--build-memory-limit",
143-
help="Total Memory that can be used by the docker build process",
143+
# Removed argument, but we still want to support printing an error message if this is passed
144+
help=argparse.SUPPRESS
144145
)
145146

146147
argparser.add_argument(
@@ -434,12 +435,10 @@ def make_r2d(argv=None):
434435
sys.exit(1)
435436

436437
if args.build_memory_limit:
437-
# if the string only contains numerals we assume it should be an int
438-
# and specifies a size in bytes
439-
if args.build_memory_limit.isnumeric():
440-
r2d.build_memory_limit = int(args.build_memory_limit)
441-
else:
442-
r2d.build_memory_limit = args.build_memory_limit
438+
# We no longer support build_memory_limit, it must be set in the builder instance
439+
print("--build-memory-limit is no longer supported", file=sys.stderr)
440+
print("Use `docker buildx create` to create a custom builder with appropriate memory limits instead", file=sys.stderr)
441+
sys.exit(-1)
443442

444443
if args.environment and not r2d.run:
445444
print("To specify environment variables, you also need to run " "the container")

repo2docker/app.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,20 @@ def _default_log_level(self):
165165
build_memory_limit = ByteSpecification(
166166
0,
167167
help="""
168-
Total memory that can be used by the docker image building process.
168+
Unsupported.
169169
170-
Set to 0 for no limits.
170+
When using docker, please use `docker buildx create` to create a new buildkit
171+
builder with appropriate limits instead.
171172
""",
172173
config=True,
173174
)
174175

176+
@observe("build_memory_limit")
177+
def build_memory_limit_changed(self, change):
178+
print("Setting build_memory_limit is not supported", file=sys.stderr)
179+
print("Use `docker buildx create` to create a custom builder with appropriate memory limits instead", file=sys.stderr)
180+
sys.exit(-1)
181+
175182
volumes = Dict(
176183
{},
177184
help="""
@@ -856,6 +863,7 @@ def build(self):
856863
for l in picked_buildpack.build(
857864
docker_client,
858865
self.output_image_spec,
866+
# This is deprecated, but passing it anyway to not break backwards compatibility
859867
self.build_memory_limit,
860868
build_args,
861869
self.cache_from,

tests/unit/test_args.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@ def test_mem_limit():
5050
"""
5151
Test various ways of passing --build-memory-limit
5252
"""
53-
r2d = make_r2d(["--build-memory-limit", "1024", "."])
54-
assert int(r2d.build_memory_limit) == 1024
55-
56-
r2d = make_r2d(["--build-memory-limit", "3K", "."])
57-
assert int(r2d.build_memory_limit) == 1024 * 3
53+
with pytest.raises(SystemExit):
54+
r2d = make_r2d(["--build-memory-limit", "1024", "."])
5855

5956

6057
def test_run_required():

0 commit comments

Comments
 (0)