Skip to content

Commit 684c416

Browse files
committed
rebase fixes
1 parent 111d2c6 commit 684c416

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

packages/orchestrator/internal/grpcserver/healthcheck.go

Whitespace-only changes.

packages/orchestrator/internal/grpcserver/info_handlers.go

Whitespace-only changes.

packages/orchestrator/internal/grpcserver/info_store.go

Whitespace-only changes.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package service
2+
3+
import (
4+
"context"
5+
6+
"go.uber.org/zap"
7+
"google.golang.org/grpc"
8+
"google.golang.org/protobuf/types/known/emptypb"
9+
"google.golang.org/protobuf/types/known/timestamppb"
10+
11+
"github.com/e2b-dev/infra/packages/orchestrator/internal/sandbox"
12+
orchestratorinfo "github.com/e2b-dev/infra/packages/shared/pkg/grpc/orchestrator-info"
13+
"github.com/e2b-dev/infra/packages/shared/pkg/smap"
14+
)
15+
16+
type Server struct {
17+
orchestratorinfo.UnimplementedInfoServiceServer
18+
19+
info *ServiceInfo
20+
sandboxes *smap.Map[*sandbox.Sandbox]
21+
}
22+
23+
func NewInfoService(_ context.Context, grpc *grpc.Server, info *ServiceInfo, sandboxes *smap.Map[*sandbox.Sandbox]) *Server {
24+
s := &Server{
25+
info: info,
26+
sandboxes: sandboxes,
27+
}
28+
29+
orchestratorinfo.RegisterInfoServiceServer(grpc, s)
30+
return s
31+
}
32+
33+
func (s *Server) ServiceInfo(_ context.Context, _ *emptypb.Empty) (*orchestratorinfo.ServiceInfoResponse, error) {
34+
info := s.info
35+
36+
metricVCpuUsed := int64(0)
37+
metricMemoryUsedMb := int64(0)
38+
metricDiskMb := int64(0)
39+
40+
for _, item := range s.sandboxes.Items() {
41+
metricVCpuUsed += item.Config.Vcpu
42+
metricMemoryUsedMb += item.Config.RamMb
43+
metricDiskMb += item.Config.TotalDiskSizeMb
44+
}
45+
46+
return &orchestratorinfo.ServiceInfoResponse{
47+
NodeId: info.ClientId,
48+
ServiceId: info.ServiceId,
49+
ServiceStatus: info.GetStatus(),
50+
51+
ServiceVersion: info.SourceVersion,
52+
ServiceCommit: info.SourceCommit,
53+
54+
ServiceStartup: timestamppb.New(info.Startup),
55+
ServiceRoles: info.Roles,
56+
57+
MetricVcpuUsed: metricVCpuUsed,
58+
MetricMemoryUsedMb: metricMemoryUsedMb,
59+
MetricDiskMb: metricDiskMb,
60+
MetricSandboxesRunning: int64(s.sandboxes.Count()),
61+
}, nil
62+
}
63+
64+
func (s *Server) ServiceStatusOverride(_ context.Context, req *orchestratorinfo.ServiceStatusChangeRequest) (*emptypb.Empty, error) {
65+
zap.L().Info("service status override request received", zap.String("status", req.ServiceStatus.String()))
66+
s.info.SetStatus(req.ServiceStatus)
67+
return &emptypb.Empty{}, nil
68+
}

0 commit comments

Comments
 (0)