Skip to content

Commit 0a2e2ea

Browse files
committed
Merge branch 'main' of https://github.com/bbc/bug
2 parents b9519b0 + fb1e10c commit 0a2e2ea

134 files changed

Lines changed: 1346 additions & 620 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
open-pull-requests-limit: 20
8+
groups:
9+
other-updates:
10+
patterns:
11+
- "*"
12+
update-types:
13+
- "major"
14+
15+
- package-ecosystem: "npm"
16+
directory: "/src/client"
17+
schedule:
18+
interval: "weekly"
19+
open-pull-requests-limit: 20
20+
groups:
21+
other-updates:
22+
patterns:
23+
- "*"
24+
update-types:
25+
- "major"
26+
27+
- package-ecosystem: "github-actions"
28+
directory: "/"
29+
schedule:
30+
interval: "weekly"
31+
open-pull-requests-limit: 20
32+
groups:
33+
other-updates:
34+
patterns:
35+
- "*"
36+
update-types:
37+
- "major"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Dependabot Auto Approve
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
- ready_for_review
10+
11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
15+
jobs:
16+
auto-approve:
17+
if: github.actor == 'dependabot[bot]'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Fetch Dependabot metadata
21+
id: metadata
22+
uses: dependabot/fetch-metadata@v2
23+
with:
24+
github-token: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Auto-approve minor and patch updates
27+
if: >-
28+
steps.metadata.outputs.update-type == 'version-update:semver-minor' ||
29+
steps.metadata.outputs.update-type == 'version-update:semver-patch'
30+
uses: actions/github-script@v7
31+
with:
32+
github-token: ${{ secrets.GITHUB_TOKEN }}
33+
script: |
34+
try {
35+
await github.rest.pulls.createReview({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
pull_number: context.payload.pull_request.number,
39+
event: 'APPROVE',
40+
body: 'Auto-approved because this is a Dependabot semver minor/patch update.'
41+
});
42+
} catch (error) {
43+
core.warning(`Approval skipped: ${error.message}`);
44+
}

.github/workflows/deploy.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
- completed
1010
workflow_dispatch:
1111

12+
concurrency:
13+
group: deploy-${{ github.ref }}
14+
cancel-in-progress: false
15+
1216
permissions:
1317
contents: read
1418
packages: write

.github/workflows/test-module-container.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
- "src/modules/**"
1212
- "src/server/core/**"
1313
- ".github/workflows/test-module-container.yml"
14+
workflow_dispatch:
1415

1516
jobs:
1617
discover-modules:

.github/workflows/versioning.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
- main
1313
workflow_dispatch:
1414

