Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: no matches found for kind=DomainGroupMapping and preferred=True #1466

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apiserver/paasng/paas_wl/bk_app/cnative/specs/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def deploy_networking(env: ModuleEnvironment) -> None:
mapping = AddrResourceManager(env).build_mapping()
wl_app = WlApp.objects.get(pk=env.engine_app_id)
with get_client_by_app(wl_app) as client:
# 需要指定 api_version, 因为 DomainGroupMapping 只有 v1alpha1 版本
crd.DomainGroupMapping(client, api_version=ApiVersion.V1ALPHA1).create_or_update(
mapping.metadata.name,
namespace=wl_app.namespace,
Expand Down Expand Up @@ -149,7 +150,10 @@ def delete_networking(env: ModuleEnvironment):
mapping = AddrResourceManager(env).build_mapping()
wl_app = env.wl_app
with get_client_by_app(wl_app) as client:
crd.DomainGroupMapping(client).delete(mapping.metadata.name, namespace=wl_app.namespace)
# 需要指定 api_version, 因为 DomainGroupMapping 只有 v1alpha1 版本
crd.DomainGroupMapping(client, api_version=ApiVersion.V1ALPHA1).delete(
mapping.metadata.name, namespace=wl_app.namespace
)


@define
Expand Down
3 changes: 1 addition & 2 deletions apiserver/paasng/paas_wl/infras/resources/base/kres.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,8 @@ def delete(
request_kwargs.update(grace_period_seconds=grace_period_seconds)
body.grace_period_seconds = grace_period_seconds

resource = self.kres.dynamic_client.get_preferred_resource(self.kres.kind)
jamesgetx marked this conversation as resolved.
Show resolved Hide resolved
try:
resource.delete(name=name, body=cattr.unstructure(body), namespace=namespace, **request_kwargs)
self.resource.delete(name=name, body=cattr.unstructure(body), namespace=namespace, **request_kwargs)
except ApiException as e:
if e.status == 404:
if raise_if_non_exists:
Expand Down