Skip to content

[aclshow] fix aclshow when clear is called before counters are populated#2037

Merged
liat-grozovik merged 2 commits intosonic-net:masterfrom
stepanblyschak:fix-aclshow-after-counters-repopulate
Feb 20, 2022
Merged

[aclshow] fix aclshow when clear is called before counters are populated#2037
liat-grozovik merged 2 commits intosonic-net:masterfrom
stepanblyschak:fix-aclshow-after-counters-repopulate

Conversation

@stepanblyschak
Copy link
Contributor

Signed-off-by: Stepan Blyschak stepanb@nvidia.com

What I did

Fixed a bug that in case ACL counters are cleared before counters are populated in COUNTERS DB the next aclshow will fail:

admin@sonic:~$ aclshow -c -t DATAACL
admin@sonic:~$ aclshow -a -t DATAACL
'NoneType' object is not subscriptable  

How I did it

Keep self.acl_counters in sync with COUNTERS DB and don't put empty values when no counters are available, so when dumping counters and loading them back there are no empty values.

How to verify it

Without this change the added UT fails:

self = <aclshow.AclStat object at 0x7f0208277438>, key = ('DATAACL_NO_COUNTER', 'RULE_NO_COUNTER'), type = 'SAI_ACL_COUNTER_ATTR_PACKETS'
                                                                                     
    def get_counter_value(self, key, type):                                          
        """                                                                          
        return the counter value or the difference comparing with the saved value in string format
        """                                                                          
        if not self.acl_counters[key]:                                               
            return 'N/A'                                                             
                                                                                     
        if key in self.saved_acl_counters: 
>           new_value = int(self.acl_counters[key][type]) - int(self.saved_acl_counters[key][type])
E           TypeError: 'NoneType' object is not subscriptable  

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

NOTES:

Request to cherry-pick to 202111.

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
@stepanblyschak
Copy link
Contributor Author

/Azpw.run

@stepanblyschak
Copy link
Contributor Author

/Azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bingwang-ms
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@stepanblyschak
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liat-grozovik liat-grozovik merged commit a9bbaf2 into sonic-net:master Feb 20, 2022
judyjoseph pushed a commit that referenced this pull request Feb 22, 2022
…ted (#2037)

- What I did
Fixed a bug that in case ACL counters are cleared before counters are populated in COUNTERS DB the next aclshow will fail:
admin@sonic:~$ aclshow -c -t DATAACL
admin@sonic:~$ aclshow -a -t DATAACL
'NoneType' object is not subscriptable  

- How I did it
Keep self.acl_counters in sync with COUNTERS DB and don't put empty values when no counters are available, so when dumping counters and loading them back there are no empty values.

- How to verify it
Without this change the added UT fails:

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants