@@ -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,15 +109,15 @@ 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;
115
116
116
117
if (m_cableLenLookup.count (port) == 0 )
117
118
{
118
- SWSS_LOG_ERROR (" Unable to create/update PG profile for port %s. Cable length is not set" , port.c_str ());
119
- return ;
119
+ SWSS_LOG_WARN (" Unable to create/update PG profile for port %s. Cable length is not set" , port.c_str ());
120
+ return task_process_status::task_need_retry ;
120
121
}
121
122
122
123
cable = m_cableLenLookup[port];
@@ -125,7 +126,7 @@ void BufferMgr::doSpeedUpdateTask(string port, string speed)
125
126
{
126
127
SWSS_LOG_ERROR (" Unable to create/update PG profile for port %s. No PG profile configured for speed %s and cable length %s" ,
127
128
port.c_str (), speed.c_str (), cable.c_str ());
128
- return ;
129
+ return task_process_status::task_failed ;
129
130
}
130
131
131
132
// Crete record in BUFFER_PROFILE table
@@ -142,8 +143,8 @@ void BufferMgr::doSpeedUpdateTask(string port, string speed)
142
143
if (mode.empty ())
143
144
{
144
145
// this should never happen if switch initialized properly
145
- SWSS_LOG_ERROR (" PG lossless pool is not yet created" );
146
- return ;
146
+ SWSS_LOG_WARN (" PG lossless pool is not yet created" );
147
+ return task_process_status::task_need_retry ;
147
148
}
148
149
149
150
// profile threshold field name
@@ -180,6 +181,7 @@ void BufferMgr::doSpeedUpdateTask(string port, string speed)
180
181
181
182
fvVector.push_back (make_pair (" profile" , profile_ref));
182
183
m_cfgBufferPgTable.set (buffer_pg_key, fvVector);
184
+ return task_process_status::task_success;
183
185
}
184
186
185
187
void BufferMgr::doTask (Consumer &consumer)
@@ -198,25 +200,41 @@ void BufferMgr::doTask(Consumer &consumer)
198
200
string port (keys[0 ]);
199
201
200
202
string op = kfvOp (t);
203
+ task_process_status task_status = task_process_status::task_success;
201
204
if (op == SET_COMMAND)
202
205
{
203
206
for (auto i : kfvFieldsValues (t))
204
207
{
205
208
if (table_name == CFG_PORT_CABLE_LEN_TABLE_NAME)
206
209
{
207
210
// receive and cache cable length table
208
- doCableTask (fvField (i), fvValue (i));
211
+ task_status = doCableTask (fvField (i), fvValue (i));
209
212
}
210
213
// In case of PORT table update, Buffer Manager is interested in speed update only
211
214
if (table_name == CFG_PORT_TABLE_NAME && fvField (i) == " speed" )
212
215
{
213
216
// create/update profile for port
214
- doSpeedUpdateTask (port, fvValue (i));
217
+ task_status = doSpeedUpdateTask (port, fvValue (i));
218
+ }
219
+ if (task_status != task_process_status::task_success)
220
+ {
221
+ break ;
215
222
}
216
223
}
217
224
}
218
225
219
- it = consumer.m_toSync .erase (it);
220
- continue ;
226
+ switch (task_status)
227
+ {
228
+ case task_process_status::task_failed:
229
+ SWSS_LOG_ERROR (" Failed to process table update" );
230
+ return ;
231
+ case task_process_status::task_need_retry:
232
+ SWSS_LOG_INFO (" Unable to process table update. Will retry..." );
233
+ ++it;
234
+ break ;
235
+ default :
236
+ it = consumer.m_toSync .erase (it);
237
+ break ;
238
+ }
221
239
}
222
240
}
0 commit comments