Skip to content

Commit

Permalink
feat(main.py): Add noevent flag
Browse files Browse the repository at this point in the history
While updating some data like kcidb flags we should not generate
events, as they will be processed by kcidb bridge again.

Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
  • Loading branch information
nuclearcat committed Dec 4, 2024
1 parent 56aa638 commit 22febf3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,8 @@ async def post_node(node: Node,

@app.put('/node/{node_id}', response_model=Node, response_model_by_alias=False)
async def put_node(node_id: str, node: Node,
user: str = Depends(authorize_user)):
user: str = Depends(authorize_user),
noevent: Optional[bool] = Query(None)):
"""Update an already added node"""
metrics.add('http_requests_total', 1)
node.id = ObjectId(node_id)
Expand Down Expand Up @@ -763,9 +764,10 @@ async def put_node(node_id: str, node: Node,
attributes = {}
if data.get('owner', None):
attributes['owner'] = data['owner']
await pubsub.publish_cloudevent('node', data, attributes)
evhist = _get_eventhistory(data)
await db.create(evhist)
if not noevent:
await pubsub.publish_cloudevent('node', data, attributes)
evhist = _get_eventhistory(data)
await db.create(evhist)
return obj


Expand Down

0 comments on commit 22febf3

Please sign in to comment.