Skip to content

Commit

Permalink
fix(agent): PENG-2457 fix the *epoch* param when querying InfluxDB fo…
Browse files Browse the repository at this point in the history
…r metrics. (#678)

This commit modifies the *epoch* param of the *.query* method in the function
*fetch_influx_data* when querying InfluxDB for metrics. The previous argument,
i.e. *us*, was generating errors in the API when converting the timestamp to
datetime objects necessary for SQLAlchemy.
  • Loading branch information
matheushent authored Dec 19, 2024
1 parent 97ba3f2 commit 1b3f28e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion jobbergate-agent/jobbergate_agent/jobbergate/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async def fetch_influx_data(
assert influxdb_client is not None # mypy assertion

logger.debug(f"Querying InfluxDB with: {query=}, {params=}")
result = influxdb_client.query(query, bind_params=params, epoch="us")
result = influxdb_client.query(query, bind_params=params, epoch="s")
logger.debug("Successfully fetched data from InfluxDB")

return [
Expand Down
6 changes: 3 additions & 3 deletions jobbergate-agent/tests/jobbergate/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ async def test_fetch_influx_data__success_with_all_set(mocked_influxdb_client: m
assert result[0]["task"] == task
assert result[0]["value"] == measurement_value
assert result[0]["measurement"] == measurement
mocked_influxdb_client.query.assert_called_once_with(query, bind_params=params, epoch="us")
mocked_influxdb_client.query.assert_called_once_with(query, bind_params=params, epoch="s")


@pytest.mark.asyncio
Expand Down Expand Up @@ -425,7 +425,7 @@ async def test_fetch_influx_data__success_with_all_None(mocked_influxdb_client:
assert result[0]["task"] == task
assert result[0]["value"] == measurement_value
assert result[0]["measurement"] == measurement
mocked_influxdb_client.query.assert_called_once_with(query, bind_params=params, epoch="us")
mocked_influxdb_client.query.assert_called_once_with(query, bind_params=params, epoch="s")


@pytest.mark.asyncio
Expand Down Expand Up @@ -495,7 +495,7 @@ async def test_fetch_influx_data__raises_JobbergateAgentError_if_query_fails(moc
task=task,
)

mocked_influxdb_client.query.assert_called_once_with(query, bind_params=params, epoch="us")
mocked_influxdb_client.query.assert_called_once_with(query, bind_params=params, epoch="s")


@pytest.mark.asyncio
Expand Down

0 comments on commit 1b3f28e

Please sign in to comment.