Skip to content

Commit b75c13d

Browse files
authored
[Fixbug]: Fix delete default HFT configuration issue (#4025)
What I did This PR is for fixing a bug that telemetry_tam object may not be deleted after the default HFT profile removed. Why I did it To the default profile, its group is empty, so the original checker isEmpty will be unable to capture the group deletion message.
1 parent 9949fbe commit b75c13d

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

orchagent/high_frequency_telemetry/hftelorch.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ task_process_status HFTelOrch::profileTableDel(const std::string &profile_name)
228228
return task_process_status::task_need_retry;
229229
}
230230

231-
if (!profile_itr->second->isEmpty())
231+
if (!profile_itr->second->isEmpty() || isProfileInUse(profile_itr->second))
232232
{
233233
return task_process_status::task_need_retry;
234234
}
@@ -355,6 +355,21 @@ std::shared_ptr<HFTelProfile> HFTelOrch::tryGetProfile(const std::string &profil
355355
return std::shared_ptr<HFTelProfile>();
356356
}
357357

358+
bool HFTelOrch::isProfileInUse(const std::shared_ptr<HFTelProfile> &profile) const
359+
{
360+
SWSS_LOG_ENTER();
361+
362+
for (const auto &type_profiles : m_type_profile_mapping)
363+
{
364+
if (type_profiles.second.find(profile) != type_profiles.second.end())
365+
{
366+
return true;
367+
}
368+
}
369+
370+
return false;
371+
}
372+
358373
void HFTelOrch::doTask(swss::NotificationConsumer &consumer)
359374
{
360375
SWSS_LOG_ENTER();

orchagent/high_frequency_telemetry/hftelorch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class HFTelOrch : public Orch
4646
task_process_status groupTableDel(const std::string &profile_name, const std::string &group_name);
4747
std::shared_ptr<HFTelProfile> getProfile(const std::string &profile_name);
4848
std::shared_ptr<HFTelProfile> tryGetProfile(const std::string &profile_name);
49+
bool isProfileInUse(const std::shared_ptr<HFTelProfile> &profile) const;
4950

5051
void doTask(swss::NotificationConsumer &consumer);
5152
void doTask(Consumer &consumer);

tests/test_hft.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,45 @@ def test_hft_multiple_groups(self, dvs, testlog):
514514
# Clean up profile
515515
self.delete_hft_profile(dvs)
516516

517+
def test_hft_empty_default_config_cleanup(self, dvs, testlog):
518+
"""Test that TAM_TELEMETRY objects are properly cleaned up when deleting
519+
a default HFT profile with empty object_names and object_counters."""
520+
# Create default HFT profile
521+
self.create_hft_profile(dvs, name="default", status="enabled")
522+
523+
# Create HFT group with empty object_names and object_counters
524+
self.create_hft_group(dvs,
525+
profile_name="default",
526+
group_name="PORT",
527+
object_names="",
528+
object_counters="")
529+
530+
# Wait for processing
531+
time.sleep(3)
532+
533+
# Get ASIC DB objects and verify TAM_TELEMETRY exists
534+
asic_db = self.get_asic_db_objects(dvs)
535+
assert len(asic_db["tam_telemetry"]) > 0, \
536+
"Expected TAM_TELEMETRY object to exist before deletion"
537+
538+
# Delete profile first
539+
self.delete_hft_profile(dvs, name="default")
540+
541+
# Sleep for 1 second
542+
time.sleep(1)
543+
544+
# Delete group
545+
self.delete_hft_group(dvs, profile_name="default", group_name="PORT")
546+
547+
# Wait for cleanup
548+
time.sleep(2)
549+
550+
# Verify TAM_TELEMETRY object is deleted
551+
asic_db = self.get_asic_db_objects(dvs)
552+
assert len(asic_db["tam_telemetry"]) == 0, \
553+
"Expected TAM_TELEMETRY object to be deleted after profile and group deletion"
554+
555+
517556
# Add Dummy always-pass test at end as workaroud
518557
# for issue when Flaky fail on final test it invokes module tear-down before retrying
519558
def test_nonflaky_dummy():

0 commit comments

Comments
 (0)