Skip to content

Commit 40884ae

Browse files
committed
fix(controller) : fix regex for deis limits
1 parent ce4f8c3 commit 40884ae

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

controller/api/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
PROCTYPE_MATCH = re.compile(r'^(?P<type>[a-z]+)')
20-
MEMLIMIT_MATCH = re.compile(r'^(?P<mem>[0-9]+[BbKkMmGg])$')
20+
MEMLIMIT_MATCH = re.compile(r'^(?P<mem>[0-9]+(MB|KB|GB|[BKMG]))$', re.IGNORECASE)
2121
CPUSHARE_MATCH = re.compile(r'^(?P<cpu>[0-9]+)$')
2222
TAGKEY_MATCH = re.compile(r'^[a-z]+$')
2323
TAGVAL_MATCH = re.compile(r'^\w+$')

controller/api/tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ def run_tests(self, test_labels, extra_tests=None, **kwargs):
6060
from .test_release import * # noqa
6161
from .test_scheduler import * # noqa
6262
from .test_users import * # noqa
63+
from .test_limits import * # noqa
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import unittest
2+
import re
3+
4+
5+
MEMLIMIT = re.compile(r'^(?P<mem>[0-9]+(MB|KB|GB|[BKMG]))$', re.IGNORECASE)
6+
7+
8+
class TestLimits(unittest.TestCase):
9+
10+
def test_upper(self):
11+
self.assertTrue(MEMLIMIT.match("20MB"))
12+
self.assertFalse(MEMLIMIT.match("20MK"))
13+
self.assertTrue(MEMLIMIT.match("20gb"))
14+
self.assertFalse(MEMLIMIT.match("20gK"))

tests/limits_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
var (
1313
limitsListCmd = "limits:list --app={{.AppName}}"
14-
limitsSetMemCmd = "limits:set --app={{.AppName}} web=256M"
14+
limitsSetMemCmd = "limits:set --app={{.AppName}} web=256MB"
1515
limitsSetCPUCmd = "limits:set --app={{.AppName}} -c web=512"
1616
limitsUnsetMemCmd = "limits:unset --app={{.AppName}} --memory web"
1717
limitsUnsetCPUCmd = "limits:unset --app={{.AppName}} -c web"

0 commit comments

Comments
 (0)