15+
concurrency:
16+
group: version-bump-${{ github.ref }}
17+
cancel-in-progress: false
18+
1519
permissions:
1620
actions: read
1721
contents: write

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Dockerfile*
2020
!/src/server/Dockerfile
2121
!/src/server/Dockerfile.dev
2222
!/src/server/Dockerfile.test
23+
!/src/modules/*/container/Dockerfile*
2324
!/src/server/services/dockerfile-write.js
2425

2526
# global environment files

package-lock.json

Lines changed: 11 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,14 @@
133133
"react-sparklines": "^1.6.0",
134134
"react-table": "^7.7.0",
135135
"react-textfit": "^1.1.1",
136-
"recharts": "^3.6.0",
136+
"recharts": "^3.8.1",
137137
"rgb-hex": "^4.0.1",
138138
"serve-favicon": "^2.5.0",
139139
"socket.io": "^4.5.1",
140140
"socket.io-client": "^4.0.1",
141141
"swagger-jsdoc": "^6.2.1",
142142
"swagger-ui-express": "^4.4.0",
143-
"systeminformation": "^5.16.1",
143+
"systeminformation": "^5.31.7",
144144
"tar": "^7.5.13",
145145
"text-hex": "^1.0.0",
146146
"timezones.json": "^1.6.1",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM node:22-alpine
2+
WORKDIR /home/node/module
3+
COPY src/server/core ./core
4+
COPY src/modules/appear-x/container ./
5+
RUN npm install
6+
CMD ["npm", "run", "development"]

src/modules/arista-switch/container/workers/tasks/neighbours.js

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ module.exports = async ({ aristaApi, mongoSingle, interfacesCollection, workerDa
1616
});
1717

1818
// fetch leases once
19-
const leases = await mongoSingle.get("leases") || [];
20-
const leasesByMac = Object.fromEntries(leases.map(lease => [lease.mac, lease]));
19+
const leases = (await mongoSingle.get("leases")) || [];
20+
const leasesByMac = Object.fromEntries(leases.map((lease) => [lease.mac, lease]));
2121

2222
// process ARP / FDB-like info
2323
const arpByInterface = {};
24-
(arpResult?.ipV4Neighbors || []).forEach(eachArp => {
24+
(arpResult?.ipV4Neighbors || []).forEach((eachArp) => {
2525
const mac = parseHex(eachArp.hwAddress).toUpperCase();
2626
const interfaceArray = eachArp.interface.split(", ");
27-
interfaceArray.forEach(iface => {
27+
interfaceArray.forEach((iface) => {
2828
if (!arpByInterface[iface]) arpByInterface[iface] = [];
2929
arpByInterface[iface].push(leasesByMac[mac] || { mac });
3030
});
@@ -35,8 +35,8 @@ module.exports = async ({ aristaApi, mongoSingle, interfacesCollection, workerDa
3535
updateOne: {
3636
filter: { interfaceId },
3737
update: { $set: { fdb: data } },
38-
upsert: false
39-
}
38+
upsert: false,
39+
},
4040
}));
4141
if (arpOps.length) await interfacesCollection.bulkWrite(arpOps);
4242
logger.debug(`updated db with arp details for ${arpOps.length} interface(s)`);
@@ -53,7 +53,7 @@ module.exports = async ({ aristaApi, mongoSingle, interfacesCollection, workerDa
5353

5454
// process LLDP info
5555
const lldpByInterface = {};
56-
(lldpResult?.lldpNeighbors || []).forEach(eachNeighbor => {
56+
(lldpResult?.lldpNeighbors || []).forEach((eachNeighbor) => {
5757
const interfaceId = eachNeighbor.port;
5858
if (!lldpByInterface[interfaceId]) lldpByInterface[interfaceId] = {};
5959

@@ -72,20 +72,39 @@ module.exports = async ({ aristaApi, mongoSingle, interfacesCollection, workerDa
7272
}
7373
});
7474

75-
// bulk update LLDP info
76-
const lldpOps = Object.entries(lldpByInterface).map(([interfaceId, data]) => ({
77-
updateOne: {
78-
filter: { interfaceId },
79-
update: { $set: { lldp: data } },
80-
upsert: false
81-
}
82-
}));
83-
if (lldpOps.length) await interfacesCollection.bulkWrite(lldpOps);
84-
logger.debug(`updated db with lldp details for ${lldpOps.length} interface(s)`);
75+
const activeInterfaceIds = Object.keys(lldpByInterface);
76+
const lldpClearFilter = {
77+
lldp: { $exists: true },
78+
};
8579

80+
if (activeInterfaceIds.length) {
81+
lldpClearFilter.interfaceId = { $nin: activeInterfaceIds };
82+
}
8683

84+
// bulk update LLDP info
85+
const lldpOps = [
86+
{
87+
updateMany: {
88+
filter: lldpClearFilter,
89+
update: {
90+
$unset: {
91+
lldp: "",
92+
},
93+
},
94+
},
95+
},
96+
...Object.entries(lldpByInterface).map(([interfaceId, data]) => ({
97+
updateOne: {
98+
filter: { interfaceId },
99+
update: { $set: { lldp: data } },
100+
upsert: false,
101+
},
102+
})),
103+
];
104+
await interfacesCollection.bulkWrite(lldpOps, { ordered: false });
105+
logger.debug(`updated db with lldp details for ${activeInterfaceIds.length} interface(s)`);
87106
} catch (err) {
88107
logger.error(`failed: ${err.message}`);
89108
throw err;
90109
}
91-
};
110+
};

0 commit comments

Comments
 (0)