-
Notifications
You must be signed in to change notification settings - Fork 36
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: handle array as comma separated value in zapi #1810
Conversation
Fix #1360 |
As no extra symbol for array handling in Zapi, we don't need any documentation change for this. |
For Array case, response would be something like this: printed as
|
@@ -279,7 +287,13 @@ func (z *Zapi) PollData() (map[string]*matrix.Matrix, error) { | |||
} | |||
|
|||
for _, child := range node.GetChildren() { | |||
fetch(instance, child, newpath) | |||
uniqueNames := util.RemoveDuplicateStr(child.GetAllChildNamesS()) | |||
if len(child.GetAllChildNamesS()) > 1 && len(uniqueNames) < len(child.GetAllChildNamesS()) && len(uniqueNames) == 1 { |
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.
since child.GetAllChildNamesS()
does work and allocations, better to calculate once
also not sure I completely understand this logic - an array is defined as:
- multiple child elements (makes sense)
- where those children have duplicates (why can an array have duplicates?)
- where those duplicates unique to a single item (why?)
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.
This is one of the response o/p:
<volume-id-attributes>
<aggr-list>
<aggr-name>Ak_Aggregate</aggr-name>
<aggr-name>Ak_Aggregate_HE</aggr-name>
<aggr-name>puk_aggr2_on_154</aggr-name>
<aggr-name>puk_aggr3_on_154</aggr-name>
</aggr-list>
<instance-uuid>ce6d03e9-be1c-11eb-b50d-00a098d7b0b9</instance-uuid>
<name>test_flexgroup_dont_delete_1</name>
<owning-vserver-name>svm_workload_dont_delete_1622024777713</owning-vserver-name>
<style-extended>flexgroup</style-extended>
<type>rw</type>
</volume-id-attributes>
For node volume-id-attributes
, child elements are : [aggr-list instance-uuid name owning-vserver-name style-extended type]
Whereas for node aggr-list
, child elements are: [aggr-name aggr-name aggr-name aggr-name]
So,
Case 1: Parent node have multiple different child elements Ex. volume-id-attributes
Case 2: Parent node may have few duplicates and few unique child elements (I am not much sure about this case)
Case 3: Parent node have multiple same child elements Ex. aggr-list
, which eventually only 1 child with array case.
// Handling array with comma separated values | ||
previousValue := instance.GetLabel(label) | ||
if isAppend && previousValue != "" { | ||
instance.SetLabel(label, previousValue+","+value) |
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.
In past we have been setting empty for array elements. That needs to be fixed as well.
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.
Out of 4 volume plugin(zapi, zapiperf, rest, restperf),
- zapiperf and restperf are exact same and handling
aggr
,node
as perf call don't have this array in response. --> no changes required. - zapi don't have any handling for flexgroup.
- rest has this below handling for
aggruuid
and it still holds true as zapi don't handle aggruuid for flexgroup.
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.
How is isHardwareEncrypted
handled for flexgroup if aggruuid is always empty for it? Also comment about aggrUUid in code doesn't match if Zapi doesn't do it this way.
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.
So, Zapi would handle this way,
First populate aggrsDisksMap
and then populate aggrsMap
.
For flexgroup, which span across multiple aggregates, it can't be part of any map.
So for them label isHardwareEncrypted
alway be false.
for _, aggrDiskData := range result {
aggrUUID := aggrDiskData.GetChildContentS("aggregate-uuid")
aggrName := aggrDiskData.GetChildContentS("aggregate")
aggrDiskList := aggrDiskData.GetChildS("aggr-plex-list").GetChildS("aggr-plex-info").GetChildS("aggr-raidgroup-list").GetChildS("aggr-raidgroup-info").GetChildS("aggr-disk-list").GetChildren()
for _, aggrDisk := range aggrDiskList {
diskName = aggrDisk.GetChildContentS("disk")
aggrsDisksMap[diskName] = aggrData{aggrUUID: aggrUUID, aggrName: aggrName}
}
}
return aggrsDisksMap, nil
func (my *Volume) updateAggrMap(disks []string, aggrDiskMap map[string]aggrData) {
if disks != nil && aggrDiskMap != nil {
// Clean aggrsMap map
my.aggrsMap = make(map[string]string)
for _, disk := range disks {
aggr := aggrDiskMap[disk]
my.aggrsMap[aggr.aggrUUID] = aggr.aggrName
}
}
}
- ^owning-vserver-name => svm | ||
- ^containing-aggregate-name => aggr | ||
- aggr-list: | ||
- ^aggr-name => aggr |
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.
We should revisit added metrics volume_aggr_labels which were added last release. Let's discuss if it is safe to remove them or we want to keep publishing them.
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.
for now, I don't change it and based on our discussion we will take call on volume_aggr_labels
.
// Handling array with comma separated values | ||
previousValue := instance.GetLabel(label) | ||
if isAppend && previousValue != "" { | ||
instance.SetLabel(label, previousValue+","+value) |
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.
How is isHardwareEncrypted
handled for flexgroup if aggruuid is always empty for it? Also comment about aggrUUid in code doesn't match if Zapi doesn't do it this way.
looks good. Completes Zapi gap with Rest 💯 |
Tested with Volume and NetworkInterface object.
For Volume, with changes:
For NetworkInterface, custom Rest:
For NetworkInterface, custom zapi, with changes,