• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tensorchord / openmodelz / 6446506146

08 Oct 2023 08:21AM UTC coverage: 27.12% (-0.03%) from 27.15%
6446506146

Pull #185

github

xieydd
chore: Fix can not get metrics from BYOC deployment

Signed-off-by: xieydd <xieydd@gmail.com>
Pull Request #185: chore: Fix can not get metrics from BYOC deployment

4 of 4 new or added lines in 2 files covered. (100.0%)

982 of 3621 relevant lines covered (27.12%)

1.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/agent/pkg/server/server_init_modelz_cloud.go
1
package server
2

3
import (
4
        "context"
5
        "fmt"
6

7
        "github.com/pkg/errors"
8
        "github.com/sirupsen/logrus"
9
        "github.com/tensorchord/openmodelz/agent/api/types"
10
        "github.com/tensorchord/openmodelz/agent/client"
11
)
12

13
func (s *Server) initModelZCloud(url, token, region string) error {
×
14
        cluster := types.ManagedCluster{
×
15
                Region: region,
×
16
                PrometheusURL: fmt.Sprintf("%s:%d", s.config.Metrics.PrometheusHost,
×
17
                        s.config.Metrics.PrometheusPort),
×
18
        }
×
19

×
20
        cli, err := client.NewClientWithOpts(
×
21
                client.WithHost(url))
×
22
        if err != nil {
×
23
                return errors.Wrap(err, "failed to create modelz cloud client")
×
24
        }
×
25
        s.modelzCloudClient = cli
×
26

×
27
        err = s.runtime.GetClusterInfo(&cluster)
×
28
        if err != nil {
×
29
                return errors.Wrap(err, "failed to get managed cluster info")
×
30
        }
×
31

32
        apiServerReady := make(chan struct{})
×
33
        go func() {
×
34
                if err := s.modelzCloudClient.WaitForAPIServerReady(); err != nil {
×
35
                        logrus.Fatalf("failed to wait for apiserver ready: %v", err)
×
36
                }
×
37
                close(apiServerReady)
×
38
        }()
39

40
        cluster.Status = types.ClusterStatusInit
×
41
        // after init modelz cloud client, register agent
×
42
        err = cli.RegisterAgent(context.Background(), token, &cluster)
×
43
        if err != nil {
×
44
                return errors.Wrap(err, "failed to register agent to modelz cloud")
×
45
        }
×
46
        s.config.ModelZCloud.ID = cluster.ID
×
47
        s.config.ModelZCloud.TokenID = cluster.TokenID
×
48
        s.config.ModelZCloud.Name = cluster.Name
×
49

×
50
        apikeys, err := s.modelzCloudClient.GetAPIKeys(context.Background(), apiServerReady, s.config.ModelZCloud.AgentToken, s.config.ModelZCloud.ID)
×
51
        if err != nil {
×
52
                logrus.Errorf("failed to get apikeys: %v", err)
×
53
        }
×
54

55
        s.config.ModelZCloud.APIKeys = apikeys
×
56

×
57
        namespaces, err := s.modelzCloudClient.GetNamespaces(context.Background(), apiServerReady, s.config.ModelZCloud.AgentToken, s.config.ModelZCloud.ID)
×
58
        if err != nil {
×
59
                logrus.Errorf("failed to get namespaces: %v", err)
×
60
        }
×
61

62
        nss := []string{}
×
63
        for _, ns := range namespaces.Items {
×
64
                nss = append(nss, ns)
×
65
                err = s.runtime.NamespaceCreate(context.Background(), ns)
×
66
                if err != nil {
×
67
                        logrus.Errorf("failed to create namespace %s: %v", ns, err)
×
68
                        continue
×
69
                }
70
        }
71
        s.config.ModelZCloud.UserNamespaces = nss
×
72

×
73
        return nil
×
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc