Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EOSC Accounting #17

Merged
merged 32 commits into from
Aug 21, 2024
Merged

EOSC Accounting #17

merged 32 commits into from
Aug 21, 2024

Conversation

enolfc
Copy link
Collaborator

@enolfc enolfc commented Jul 18, 2024

Summary

Implement changes needed to make Notebooks report accounting as needed by EOSC Lot 1/3
Modernise the code as well

Changes to the main accounting script:

  • it changes the configuration and splits the configuration into a [default] section and keeps there most of the stuff that was on [prometheus] which was a mix of everything
  • the DB is updated with a new field (flavor) which is populated from the egi.eu/flavor annotation
  • APEL records are not generated by default, needs to be explicitly enabled in the config
  • default VO is removed, not clear that it was used at all

In the EOSC accounting:

  • it does not query prometheus directly anymore but does queries to the existing database for VM that have
  • it can use a from-date and to-date for reporting, by default it will report the previous day
  • uses client credentials grant instead of refresh

Other changes

  • it moves to pyproject.toml, we may think on additional tooling for managing the project in the future

Related issue :

@enolfc enolfc marked this pull request as ready for review July 23, 2024 11:25
The code will report from the last succesfully completed execution
@andrea-manzi
Copy link
Contributor

i'm testing manullay for now, but i see some strange aggregated values being published to Accounting:

DEBUG:root:Sending metric {'metric_definition_id': '668bdd5988e1d617b217ecb9', 'time_period_start': '2024-07-25T00:00:00Z', 'time_period_end': '2024-07-25T23:59:00Z', 'user': '[email protected]', 'group': 'urn:geant:eosc-federation.eu:testing:group:eosc#testing.eosc-federation.eu', 'value': 57002.0} to accounting DEBUG:root:Pushing to accounting - 668bdf9c744c3c7ae7531916 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.acc.staging.eosc.grnet.gr:443 DEBUG:urllib3.connectionpool:https://api.acc.staging.eosc.grnet.gr:443 "POST /accounting-system/installations/668bdf9c744c3c7ae7531916/metrics HTTP/1.1" 201 190 DEBUG:root:Sending metric {'metric_definition_id': '668bdd5988e1d617b217ecb9', 'time_period_start': '2024-07-25T00:00:00Z', 'time_period_end': '2024-07-25T23:59:00Z', 'user': '[email protected]', 'group': 'pp-5e869742-24f1-4ae0-a21c-13a64cfe7115', 'value': 7751.0} to accounting DEBUG:root:Pushing to accounting - 668bdf9c744c3c7ae7531916 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.acc.staging.eosc.grnet.gr:443 DEBUG:urllib3.connectionpool:https://api.acc.staging.eosc.grnet.gr:443 "POST /accounting-system/installations/668bdf9c744c3c7ae7531916/metrics HTTP/1.1" 201 189 DEBUG:root:Sending metric {'metric_definition_id': '668bdd5988e1d617b217ecb9', 'time_period_start': '2024-07-25T00:00:00Z', 'time_period_end': '2024-07-25T23:59:00Z', 'user': '[email protected]', 'group': 'pp-d71db0cf-3d77-4f97-976d-8fa5a51fe3ff', 'value': 96.0} to accounting

i have generated the DB from prometheus on fullhub instance using the pods py script

@andrea-manzi
Copy link
Contributor

i'm testing manullay for now, but i see some strange aggregated values being published to Accounting:

DEBUG:root:Sending metric {'metric_definition_id': '668bdd5988e1d617b217ecb9', 'time_period_start': '2024-07-25T00:00:00Z', 'time_period_end': '2024-07-25T23:59:00Z', 'user': '[email protected]', 'group': 'urn:geant:eosc-federation.eu:testing:group:eosc#testing.eosc-federation.eu', 'value': 57002.0} to accounting DEBUG:root:Pushing to accounting - 668bdf9c744c3c7ae7531916 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.acc.staging.eosc.grnet.gr:443 DEBUG:urllib3.connectionpool:https://api.acc.staging.eosc.grnet.gr:443 "POST /accounting-system/installations/668bdf9c744c3c7ae7531916/metrics HTTP/1.1" 201 190 DEBUG:root:Sending metric {'metric_definition_id': '668bdd5988e1d617b217ecb9', 'time_period_start': '2024-07-25T00:00:00Z', 'time_period_end': '2024-07-25T23:59:00Z', 'user': '[email protected]', 'group': 'pp-5e869742-24f1-4ae0-a21c-13a64cfe7115', 'value': 7751.0} to accounting DEBUG:root:Pushing to accounting - 668bdf9c744c3c7ae7531916 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.acc.staging.eosc.grnet.gr:443 DEBUG:urllib3.connectionpool:https://api.acc.staging.eosc.grnet.gr:443 "POST /accounting-system/installations/668bdf9c744c3c7ae7531916/metrics HTTP/1.1" 201 189 DEBUG:root:Sending metric {'metric_definition_id': '668bdd5988e1d617b217ecb9', 'time_period_start': '2024-07-25T00:00:00Z', 'time_period_end': '2024-07-25T23:59:00Z', 'user': '[email protected]', 'group': 'pp-d71db0cf-3d77-4f97-976d-8fa5a51fe3ff', 'value': 96.0} to accounting

