Skip to content

Commit 4864483

Browse files
committed
fix: list hosts
Signed-off-by: BruceAko <chongzhi@hust.edu.cn>
1 parent b9cf420 commit 4864483

File tree

6 files changed

+91
-87
lines changed

6 files changed

+91
-87
lines changed

.github/workflows/e2e-v2.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ permissions:
1616
env:
1717
KIND_VERSION: v0.12.0
1818
CONTAINERD_VERSION: v1.5.2
19-
KIND_CONFIG_PATH: test/testdata/kind/config-v2.yaml
19+
KIND_CONFIG_PATH: test/testdata/kind/config-v2-nydus.yaml
2020
DRAGONFLY_CHARTS_PATH: deploy/helm-charts/charts/dragonfly
2121
DRAGONFLY_FILE_SERVER_PATH: test/testdata/k8s/file-server.yaml
2222

@@ -113,10 +113,6 @@ jobs:
113113
config: ${{ env.KIND_CONFIG_PATH }}
114114
cluster_name: kind
115115

116-
- name: Add taint to node
117-
run: |
118-
kubectl taint nodes kind-worker2 key=value:NoSchedule
119-
120116
- name: Setup dragonfly
121117
run: |
122118
helm install --wait --timeout 15m --dependency-update --create-namespace --namespace dragonfly-system -f ${{ matrix.charts-config }} dragonfly ${{ env.DRAGONFLY_CHARTS_PATH }}

scheduler/service/service_v2.go

