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

Fix reported time in seconds in metrics when backup are >24h #608

Merged
merged 1 commit into from
Aug 31, 2023

Conversation

Skunnyk
Copy link
Contributor

@Skunnyk Skunnyk commented Aug 3, 2023

@adejanovski
Copy link
Contributor

Hi @Skunnyk, thanks for sending this PR!

Issue: The integration tests are failing due to this change:

Traceback (most recent call last):
Feature: Integration tests
  File "/home/runner/work/cassandra-medusa/cassandra-medusa/medusa/backup_node.py", line 199, in handle_backup
    enable_md5_checks_flag, backup_name, config, monitoring)
  File "/home/runner/work/cassandra-medusa/cassandra-medusa/medusa/backup_node.py", line 257, in start_backup
    update_monitoring(actual_backup_duration, backup_name, monitoring, node_backup)
  File "/home/runner/work/cassandra-medusa/cassandra-medusa/medusa/backup_node.py", line 337, in update_monitoring
    monitoring.send(tags, actual_backup_duration.total_seconds)
  File "/home/runner/work/cassandra-medusa/cassandra-medusa/medusa/monitoring/__init__.py", line 54, in send
    return self._monitoring_driver.send(tags, value)
  File "/home/runner/work/cassandra-medusa/cassandra-medusa/medusa/monitoring/local.py", line 36, in send
    self._persist_metric(metric)
  File "/home/runner/work/cassandra-medusa/cassandra-medusa/medusa/monitoring/local.py", line 40, in _persist_metric
    data = json.dumps(metric)
  File "/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'builtin_function_or_method' is not JSON serializable

@Skunnyk
Copy link
Contributor Author

Skunnyk commented Aug 21, 2023

Woopsie, was tired I guess, used .total_seconds instead of calling the function .total_seconds() :)

medusa/backup_cluster.py Outdated Show resolved Hide resolved
medusa/restore_cluster.py Outdated Show resolved Hide resolved
- When backup duration is >24h, the .seconds conversion only convert the second of the day, not the full duration.
- This fix thelastpickle#606
@sonarcloud
Copy link

sonarcloud bot commented Aug 31, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
3.5% 3.5% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

Copy link
Contributor

@adejanovski adejanovski left a comment

Choose a reason for hiding this comment

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

Looks good now. Thanks @Skunnyk

@adejanovski adejanovski merged commit bcf2153 into thelastpickle:master Aug 31, 2023
25 of 26 checks passed
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.

Reported time in metrics/logs is wrong when backup > 24h
2 participants