-
Notifications
You must be signed in to change notification settings - Fork 20
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
Calculating and updtating cluster and volume alert_count in each cluster sync #599
Conversation
@shtripat @shirshendu @r0h4n please review |
only provisioning node will do alert_count update |
Codecov Report
@@ Coverage Diff @@
## master #599 +/- ##
==========================================
- Coverage 39.66% 39.63% -0.03%
==========================================
Files 70 70
Lines 2607 2614 +7
Branches 374 376 +2
==========================================
+ Hits 1034 1036 +2
- Misses 1542 1547 +5
Partials 31 31
Continue to review full report at Codecov.
|
def find_volume_id(): | ||
alert_counts = {} | ||
volumes = etcd_utils.read( | ||
"clusters/%s/Volumes" % NS.tendrl_context.integration_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Volume.load_all()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will change this
|
||
def find_volume_id(): | ||
alert_counts = {} | ||
volumes = etcd_utils.read( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use NS.gluster.objects.Volume().load_all()
here ? I feel all you need is volume names then form the dict.
Also call the function as get_volume_alert_counts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
severity = ["WARNING", "CRITICAL"] | ||
try: | ||
alert_counts = find_volume_id() | ||
alerts_arr = NS.tendrl.objects.ClusterAlert( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to load all the cluster alerts using tags only? Don't you need integration_id here? Does it default to NS.tendrl_context.integration_id in object constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shtripat for the cluster_alert object is a subclass of alert object, so for an alert object integration_id is not a mandatory field. So for cluster alerts, integration_id is present in tags only. While forming patch cluster alert object will take integration_id from tags only. That is why i am passing only tags with integration_id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
if alert.resource in NS.gluster.objects.VolumeAlertCounters( | ||
)._defs['relationship'][alert.alert_type.lower()]: | ||
vol_name = alert.tags.get('volume_name', None) | ||
if vol_name: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add both the conditions in one if condition as if vol_name and vol_name in alert_counts.keys()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will change this
alert_count=cluster_alert_count | ||
).save() | ||
# Update volume alert count | ||
for volume in alert_counts: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand alert_counts is a dict. If so you should use something like
for vol_name, alert_det in alert_counts.iter_items():
NS.gluster.objects.VolumeAlertCounters(
integration_id=NS.tendrl_context.integration_id,
alert_count=alert_det['alert_count'],
volume_id=alert_det['vol_id']
).save()
Does this work. Even I feel the dict created in find_volume_id
functions could be with keys as volume ids and value as counters. Why you need volume name as keys? Do you really use that anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the alert object contains volume name only present in tags, to compare this alert with a particular volume i need volume name. that why i am creating dict with the volume name. During alert iteration, i am just comparing volume name from alert object with newly formed dict to increase the alert count.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@shtripat changes done |
continue | ||
volumes = NS.gluster.objects.Volume().load_all() | ||
for volume in volumes: | ||
alert_counts[volume.name] = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can do the whole thing in one line
alert_counts[volume.name] = {"vol_id": volume.vol_id, "alert_count": 0}
ff21148
to
e30cbe5
Compare
@shtripat changes done |
severity = ["WARNING", "CRITICAL"] | ||
try: | ||
alert_counts = get_volume_alert_counts() | ||
alerts_arr = NS.tendrl.objects.ClusterAlert( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alerts
is good enough name :)
Looks fine. One small suggestion. |
@shtripat changes done, i verified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please resolve conflicts
…ter sync tendrl-bug-id: Tendrl#598 Signed-off-by: GowthamShanmugasundaram <[email protected]>
tendrl-bug-id: Tendrl#598 Signed-off-by: GowthamShanmugasundaram <[email protected]>
tendrl-bug-id: Tendrl#598 Signed-off-by: GowthamShanmugasundaram <[email protected]>
3595e93
to
4787a92
Compare
tendrl-bug-id: #598
Signed-off-by: GowthamShanmugasundaram [email protected]