Skip to content

Commit

Permalink
Update actions and dependencies versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ivukotic committed Oct 8, 2024
1 parent f7d5fd4 commit 5839829
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 41 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4.2.1

- name: Extract tag name
shell: bash
run: echo "##[set-output name=imagetag;]$(echo ${GITHUB_REF##*/})"
id: extract_tag_name

- name: Docker Build & Push Action
uses: mr-smithers-excellent/docker-build-push@v6.3
uses: mr-smithers-excellent/docker-build-push@v6.4
with:
image: ivukotic/aaasf
tags: ${{ steps.extract_tag_name.outputs.imagetag }}
Expand All @@ -32,6 +32,6 @@ jobs:
uses: peter-evans/[email protected]
with:
token: ${{ secrets.AAAS_GITOPS_DEPLOY_TRIGGER }}
repository: maniaclab/river_apps
repository: maniaclab/flux_apps
event-type: gitops-aaasf-app-trigger-dev
client-payload: '{"ref": "${{ steps.extract_tag_name.outputs.imagetag }}"}'
6 changes: 3 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4.2.1

- name: Docker Build & Push Action
uses: mr-smithers-excellent/docker-build-push@v6.3
uses: mr-smithers-excellent/docker-build-push@v6.4
with:
image: ivukotic/aaasf
tags: latest, ${{ github.sha }}
Expand All @@ -25,6 +25,6 @@ jobs:
uses: peter-evans/[email protected]
with:
token: ${{ secrets.AAAS_GITOPS_DEPLOY_TRIGGER }}
repository: maniaclab/river_apps
repository: maniaclab/flux_apps
event-type: gitops-aaasf-app-trigger
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
112 changes: 77 additions & 35 deletions routes/alarms.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ function hasTopology(obj) {
async function loadAlarmTopology() {
console.log('loading categories...');
try {
const response = await es.search(
{
index: esAlarmTopologyIndex,
size: 1000,
query: { match_all: {} },
const response = await es.search({
index: esAlarmTopologyIndex,
size: 1000,
query: {
match_all: {}
},
);
}, );
if (response.hits.total.value === 0) {
console.log('No categories found.');
return false;
}
const { hits } = response.hits;
const {
hits
} = response.hits;
categories.length = 0;
hits.forEach((hit) => {
const s = hit._source;
Expand Down Expand Up @@ -77,8 +79,8 @@ router.post('/', jsonParser, async (req, res) => {
console.log('Check that only allowed things are in.');
Object.entries(b).forEach(([key]) => {
// console.log(`${key}: ${value}`);
if (!(config.REQUIRED_ALARM_FIELDS.includes(key)
|| config.OPTIONAL_ALARM_FIELDS.includes(key))) {
if (!(config.REQUIRED_ALARM_FIELDS.includes(key) ||
config.OPTIONAL_ALARM_FIELDS.includes(key))) {
console.log(`key: >${key}< not allowed.\n`);
delete b[key];
}
Expand All @@ -95,7 +97,10 @@ router.post('/', jsonParser, async (req, res) => {
b.created_at = new Date().getTime();

try {
const response = await es.index({ index: esAlarmsIndex, body: b });
const response = await es.index({
index: esAlarmsIndex,
body: b
});
// console.log('Alarm added.');
// console.debug(response);
res.status(200).send('OK');
Expand Down Expand Up @@ -135,32 +140,52 @@ router.post('/fetch', jsonParser, async (req, res) => {
return;
}
const {
category, subcategory, event, period,
category,
subcategory,
event,
period,
} = b;

console.log('Getting alarms in:', category, '/', subcategory, '/', event, '/', period);
const alarms = [];
try {
const response = await es.search(
{
index: esAlarmsIndex,
size: 1000,
query: {
bool: {
must: [
{ term: { category } },
{ term: { subcategory } },
{ term: { event } },
{ range: { created_at: { gte: `now-${period}h/h` } } },
],
},
const response = await es.search({
index: esAlarmsIndex,
size: 1000,
query: {
bool: {
must: [{
term: {
category
}
},
{
term: {
subcategory
}
},
{
term: {
event
}
},
{
range: {
created_at: {
gte: `now-${period}h/h`
}
}
},
],
},
},
);
}, );
if (response.hits.total.value === 0) {
console.log('No alarms found.');
} else {
const { hits } = response.hits;
const {
hits
} = response.hits;
hits.forEach((hit) => {
const s = hit._source;
// console.log(s);
Expand Down Expand Up @@ -197,7 +222,9 @@ router.post('/category', jsonParser, async (req, res) => {

try {
const response = await es.index({
index: esAlarmTopologyIndex, body: b, refresh: true,
index: esAlarmTopologyIndex,
body: b,
refresh: true,
});
console.log('Category added.');
console.debug(response.body);
Expand Down Expand Up @@ -246,18 +273,31 @@ router.patch('/category', jsonParser, async (req, res) => {
},
query: {
bool: {
must: [
{ term: { category: b.category } },
{ term: { subcategory: b.subcategory } },
{ term: { event: b.event } },
must: [{
term: {
category: b.category
}
},
{
term: {
subcategory: b.subcategory
}
},
{
term: {
event: b.event
}
},
],
},
},
};

try {
const response = await es.updateByQuery({
index: esAlarmTopologyIndex, body: updateBody, refresh: true,
index: esAlarmTopologyIndex,
body: updateBody,
refresh: true,
});
console.log('Category patched.');
console.debug(response.body);
Expand Down Expand Up @@ -285,7 +325,9 @@ router.delete('/', async (req, res) => {
if (b[v] === undefined || b[v] === null) {
res.status(400).send(`${v} is required.\n`);
} else {
const obj = { match: {} };
const obj = {
match: {}
};
obj.match[v] = b[v];
selector.push(obj);
}
Expand All @@ -303,11 +345,11 @@ router.delete('/', async (req, res) => {
},
refresh: true,
});
console.log(`delete response: ${response.body}`);
if (response.body.deleted > 0) {
await loadAlarmTopology();
res.status(200).send('OK');
} else {
console.log(response.body);
res.status(500).send('No alarms in that category.');
}
} catch (error) {
Expand All @@ -318,4 +360,4 @@ router.delete('/', async (req, res) => {

exports.router = router;
exports.init = init;
exports.loadAlarmTopology = loadAlarmTopology;
exports.loadAlarmTopology = loadAlarmTopology;

0 comments on commit 5839829

Please sign in to comment.