Garbage-collect host-data resources after Kubernetes Nodes are deleted

未关闭
#963 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
go, kubernetes

调研方向

从 CRDClient.CreateOrUpdateHostData 和 host-sensor manager 开始,追踪 host-data resources 的创建和管理方式。然后检查 controller 端的 Node 处理逻辑和现有测试,为已删除的 Nodes、为空或失败的 Node 列表以及存在的 Node 添加覆盖。完成的标准是:仅针对缺失的 Nodes 删除过期资源,并且在列表错误或结果为空时,清理以 fail closed 方式处理。

由索引模型根据 Issue 内容生成。

描述

What happened?

Host-data custom resources created by the node agent remain after their Kubernetes Node is deleted. On clusters with node autoscaling, each scale-up creates another set of cluster-scoped resources and the stale objects accumulate indefinitely.

Why it happens

CRDClient.CreateOrUpdateHostData names each resource after the node but sets no owner reference. The host-sensor manager has no node-deletion watcher or shutdown cleanup, so nothing removes resources when a Node disappears.

This affects the resources in hostdata.kubescape.cloud, including OS release, kernel, kubelet, CNI, open-port, security-hardening, control-plane, cloud-provider, and kernel-variable data.

Requested behavior

Please garbage-collect host-data resources whose named Kubernetes Node no longer exists. Cleanup should fail closed when the Node list cannot be read or is empty, and should not remove data for a present Node.

A controller-side Node deletion watcher is likely more reliable than pod shutdown cleanup because an autoscaled node can disappear without giving its node-agent pod a clean shutdown window. Tests should cover node deletion, transient Node-list failure, and a present node.

Versions checked
  • node-agent v0.3.142
  • current main as of 2026-09-08
主要语言
Go
星标
39
派生
42
平均合并
1 天 18 小时
30 天内合并 PR
40

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

kubescape/node-agent 的其他 Issue

查看 kubescape/node-agent 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。