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

Delete graphite data when resource gets deleted #154

Merged
merged 7 commits into from
Oct 5, 2017

Conversation

rishubhjain
Copy link
Contributor

Tendrl-bug-id: #148

@rishubhjain
Copy link
Contributor Author

@r0h4n @shtripat Please review, It is tested


WHISPER_PATH = "/var/lib/carbon/whisper/tendrl/"

class UpdateGraphite(flows.BaseFlow):
Copy link
Contributor

Choose a reason for hiding this comment

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

Call this "DeleteResourceFromGraphite"

from tendrl.monitoring_integration.grafana import create_dashboards


WHISPER_PATH = "/var/lib/carbon/whisper/tendrl/"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this path the same for all versions of carbon/graphite? Can you read this path from the Graphite/Carbon conf file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -29,6 +29,20 @@ namespace.monitoring:
type: Create
version: 1
uuid: 1951e821-7aa9-4a91-8183-e73bc8275bde
UpdateGraphite:
Copy link
Contributor

Choose a reason for hiding this comment

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

DeleteResourceFromGraphite

@rishubhjain
Copy link
Contributor Author

rishubhjain commented Oct 3, 2017

@shtripat I have made the changes, Please review

self.update_graphite(cluster_id, resource_name,
resource_type.lower())

def get_path(self):
carbon_path = "/etc/tendrl/monitoring-integration/carbon.conf"
Copy link
Member

Choose a reason for hiding this comment

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

Is this file a ini format? If so cant we load ini to dict and refer fields.

self.update_graphite(cluster_id, resource_name,
resource_type.lower())

def get_path(self):
Copy link
Member

Choose a reason for hiding this comment

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

call this get_data_dir_path may be

@rishubhjain
Copy link
Contributor Author

rishubhjain commented Oct 4, 2017

@shtripat I have made the necessary changes, Please review

str(cluster_id),
"archive", "volumes")
if not os.path.exists(archive_path):
os.system("mkdir -p " + str(archive_path))
Copy link
Member

Choose a reason for hiding this comment

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

os module has "makedirs" function, you can directly use that.
example: os.makedirs("a/b/c")

return None


def update_graphite(self, cluster_id, resource_name, resource_type):
Copy link
Member

Choose a reason for hiding this comment

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

can we divide this function into submodules? The function is way too long, which makes it difficult to read, understand and review.

"deletion from graphite failed"})
archive_path = os.path.join(archive_path,
"volumes", vol_name)
os.system("mkdir -p " + str(archive_path))
Copy link
Member

Choose a reason for hiding this comment

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

same as above

str(cluster_id),
"archive", "nodes")
if not os.path.exists(archive_path):
os.system("mkdir -p " + str(archive_path))
Copy link
Member

Choose a reason for hiding this comment

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

same as above

for vol_name in volume_affected_list:
archive_path = os.path.join(archive_path,
"volumes", vol_name)
os.system("mkdir -p " + str(archive_path))
Copy link
Member

Choose a reason for hiding this comment

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

same as above

resource_folder_name = str(host_name) + "_" + \
str(datetime.datetime.now().isoformat())
archive_path = os.path.join(archive_path, resource_folder_name)
os.system("mkdir -p " + str(archive_path))
Copy link
Member

Choose a reason for hiding this comment

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

same as above

@rishubhjain
Copy link
Contributor Author

@cloudbehl I have made the changes, Please review

subvolume)
brick_list = create_dashboards.get_resource_keys("", subvolume_brick_key)
if flag:
flag = False
Copy link
Member

Choose a reason for hiding this comment

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

Where is flag being set as True?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Ah my bad didnt check down enough :) Ack


def run(self):
super(UpdateGraphite, self).run()
cluster_id = self.parameters.get("TendrlContext.integration_id")
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not cluster_id, stop adding confusing code and use integration_id everywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@r0h4n Made the required changes, Will make changes in other files also in separate PR

@r0h4n r0h4n merged commit 1b8a4c1 into Tendrl:master Oct 5, 2017
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.

4 participants