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

k8snetworkplumbingwg / sriov-network-operator / 19838673568

01 Dec 2025 09:49PM UTC coverage: 62.05% (-0.1%) from 62.149%
19838673568

Pull #972

github

web-flow
build(deps): bump coverallsapp/github-action from 2.3.6 to 2.3.7

Bumps [coverallsapp/github-action](https://github.com/coverallsapp/github-action) from 2.3.6 to 2.3.7.
- [Release notes](https://github.com/coverallsapp/github-action/releases)
- [Commits](https://github.com/coverallsapp/github-action/compare/v2.3.6...v2.3.7)

---
updated-dependencies:
- dependency-name: coverallsapp/github-action
  dependency-version: 2.3.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #972: build(deps): bump coverallsapp/github-action from 2.3.6 to 2.3.7

8759 of 14116 relevant lines covered (62.05%)

0.69 hits per line

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

60.42
/pkg/daemon/status.go
1
package daemon
2

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

7
        "k8s.io/apimachinery/pkg/api/equality"
8
        "k8s.io/client-go/util/retry"
9
        "sigs.k8s.io/controller-runtime/pkg/client"
10
        "sigs.k8s.io/controller-runtime/pkg/log"
11

12
        sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
13
        "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars"
14
)
15

16
const (
17
        Unknown = "Unknown"
18
)
19

20
func (dn *NodeReconciler) updateSyncState(ctx context.Context, desiredNodeState *sriovnetworkv1.SriovNetworkNodeState, status, failedMessage string) error {
1✔
21
        funcLog := log.Log.WithName("updateSyncState")
1✔
22
        currentNodeState := &sriovnetworkv1.SriovNetworkNodeState{}
1✔
23
        desiredNodeState.Status.SyncStatus = status
1✔
24
        desiredNodeState.Status.LastSyncError = failedMessage
1✔
25

1✔
26
        retryErr := retry.RetryOnConflict(retry.DefaultRetry, func() error {
2✔
27
                if err := dn.client.Get(ctx, client.ObjectKey{Namespace: desiredNodeState.Namespace, Name: desiredNodeState.Name}, currentNodeState); err != nil {
1✔
28
                        funcLog.Error(err, "failed to get latest node state",
×
29
                                "SyncStatus", status,
×
30
                                "LastSyncError", failedMessage)
×
31
                        return err
×
32
                }
×
33
                // update the object meta if not the patch can fail if the object did change
34
                desiredNodeState.ObjectMeta = currentNodeState.ObjectMeta
1✔
35

1✔
36
                funcLog.V(2).Info("update nodeState status",
1✔
37
                        "CurrentSyncStatus", currentNodeState.Status.SyncStatus,
1✔
38
                        "CurrentLastSyncError", currentNodeState.Status.LastSyncError,
1✔
39
                        "NewSyncStatus", desiredNodeState.Status.SyncStatus,
1✔
40
                        "NewFailedMessage", desiredNodeState.Status.LastSyncError)
1✔
41

1✔
42
                err := dn.client.Status().Patch(ctx, desiredNodeState, client.MergeFrom(currentNodeState))
1✔
43
                if err != nil {
1✔
44
                        funcLog.Error(err, "failed to update node state status",
×
45
                                "SyncStatus", status,
×
46
                                "LastSyncError", failedMessage)
×
47
                        return err
×
48
                }
×
49
                return nil
1✔
50
        })
51

52
        if retryErr != nil {
1✔
53
                funcLog.Error(retryErr, "failed to update node state status")
×
54
                return retryErr
×
55
        }
×
56

57
        dn.recordStatusChangeEvent(ctx, currentNodeState.Status.SyncStatus, status, failedMessage)
1✔
58
        return nil
1✔
59
}
60

61
func (dn *NodeReconciler) shouldUpdateStatus(current, desiredNodeState *sriovnetworkv1.SriovNetworkNodeState) bool {
1✔
62
        // check number of interfaces are equal
1✔
63
        if len(current.Status.Interfaces) != len(desiredNodeState.Status.Interfaces) {
1✔
64
                return true
×
65
        }
×
66

67
        // check for bridges
68
        if !equality.Semantic.DeepEqual(current.Status.Bridges, desiredNodeState.Status.Bridges) {
1✔
69
                return true
×
70
        }
×
71

72
        // check for system
73
        if !equality.Semantic.DeepEqual(current.Status.System, desiredNodeState.Status.System) {
1✔
74
                return true
×
75
        }
×
76

77
        // check for interfaces
78
        // we can't use deep equal here because if we have a vf inside a pod is name will not be available for example
79
        // we use the index for both lists
80
        c := current.Status.DeepCopy().Interfaces
1✔
81
        d := desiredNodeState.Status.DeepCopy().Interfaces
1✔
82
        for idx := range d {
2✔
83
                // check if it's a new device
1✔
84
                if d[idx].PciAddress != c[idx].PciAddress {
1✔
85
                        return true
×
86
                }
×
87
                // remove all the vfs
88
                d[idx].VFs = nil
1✔
89
                c[idx].VFs = nil
1✔
90

1✔
91
                if !equality.Semantic.DeepEqual(d[idx], c[idx]) {
1✔
92
                        return true
×
93
                }
×
94
        }
95

96
        return false
1✔
97
}
98

99
func (dn *NodeReconciler) updateStatusFromHost(nodeState *sriovnetworkv1.SriovNetworkNodeState) error {
1✔
100
        funcLog := log.Log.WithName("updateStatusFromHost")
1✔
101
        funcLog.Info("Getting host network status")
1✔
102
        ifaces, err := dn.platformInterface.DiscoverSriovDevices()
1✔
103
        if err != nil {
1✔
104
                funcLog.Error(err, "failed to discover sriov devices")
×
105
                return err
×
106
        }
×
107

108
        var bridges sriovnetworkv1.Bridges
1✔
109
        if vars.ManageSoftwareBridges {
1✔
110
                bridges, err = dn.platformInterface.DiscoverBridges()
×
111
                if err != nil {
×
112
                        funcLog.Error(err, "failed to discover bridges")
×
113
                        return err
×
114
                }
×
115
        }
116

117
        nodeState.Status.Interfaces = ifaces
1✔
118
        nodeState.Status.Bridges = bridges
1✔
119
        nodeState.Status.System.RdmaMode, err = dn.hostHelpers.DiscoverRDMASubsystem()
1✔
120
        if err != nil {
1✔
121
                funcLog.Error(err, "failed to discover rdma subsystem")
×
122
                return err
×
123
        }
×
124
        return nil
1✔
125
}
126

127
func (dn *NodeReconciler) recordStatusChangeEvent(ctx context.Context, oldStatus, newStatus, lastError string) {
1✔
128
        if oldStatus != newStatus {
2✔
129
                if oldStatus == "" {
2✔
130
                        oldStatus = Unknown
1✔
131
                }
1✔
132
                if newStatus == "" {
1✔
133
                        newStatus = Unknown
×
134
                }
×
135
                eventMsg := fmt.Sprintf("Status changed from: %s to: %s", oldStatus, newStatus)
1✔
136
                if lastError != "" {
1✔
137
                        eventMsg = fmt.Sprintf("%s. Last Error: %s", eventMsg, lastError)
×
138
                }
×
139
                dn.eventRecorder.SendEvent(ctx, "SyncStatusChanged", eventMsg)
1✔
140
        }
141
}
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