Skip to content

feat: add host agent version drift flag in privateKey list#4589

Open
leebrouse wants to merge 5 commits intokoderover:mainfrom
leebrouse:feature/agent_vesion_monitor
Open

feat: add host agent version drift flag in privateKey list#4589
leebrouse wants to merge 5 commits intokoderover:mainfrom
leebrouse:feature/agent_vesion_monitor

Conversation

@leebrouse
Copy link
Copy Markdown
Contributor

@leebrouse leebrouse commented Apr 2, 2026

What this PR does / Why we need it:

This PR enables agent version visibility and version drift warning for Host Management.
Previously, the host list API did not provide a direct comparison result between host agent_version and system target version, so the frontend could not reliably show upgrade reminders.

What is changed and how it works?

  • Updated ListPrivateKeys in pkg/microservice/aslan/core/system/service/private_key.go.
  • Added logic to fetch current target agent version from ConfigMap aslan-config key ZADIG_AGENT_VERSION.
  • For each host entry:
    • Keep existing private key encryption behavior.
    • Only when host is in agent mode (key.Agent != nil && key.ScheduleWorkflow):
      • fill agent.zadig_version
      • compute agent.need_update by comparing agent.agent_version vs agent.zadig_version
  • Added version comparison helper:
    • strips v prefix before comparing, to avoid false mismatch (v2.5.1 vs 2.5.1).
  • Result:
    • if versions differ: need_update = true
    • if versions are equal: need_update = false

Does this PR introduce a user-facing change?

  • API change
  • database schema change
  • upgrade assistant change
  • change in non-functional attributes such as efficiency or availability
  • fix of a previous issue

This change is Reviewable

Signed-off-by: YuTang Song <2313186065@qq.com>
func getCurrentZadigAgentVersion() (string, error) {
ns := commonconfig.Namespace()
kubeClient := krkubeclient.Client()
configMap, found, err := getter.GetConfigMap(ns, "aslan-config", kubeClient)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数跟getZadigAgentVersion重复了

Signed-off-by: YuTang Song <2313186065@qq.com>
@leebrouse leebrouse requested a review from PetrusZ April 3, 2026 03:44
func GetZadigAgentVersion() (string, error) {
ns := commonconfig.Namespace()
kubeClient := krkubeclient.Client()
configMap, found, err := getter.GetConfigMap(ns, "aslan-config", kubeClient)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用viper.GetString(setting.ZadigAgentVersion)这种方法,从环境变量里读就行,不需要读configmap,再改一下吧

@github-actions github-actions bot added the common label Apr 3, 2026
if version != "" {
return version, nil
}
version := viper.GetString(setting.ZadigAgentRepoURL)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是version

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下面代码乱了

Signed-off-by: YuTang Song <2313186065@qq.com>
@leebrouse leebrouse requested a review from PetrusZ April 3, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants