mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix: remove metadata server from host (#21278)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -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/hostdeployer/deployclient"
|
||||
"yunion.io/x/onecloud/pkg/hostman/hosthandler"
|
||||
@@ -35,7 +34,6 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/hostman/hostmetrics"
|
||||
"yunion.io/x/onecloud/pkg/hostman/hostutils"
|
||||
"yunion.io/x/onecloud/pkg/hostman/kubehandlers"
|
||||
"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"
|
||||
@@ -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)
|
||||
|
||||
@@ -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",
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user