Skip to content

Commit

Permalink
fix: remove metadata server from host (#21281)
Browse files Browse the repository at this point in the history
Co-authored-by: Qiu Jian <[email protected]>
  • Loading branch information
swordqiu and Qiu Jian authored Sep 21, 2024
1 parent 449c114 commit 8d11c68
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
15 changes: 0 additions & 15 deletions pkg/hostman/host_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"yunion.io/x/onecloud/pkg/hostman/downloader"
"yunion.io/x/onecloud/pkg/hostman/guestfs/fsdriver"
"yunion.io/x/onecloud/pkg/hostman/guestman"
"yunion.io/x/onecloud/pkg/hostman/guestman/desc"
"yunion.io/x/onecloud/pkg/hostman/guestman/guesthandlers"
"yunion.io/x/onecloud/pkg/hostman/guestman/podhandlers"
"yunion.io/x/onecloud/pkg/hostman/hostdeployer/deployclient"
Expand All @@ -35,7 +34,6 @@ import (
"yunion.io/x/onecloud/pkg/hostman/hostinfo/hostpinger"
"yunion.io/x/onecloud/pkg/hostman/hostmetrics"
"yunion.io/x/onecloud/pkg/hostman/hostutils"
"yunion.io/x/onecloud/pkg/hostman/metadata"
"yunion.io/x/onecloud/pkg/hostman/options"
"yunion.io/x/onecloud/pkg/hostman/storageman"
"yunion.io/x/onecloud/pkg/hostman/storageman/diskhandlers"
Expand Down Expand Up @@ -125,19 +123,6 @@ func (host *SHostService) RunService() {

host.initHandlers(app)

// Init Metadata handler
go metadata.Start(
app_common.InitApp(&options.HostOptions.BaseOptions, false),
&metadata.Service{
Address: options.HostOptions.Address,
Port: options.HostOptions.Port + 1000,
DescGetter: metadata.DescGetterFunc(func(ip string) *desc.SGuestDesc {
guestDesc, _ := guestman.GetGuestManager().GetGuestNicDesc("", ip, "", "", false)
return guestDesc
}),
},
)

{
cronManager.AddJobEveryFewDays(
"CleanRecycleDiskFiles", 1, 3, 0, 0, storageman.CleanRecycleDiskfiles, false)
Expand Down
20 changes: 18 additions & 2 deletions pkg/hostman/metadata/metadatahandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ func (s *Service) metaData(ctx context.Context, w http.ResponseWriter, r *http.R
"ami-launch-index",
"block-device-mapping/", "hostname",
"instance-id", "instance-type",
"local-hostname", "local-ipv4", "mac",
"local-hostname",
"local-ipv4",
"local-ipv6",
"mac",
"public-hostname", "public-ipv4",
"network_config/",
"local-sub-ipv4s",
Expand Down Expand Up @@ -173,9 +176,12 @@ func (s *Service) metaData(ctx context.Context, w http.ResponseWriter, r *http.R
return
}
}
case "hostname", "public-hostname", "local-hostname":
case "hostname":
hostutils.Response(ctx, w, guestDesc.Name)
return
case "public-hostname", "local-hostname":
hostutils.Response(ctx, w, guestDesc.Hostname)
return
case "instance-id":
hostutils.Response(ctx, w, guestDesc.Uuid)
return
Expand All @@ -202,6 +208,16 @@ func (s *Service) metaData(ctx context.Context, w http.ResponseWriter, r *http.R
}
hostutils.Response(ctx, w, strings.Join(ips, "\n"))
return
case "local-ipv6":
ips := make([]string, 0)
guestNics := guestDesc.Nics
for _, nic := range guestNics {
if len(nic.Ip6) > 0 {
ips = append(ips, nic.Ip6)
}
}
hostutils.Response(ctx, w, strings.Join(ips, "\n"))
return
case "local-sub-ipv4s":
ips := make([]string, 0)
guestNics := guestDesc.Nics
Expand Down

0 comments on commit 8d11c68

Please sign in to comment.