@@ -72,9 +72,10 @@ void BufferMgr::readPgProfileLookupFile(string file)
72
72
infile.close ();
73
73
}
74
74
75
- void BufferMgr::doCableTask (string port, string cable_length)
75
+ task_process_status BufferMgr::doCableTask (string port, string cable_length)
76
76
{
77
77
m_cableLenLookup[port] = cable_length;
78
+ return task_process_status::task_success;
78
79
}
79
80
80
81
string BufferMgr::getPgPoolMode ()
@@ -108,7 +109,7 @@ Create/update two tables: profile (in m_cfgBufferProfileTable) and port buffer (
108
109
}
109
110
}
110
111
*/
111
- void BufferMgr::doSpeedUpdateTask (string port, string speed)
112
+ task_process_status BufferMgr::doSpeedUpdateTask (string port, string speed)
112
113
{
113
114
vector<FieldValueTuple> fvVector;
114
115
string cable;
@@ -117,7 +118,7 @@ void BufferMgr::doSpeedUpdateTask(string port, string speed)
117
118
{
118
119
/* Set to NOTICE since cable length could be left empty */
119
120
SWSS_LOG_NOTICE (" Unable to create/update PG profile for port %s. Cable length is not set" , port.c_str ());
120
- return ;
121
+ return task_process_status::task_need_retry ;
121
122
}
122
123
123
124
cable = m_cableLenLookup[port];
@@ -126,7 +127,7 @@ void BufferMgr::doSpeedUpdateTask(string port, string speed)
126
127
{
127
128
SWSS_LOG_ERROR (" Unable to create/update PG profile for port %s. No PG profile configured for speed %s and cable length %s" ,
128
129
port.c_str (), speed.c_str (), cable.c_str ());
129
- return ;
130
+ return task_process_status::task_invalid_entry ;
130
131
}
131
132
132
133
// Crete record in BUFFER_PROFILE table
@@ -144,8 +145,8 @@ void BufferMgr::doSpeedUpdateTask(string port, string speed)
144
145
if (mode.empty ())
145
146
{
146
147
// this should never happen if switch initialized properly
147
- SWSS_LOG_ERROR (" PG lossless pool is not yet created" );
148
- return ;
148
+ SWSS_LOG_WARN (" PG lossless pool is not yet created" );
149
+ return task_process_status::task_need_retry ;
149
150
}
150
151
151
152
// profile threshold field name
@@ -171,6 +172,7 @@ void BufferMgr::doSpeedUpdateTask(string port, string speed)
171
172
string profile_ref = string (" [" ) + CFG_BUFFER_PROFILE_TABLE_NAME + CONFIGDB_TABLE_NAME_SEPARATOR + buffer_profile_key + " ]" ;
172
173
fvVector.push_back (make_pair (" profile" , profile_ref));
173
174
m_cfgBufferPgTable.set (buffer_pg_key, fvVector);
175
+ return task_process_status::task_success;
174
176
}
175
177
176
178
void BufferMgr::doTask (Consumer &consumer)
@@ -189,25 +191,45 @@ void BufferMgr::doTask(Consumer &consumer)
189
191
string port (keys[0 ]);
190
192
191
193
string op = kfvOp (t);
194
+ task_process_status task_status = task_process_status::task_success;
192
195
if (op == SET_COMMAND)
193
196
{
194
197
for (auto i : kfvFieldsValues (t))
195
198
{
196
199
if (table_name == CFG_PORT_CABLE_LEN_TABLE_NAME)
197
200
{
198
201
// receive and cache cable length table
199
- doCableTask (fvField (i), fvValue (i));
202
+ task_status = doCableTask (fvField (i), fvValue (i));
200
203
}
201
204
// In case of PORT table update, Buffer Manager is interested in speed update only
202
205
if (table_name == CFG_PORT_TABLE_NAME && fvField (i) == " speed" )
203
206
{
204
207
// create/update profile for port
205
- doSpeedUpdateTask (port, fvValue (i));
208
+ task_status = doSpeedUpdateTask (port, fvValue (i));
209
+ }
210
+ if (task_status != task_process_status::task_success)
211
+ {
212
+ break ;
206
213
}
207
214
}
208
215
}
209
216
210
- it = consumer.m_toSync .erase (it);
211
- continue ;
217
+ switch (task_status)
218
+ {
219
+ case task_process_status::task_failed:
220
+ SWSS_LOG_ERROR (" Failed to process table update" );
221
+ return ;
222
+ case task_process_status::task_need_retry:
223
+ SWSS_LOG_INFO (" Unable to process table update. Will retry..." );
224
+ ++it;
225
+ break ;
226
+ case task_process_status::task_invalid_entry:
227
+ SWSS_LOG_ERROR (" Failed to process invalid entry, drop it" );
228
+ it = consumer.m_toSync .erase (it);
229
+ break ;
230
+ default :
231
+ it = consumer.m_toSync .erase (it);
232
+ break ;
233
+ }
212
234
}
213
235
}
0 commit comments