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

mendersoftware / mender-server / 1622978334

13 Jan 2025 03:51PM UTC coverage: 72.802% (-3.8%) from 76.608%
1622978334

Pull #300

gitlab-ci

alfrunes
fix: Deployment device count should not exceed max devices

Added a condition to skip deployments when the device count reaches max
devices.

Changelog: Title
Ticket: MEN-7847
Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Pull Request #300: fix: Deployment device count should not exceed max devices

4251 of 6164 branches covered (68.96%)

Branch coverage included in aggregate %.

0 of 18 new or added lines in 1 file covered. (0.0%)

2544 existing lines in 83 files now uncovered.

42741 of 58384 relevant lines covered (73.21%)

21.49 hits per line

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

23.08
/backend/services/inventory/server.go
1
// Copyright 2023 Northern.tech AS
2
//
3
//        Licensed under the Apache License, Version 2.0 (the "License");
4
//        you may not use this file except in compliance with the License.
5
//        You may obtain a copy of the License at
6
//
7
//            http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//        Unless required by applicable law or agreed to in writing, software
10
//        distributed under the License is distributed on an "AS IS" BASIS,
11
//        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//        See the License for the specific language governing permissions and
13
//        limitations under the License.
14
package main
15

16
import (
17
        "net/http"
18

19
        "github.com/pkg/errors"
20

21
        "github.com/mendersoftware/mender-server/pkg/log"
22

23
        api_http "github.com/mendersoftware/mender-server/services/inventory/api/http"
24
        "github.com/mendersoftware/mender-server/services/inventory/client/devicemonitor"
25
        "github.com/mendersoftware/mender-server/services/inventory/client/workflows"
26
        "github.com/mendersoftware/mender-server/services/inventory/config"
27
        inventory "github.com/mendersoftware/mender-server/services/inventory/inv"
28
        "github.com/mendersoftware/mender-server/services/inventory/store/mongo"
29
)
30

UNCOV
31
func RunServer(c config.Reader) error {
×
UNCOV
32

×
UNCOV
33
        l := log.New(log.Ctx{})
×
UNCOV
34

×
UNCOV
35
        db, err := mongo.NewDataStoreMongo(makeDataStoreConfig())
×
UNCOV
36
        if err != nil {
×
UNCOV
37
                return errors.Wrap(err, "database connection failed")
×
UNCOV
38
        }
×
39

UNCOV
40
        limitAttributes := c.GetInt(SettingLimitAttributes)
×
UNCOV
41
        limitTags := c.GetInt(SettingLimitTags)
×
42

×
43
        inv := inventory.NewInventory(db).WithLimits(limitAttributes, limitTags)
×
UNCOV
44

×
UNCOV
45
        devicemonitorAddr := c.GetString(SettingDevicemonitorAddr)
×
UNCOV
46
        if devicemonitorAddr != "" {
×
UNCOV
47
                c := devicemonitor.NewClient(devicemonitorAddr)
×
UNCOV
48
                inv = inv.WithDevicemonitor(c)
×
UNCOV
49
        }
×
50

UNCOV
51
        if inv, err = maybeWithInventory(inv, c); err != nil {
×
UNCOV
52
                return err
×
UNCOV
53
        }
×
54

UNCOV
55
        invapi := api_http.NewInventoryApiHandlers(inv)
×
UNCOV
56
        handler, err := invapi.Build()
×
57
        if err != nil {
×
58
                return errors.Wrap(err, "inventory API handlers setup failed")
×
UNCOV
59
        }
×
UNCOV
60
        addr := c.GetString(SettingListen)
×
UNCOV
61
        l.Printf("listening on %s", addr)
×
UNCOV
62

×
63
        return http.ListenAndServe(addr, handler)
×
64
}
65

66
func maybeWithInventory(
67
        inv inventory.InventoryApp,
68
        c config.Reader,
69
) (inventory.InventoryApp, error) {
1✔
70
        if reporting := c.GetBool(SettingEnableReporting); reporting {
2✔
71
                orchestrator := c.GetString(SettingOrchestratorAddr)
1✔
72
                if orchestrator == "" {
2✔
73
                        return inv, errors.New("reporting integration needs orchestrator address")
1✔
74
                }
1✔
75

76
                c := workflows.NewClient(orchestrator)
1✔
77
                inv = inv.WithReporting(c)
1✔
78
        }
79
        return inv, nil
1✔
80
}
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