i have generated the DB from prometheus on fullhub instance using the pods py script

could be that this is related to this query https://github.com/EGI-Federation/egi-notebooks-accounting/blob/master/egi_notebooks_accounting/pods.py#L46 which is returning seconds? while we would like to report hours?

@andrea-manzi
Copy link
Contributor

i'm testing manullay for now, but i see some strange aggregated values being published to Accounting:
DEBUG:root:Sending metric {'metric_definition_id': '668bdd5988e1d617b217ecb9', 'time_period_start': '2024-07-25T00:00:00Z', 'time_period_end': '2024-07-25T23:59:00Z', 'user': '[email protected]', 'group': 'urn:geant:eosc-federation.eu:testing:group:eosc#testing.eosc-federation.eu', 'value': 57002.0} to accounting DEBUG:root:Pushing to accounting - 668bdf9c744c3c7ae7531916 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.acc.staging.eosc.grnet.gr:443 DEBUG:urllib3.connectionpool:https://api.acc.staging.eosc.grnet.gr:443 "POST /accounting-system/installations/668bdf9c744c3c7ae7531916/metrics HTTP/1.1" 201 190 DEBUG:root:Sending metric {'metric_definition_id': '668bdd5988e1d617b217ecb9', 'time_period_start': '2024-07-25T00:00:00Z', 'time_period_end': '2024-07-25T23:59:00Z', 'user': '[email protected]', 'group': 'pp-5e869742-24f1-4ae0-a21c-13a64cfe7115', 'value': 7751.0} to accounting DEBUG:root:Pushing to accounting - 668bdf9c744c3c7ae7531916 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.acc.staging.eosc.grnet.gr:443 DEBUG:urllib3.connectionpool:https://api.acc.staging.eosc.grnet.gr:443 "POST /accounting-system/installations/668bdf9c744c3c7ae7531916/metrics HTTP/1.1" 201 189 DEBUG:root:Sending metric {'metric_definition_id': '668bdd5988e1d617b217ecb9', 'time_period_start': '2024-07-25T00:00:00Z', 'time_period_end': '2024-07-25T23:59:00Z', 'user': '[email protected]', 'group': 'pp-d71db0cf-3d77-4f97-976d-8fa5a51fe3ff', 'value': 96.0} to accounting
i have generated the DB from prometheus on fullhub instance using the pods py script

could be that this is related to this query https://github.com/EGI-Federation/egi-notebooks-accounting/blob/master/egi_notebooks_accounting/pods.py#L46 which is returning seconds? while we would like to report hours?

mm no that value is coming from the pod.wall

@enolfc
Copy link
Collaborator Author

enolfc commented Jul 29, 2024

mm no that value is coming from the pod.wall

that's also in seconds, so we need to convert to hours

@andrea-manzi
Copy link
Contributor

mm no that value is coming from the pod.wall

that's also in seconds, so we need to convert to hours

yes now numbers seems correct!

DEBUG:urllib3.connectionpool:https://api.acc.staging.eosc.grnet.gr:443 "POST /accounting-system/installations/668bdf9c744c3c7ae7531916/metrics HTTP/1.1" 201 200
DEBUG:root:Sending metric {'metric_definition_id': '668bdd5988e1d617b217ecb9', 'time_period_start': '2024-07-25T00:00:00Z', 'time_period_end': '2024-07-25T23:59:00Z', 'user': '[email protected]', 'group': 'pp-5e869742-24f1-4ae0-a21c-13a64cfe7115', 'value': 2.1530555555555555} to accounting
DEBUG:root:Pushing to accounting - 668bdf9c744c3c7ae7531916
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.acc.staging.eosc.grnet.gr:443
DEBUG:urllib3.connectionpool:https://api.acc.staging.eosc.grnet.gr:443 "POST /accounting-system/installations/668bdf9c744c3c7ae7531916/metrics HTTP/1.1" 201 201
DEBUG:root:Sending metric {'metric_definition_id': '668bdd5988e1d617b217ecb9', 'time_period_start': '2024-07-25T00:00:00Z', 'time_period_end': '2024-07-25T23:59:00Z', 'user': '[email protected]', 'group': 'pp-d71db0cf-3d77-4f97-976d-8fa5a51fe3ff', 'value': 0.02666666666666667} to accounting

@valtri do you think you can test it on the testing JHub instance ?

Copy link
Contributor

@andrea-manzi andrea-manzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested successfully by CESNET

@andrea-manzi andrea-manzi merged commit 5f048a6 into EGI-Federation:master Aug 21, 2024
2 checks passed
@enolfc enolfc deleted the eosc-accounting branch August 21, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants