Skip to content

Commit

Permalink
Release 1.3 branch fix (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
SheepSheepChen authored Oct 16, 2023
1 parent 2bb5378 commit 9b858a3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
7 changes: 6 additions & 1 deletion apiserver/paasng/paas_wl/workloads/processes/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ def list_processes(env: ModuleEnvironment) -> ProcessesInfo:
else:
try:
release: Release = Release.objects.get_latest(wl_app)
procfile = release.get_procfile()
# 历史遗留问题,release 脏数据符合条件 version = 1 , procfile 为空 ,build 为 None
is_dirty_release = release.version == 1 and not release.procfile and not release.build
if is_dirty_release:
procfile = {}
else:
procfile = release.get_procfile()
except Release.DoesNotExist:
logger.warning("Not any available Release")

Expand Down
4 changes: 2 additions & 2 deletions apiserver/paasng/paasng/dev_resources/sourcectl/git/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ def to_cmd(self, obscure: bool = False) -> List[str]:
class GitClient:
"""Git 客户端"""

VERSION_REGEX = re.compile(r"refs/(?P<type>(remotes/origin|tags))/(?P<name>[{}\w.\-_]+)")
VERSION_REGEX = re.compile(r"refs/(?P<type>(remotes/origin|tags))/(?P<name>[{}\w.\-_/]+)")
COMMIT_INFO_REGEX = re.compile(r"(?P<ts>(\d+))/(?P<msg>[\S\s]*)", re.M)
META_GIT_DIR = ".git"
_git_filepath = "git"
_default_timeout = 30
_default_timeout = 600

def checkout(self, path: Path, target: str) -> str:
"""切换分支或tag"""
Expand Down
8 changes: 8 additions & 0 deletions apiserver/paasng/tests/paas_wl/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,14 @@ def wl_release(wl_app):
)


@pytest.fixture
def wl_dirty_release(wl_app):
return create_wl_release(
wl_app=wl_app,
release_params={"version": 1, "build": None},
)


@pytest.fixture
def build_proc(wl_app) -> BuildProcess:
"""A new BuildProcess object with random info"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ def test_list_processes(bk_stag_env, wl_app, wl_release, mock_reader):
assert list_processes(bk_stag_env).processes == [web_proc, worker_proc]


def test_list_processes_with_dirty_release(bk_stag_env, wl_app, wl_dirty_release, mock_reader):
assert not list_processes(bk_stag_env).processes


def test_list_processes_boundary_case(bk_stag_env, wl_app, wl_release, mock_reader):
mock_reader.set_processes(
# worker 没有实例, 不会被忽略
Expand Down
1 change: 1 addition & 0 deletions apiserver/paasng/tests/sourcectl/git/test_git_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def test_clone(self, client, bare, expected):
],
{"branch": ["develop"], "tag": ["develop", "v20210203"]},
),
(["9n8b7u6y5t refs/remotes/origin/develop/1.2"], {"branch": ["develop/1.2"]}),
],
)
def test_list_refs(self, client, refs, expected):
Expand Down

0 comments on commit 9b858a3

Please sign in to comment.