• 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

61.36
/backend/services/deployments/api/http/api_deployments_last_status.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

15
package http
16

17
import (
18
        "net/http"
19

20
        "github.com/pkg/errors"
21

22
        "github.com/ant0ine/go-json-rest/rest"
23

24
        "github.com/mendersoftware/mender-server/pkg/identity"
25
        "github.com/mendersoftware/mender-server/pkg/requestlog"
26
        "github.com/mendersoftware/mender-server/pkg/rest_utils"
27

28
        "github.com/mendersoftware/mender-server/services/deployments/model"
29
)
30

31
// device deployments last status handler
32
func (d *DeploymentsApiHandlers) GetDeviceDeploymentLastStatus(
33
        w rest.ResponseWriter,
34
        r *rest.Request,
35
) {
1✔
36
        l := requestlog.GetRequestLogger(r)
1✔
37

1✔
38
        l.Debugf("starting")
1✔
39

1✔
40
        tenantId := r.PathParam("tenant")
1✔
41
        var req model.DeviceDeploymentLastStatusReq
1✔
42
        if err := r.DecodeJsonPayload(&req); err != nil {
1✔
UNCOV
43
                l.Errorf("error during DecodeJsonPayload: %s.", err.Error())
×
UNCOV
44
                rest_utils.RestErrWithLog(
×
UNCOV
45
                        w,
×
UNCOV
46
                        r,
×
UNCOV
47
                        l,
×
UNCOV
48
                        errors.Wrap(err, "cannot parse device ids array"),
×
UNCOV
49
                        http.StatusBadRequest,
×
UNCOV
50
                )
×
UNCOV
51
                return
×
52
        } else if len(req.DeviceIds) == 0 {
1✔
53
                rest_utils.RestErrWithLog(
×
54
                        w,
×
55
                        r,
×
56
                        l,
×
57
                        errors.Wrap(err, "device ids array cannot be empty"),
×
58
                        http.StatusBadRequest,
×
59
                )
×
60
        }
×
61

62
        l.Debugf("querying %d devices ids", len(req.DeviceIds))
1✔
63
        ctx := r.Context()
1✔
64
        if tenantId != "" {
2✔
65
                ctx = identity.WithContext(
1✔
66
                        ctx,
1✔
67
                        &identity.Identity{
1✔
68
                                Tenant: tenantId,
1✔
69
                        },
1✔
70
                )
1✔
71
        }
1✔
72
        lastDeployments, err := d.app.GetDeviceDeploymentLastStatus(ctx, req.DeviceIds)
1✔
73
        switch err {
1✔
74
        default:
1✔
75
                d.view.RenderInternalError(w, r, err, l)
1✔
76
        case nil:
1✔
77
                l.Infof("outputting: %+v", lastDeployments)
1✔
78
                w.WriteHeader(http.StatusOK)
1✔
79
                _ = w.WriteJson(lastDeployments)
1✔
80
        }
81
}
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