Lines changed: 82 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package service
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
2223
"io"
2324
"time"
@@ -701,80 +702,87 @@ func (v *V2) AnnounceHost(ctx context.Context, req *schedulerv2.AnnounceHostRequ
701702

702703
// ListHosts lists hosts in scheduler.
703704
func (v *V2) ListHosts(ctx context.Context) (*schedulerv2.ListHostsResponse, error) {
704-
hosts := v.resource.HostManager().LoadAll()
705-
706-
resHosts := make([]*commonv2.Host, len(hosts))
707-
for i, host := range hosts {
708-
resHosts[i] = &commonv2.Host{
709-
Id: host.ID,
710-
Type: uint32(host.Type),
711-
Hostname: host.Hostname,
712-
Ip: host.IP,
713-
Port: host.Port,
714-
DownloadPort: host.DownloadPort,
715-
Os: host.OS,
716-
Platform: host.Platform,
717-
PlatformFamily: host.PlatformFamily,
718-
PlatformVersion: host.PlatformVersion,
719-
KernelVersion: host.KernelVersion,
720-
Cpu: &commonv2.CPU{
721-
LogicalCount: host.CPU.LogicalCount,
722-
PhysicalCount: host.CPU.PhysicalCount,
723-
Percent: host.CPU.Percent,
724-
ProcessPercent: host.CPU.ProcessPercent,
725-
Times: &commonv2.CPUTimes{
726-
User: host.CPU.Times.User,
727-
System: host.CPU.Times.System,
728-
Idle: host.CPU.Times.Idle,
729-
Nice: host.CPU.Times.Nice,
730-
Iowait: host.CPU.Times.Iowait,
731-
Irq: host.CPU.Times.Irq,
732-
Softirq: host.CPU.Times.Softirq,
733-
Steal: host.CPU.Times.Steal,
734-
Guest: host.CPU.Times.Guest,
735-
GuestNice: host.CPU.Times.GuestNice,
736-
},
737-
},
738-
Memory: &commonv2.Memory{
739-
Total: host.Memory.Total,
740-
Available: host.Memory.Available,
741-
Used: host.Memory.Used,
742-
UsedPercent: host.Memory.UsedPercent,
743-
ProcessUsedPercent: host.Memory.ProcessUsedPercent,
744-
Free: host.Memory.Free,
745-
},
746-
Network: &commonv2.Network{
747-
TcpConnectionCount: host.Network.TCPConnectionCount,
748-
UploadTcpConnectionCount: host.Network.UploadTCPConnectionCount,
749-
Location: &host.Network.Location,
750-
Idc: &host.Network.IDC,
751-
},
752-
Disk: &commonv2.Disk{
753-
Total: host.Disk.Total,
754-
Free: host.Disk.Free,
755-
Used: host.Disk.Used,
756-
UsedPercent: host.Disk.UsedPercent,
757-
InodesTotal: host.Disk.InodesTotal,
758-
InodesUsed: host.Disk.InodesUsed,
759-
InodesFree: host.Disk.InodesFree,
760-
InodesUsedPercent: host.Disk.InodesUsedPercent,
761-
},
762-
Build: &commonv2.Build{
763-
GitVersion: host.Build.GitVersion,
764-
GitCommit: &host.Build.GitCommit,
765-
GoVersion: &host.Build.GoVersion,
766-
Platform: &host.Build.Platform,
767-
},
768-
SchedulerClusterId: host.SchedulerClusterID,
769-
DisableShared: host.DisableShared,
770-
}
771-
}
772-
773-
resp := &schedulerv2.ListHostsResponse{
774-
Hosts: resHosts,
775-
}
776-
777-
return resp, nil
705+
return nil, errors.New("not implemented")
706+
//hosts := v.resource.HostManager().LoadAll()
707+
//
708+
////resHosts := make([]*commonv2.Host, len(hosts))
709+
////for i, host := range hosts {
710+
//// resHosts[i] = &commonv2.Host{
711+
//// Id: host.ID,
712+
//// Type: uint32(host.Type),
713+
//// Hostname: host.Hostname,
714+
//// Ip: host.IP,
715+
//// Port: host.Port,
716+
//// DownloadPort: host.DownloadPort,
717+
//// Os: host.OS,
718+
//// Platform: host.Platform,
719+
//// PlatformFamily: host.PlatformFamily,
720+
//// PlatformVersion: host.PlatformVersion,
721+
//// KernelVersion: host.KernelVersion,
722+
//// Cpu: &commonv2.CPU{
723+
//// LogicalCount: host.CPU.LogicalCount,
724+
//// PhysicalCount: host.CPU.PhysicalCount,
725+
//// Percent: host.CPU.Percent,
726+
//// ProcessPercent: host.CPU.ProcessPercent,
727+
//// Times: &commonv2.CPUTimes{
728+
//// User: host.CPU.Times.User,
729+
//// System: host.CPU.Times.System,
730+
//// Idle: host.CPU.Times.Idle,
731+
//// Nice: host.CPU.Times.Nice,
732+
//// Iowait: host.CPU.Times.Iowait,
733+
//// Irq: host.CPU.Times.Irq,
734+
//// Softirq: host.CPU.Times.Softirq,
735+
//// Steal: host.CPU.Times.Steal,
736+
//// Guest: host.CPU.Times.Guest,
737+
//// GuestNice: host.CPU.Times.GuestNice,
738+
//// },
739+
//// },
740+
//// Memory: &commonv2.Memory{
741+
//// Total: host.Memory.Total,
742+
//// Available: host.Memory.Available,
743+
//// Used: host.Memory.Used,
744+
//// UsedPercent: host.Memory.UsedPercent,
745+
//// ProcessUsedPercent: host.Memory.ProcessUsedPercent,
746+
//// Free: host.Memory.Free,
747+
//// },
748+
//// Network: &commonv2.Network{
749+
//// TcpConnectionCount: host.Network.TCPConnectionCount,
750+
//// UploadTcpConnectionCount: host.Network.UploadTCPConnectionCount,
751+
//// Location: &host.Network.Location,
752+
//// Idc: &host.Network.IDC,
753+
//// },
754+
//// Disk: &commonv2.Disk{
755+
//// Total: host.Disk.Total,
756+
//// Free: host.Disk.Free,
757+
//// Used: host.Disk.Used,
758+
//// UsedPercent: host.Disk.UsedPercent,
759+
//// InodesTotal: host.Disk.InodesTotal,
760+
//// InodesUsed: host.Disk.InodesUsed,
761+
//// InodesFree: host.Disk.InodesFree,
762+
//// InodesUsedPercent: host.Disk.InodesUsedPercent,
763+
//// },
764+
//// Build: &commonv2.Build{
765+
//// GitVersion: host.Build.GitVersion,
766+
//// GitCommit: &host.Build.GitCommit,
767+
//// GoVersion: &host.Build.GoVersion,
768+
//// Platform: &host.Build.Platform,
769+
//// },
770+
//// SchedulerClusterId: host.SchedulerClusterID,
771+
//// DisableShared: host.DisableShared,
772+
//// }
773+
////}
774+
//resHosts := []*commonv2.Host{
775+
// &commonv2.Host{
776+
// Id: "我自己添加的",
777+
// Type: uint32(len(hosts)),
778+
// },
779+
//}
780+
//
781+
//resp := &schedulerv2.ListHostsResponse{
782+
// Hosts: resHosts,
783+
//}
784+
//
785+
//return resp, nil
778786
}
779787

780788
// DeleteHost releases host in scheduler.

test/e2e/v2/leave_host_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ var _ = Describe("Clients go offline normally and abnormally", func() {
5252
}
5353

5454
grpcCredentials := insecure.NewCredentials()
55-
schedulerClient, err := schedulerclient.GetV2ByAddr(context.Background(), ":8002", grpc.WithTransportCredentials(grpcCredentials))
55+
schedulerClient, err := schedulerclient.GetV2ByAddr(context.Background(), "127.0.0.1:8004", grpc.WithTransportCredentials(grpcCredentials))
5656
Expect(err).NotTo(HaveOccurred())
5757

5858
time.Sleep(3 * time.Minute)
5959
hostCount := util.Servers[util.SeedClientServerName].Replicas + util.Servers[util.ClientServerName].Replicas
6060
fmt.Println("hostCount:", hostCount, getHostCountFromScheduler(schedulerClient))
6161
//Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount))
6262

63-
podName, err := util.GetClientPodName(1)
63+
podName, err := util.GetClientPodName(0)
6464
Expect(err).NotTo(HaveOccurred())
6565

6666
out, err := util.KubeCtlCommand("-n", util.DragonflyNamespace, "delete", "pod", podName).CombinedOutput()
@@ -69,7 +69,7 @@ var _ = Describe("Clients go offline normally and abnormally", func() {
6969
fmt.Println("hostCount:", hostCount, getHostCountFromScheduler(schedulerClient))
7070
//Expect(getHostCountFromScheduler(schedulerClient)).To(Equal(hostCount))
7171

72-
podName, err = util.GetClientPodName(1)
72+
podName, err = util.GetClientPodName(0)
7373
Expect(err).NotTo(HaveOccurred())
7474

7575
out, err = util.KubeCtlCommand("-n", util.DragonflyNamespace, "delete", "pod", podName, "--force", "--grace-period=0").CombinedOutput()

test/testdata/charts/config-v2.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ scheduler:
4545
memory: "4Gi"
4646
service:
4747
type: NodePort
48-
nodePort: 30802
48+
nodePort: 30804
4949
extraVolumeMounts:
5050
- name: logs
5151
mountPath: "/var/log/"

test/testdata/kind/config-v2-nydus.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ nodes:
1212
- containerPort: 4003
1313
hostPort: 4003
1414
protocol: TCP
15-
- containerPort: 30802
16-
hostPort: 8002
15+
- containerPort: 30804
16+
hostPort: 8004
1717
protocol: TCP
1818
extraMounts:
1919
- hostPath: ./test/testdata/containerd/config-v2.toml

test/testdata/kind/config-v2.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ nodes:
2121
- containerPort: 4003
2222
hostPort: 4003
2323
protocol: TCP
24-
- containerPort: 30802
25-
hostPort: 8002
24+
- containerPort: 30804
25+
hostPort: 8004
2626
protocol: TCP
2727
extraMounts:
2828
- hostPath: ./test/testdata/containerd/config-v2.toml

0 commit comments

Comments
 (0)