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

mendersoftware / mender-mcu / 1564701830

28 Nov 2024 04:29PM UTC coverage: 9.088%. Remained the same
1564701830

push

gitlab-ci

vpodzime
fix: Detect hanging in PENDING_REBOOT state

If reboot was requested, but it hasn't come in a pre-defined
number of iterations to wait, we need to fail the deployment and
resume normal operation.

This also means we need to tell the scheduler to run the work
function even if it is just waiting for a reboot and has nothing
to do. Nothing else than checking if it has not been waiting for
too long.

Ticket: MEN-7555
Changelog: none
Signed-off-by: Vratislav Podzimek <vratislav.podzimek@northern.tech>

0 of 28 new or added lines in 2 files covered. (0.0%)

222 existing lines in 1 file now uncovered.

251 of 2762 relevant lines covered (9.09%)

0.65 hits per line

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

0.0
/core/src/mender-error-counters.c
1
/**
2
 * @file      mender-error-counters.c
3
 * @brief     Mender Error counters implementation
4
 *
5
 * Copyright Northern.tech AS
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19

20
#include <stdint.h>
21

22
#include "mender-error-counters.h"
23
#include "mender-log.h"
24
#include "mender-utils.h"
25

26
#if CONFIG_MENDER_ERRORS_THRESHOLD_NET > 0
27

28
static uint8_t net_errors = 0;
29
#if CONFIG_MENDER_ERRORS_THRESHOLD_NET > UINT8_MAX
30
#error "CONFIG_MENDER_ERRORS_THRESHOLD_NET must be <= UINT8_MAX"
31
#endif
32

33
mender_err_t
34
mender_err_count_net_inc(void) {
×
35
    if (net_errors < UINT8_MAX) {
×
36
        net_errors++;
×
37
    }
38
    if (net_errors > CONFIG_MENDER_ERRORS_THRESHOLD_NET) {
×
39
        mender_log_warning("Network errors limit exceeded");
×
40
        return MENDER_FAIL;
×
41
    }
42
    return MENDER_OK;
×
43
}
44

45
mender_err_t
46
mender_err_count_net_check(void) {
×
47
    if (net_errors > CONFIG_MENDER_ERRORS_THRESHOLD_NET) {
×
48
        mender_log_warning("Network errors limit exceeded");
×
49
        return MENDER_FAIL;
×
50
    }
51
    return MENDER_OK;
×
52
}
53

54
mender_err_t
55
mender_err_count_net_reset(void) {
×
56
    net_errors = 0;
×
57
    return MENDER_OK;
×
58
}
59
#endif /* CONFIG_MENDER_ERRORS_THRESHOLD_NET > 0 */
60

61
#if CONFIG_MENDER_ERRORS_THRESHOLD_REBOOT > 0
62

63
static uint8_t reboot_errors = 0;
64
#if CONFIG_MENDER_ERRORS_THRESHOLD_REBOOT > UINT8_MAX
65
#error "CONFIG_MENDER_ERRORS_THRESHOLD_REBOOT must be <= UINT8_MAX"
66
#endif
67

68
mender_err_t
NEW
69
mender_err_count_reboot_inc(void) {
×
NEW
70
    if (reboot_errors < UINT8_MAX) {
×
NEW
71
        reboot_errors++;
×
72
    }
NEW
73
    if (reboot_errors > CONFIG_MENDER_ERRORS_THRESHOLD_REBOOT) {
×
NEW
74
        return MENDER_FAIL;
×
75
    }
NEW
76
    return MENDER_OK;
×
77
}
78

79
mender_err_t
NEW
80
mender_err_count_reboot_reset(void) {
×
NEW
81
    reboot_errors = 0;
×
NEW
82
    return MENDER_OK;
×
83
}
84
#endif /* CONFIG_MENDER_ERRORS_THRESHOLD_REBOOT > 0 */
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