@@ -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
@@ -143,8 +144,8 @@ void BufferMgr::doSpeedUpdateTask(string port, string speed)
143
144
if (mode.empty ())
144
145
{
145
146
// this should never happen if switch initialized properly
146
- SWSS_LOG_ERROR (" PG lossless pool is not yet created" );
147
- return ;
147
+ SWSS_LOG_WARN (" PG lossless pool is not yet created" );
148
+ return task_process_status::task_need_retry ;
148
149
}
149
150
150
151
// profile threshold field name
@@ -170,6 +171,7 @@ void BufferMgr::doSpeedUpdateTask(string port, string speed)
170
171
string profile_ref = string (" [" ) + CFG_BUFFER_PROFILE_TABLE_NAME + CONFIGDB_TABLE_NAME_SEPARATOR + buffer_profile_key + " ]" ;
171
172
fvVector.push_back (make_pair (" profile" , profile_ref));
172
173
m_cfgBufferPgTable.set (buffer_pg_key, fvVector);
174
+ return task_process_status::task_success;
173
175
}
174
176
175
177
void BufferMgr::doTask (Consumer &consumer)
@@ -188,25 +190,41 @@ void BufferMgr::doTask(Consumer &consumer)
188
190
string port (keys[0 ]);
189
191
190
192
string op = kfvOp (t);
193
+ task_process_status task_status = task_process_status::task_success;
191
194
if (op == SET_COMMAND)
192
195
{
193
196
for (auto i : kfvFieldsValues (t))
194
197
{
195
198
if (table_name == CFG_PORT_CABLE_LEN_TABLE_NAME)
196
199
{
197
200
// receive and cache cable length table
198
- doCableTask (fvField (i), fvValue (i));
201
+ task_status = doCableTask (fvField (i), fvValue (i));
199
202
}
200
203
// In case of PORT table update, Buffer Manager is interested in speed update only
201
204
if (table_name == CFG_PORT_TABLE_NAME && fvField (i) == " speed" )
202
205
{
203
206
// create/update profile for port
204
- doSpeedUpdateTask (port, fvValue (i));
207
+ task_status = doSpeedUpdateTask (port, fvValue (i));
208
+ }
209
+ if (task_status != task_process_status::task_success)
210
+ {
211
+ break ;
205
212
}
206
213
}
207
214
}
208
215
209
- it = consumer.m_toSync .erase (it);
210
- continue ;
216
+ switch (task_status)
217
+ {
218
+ case task_process_status::task_failed:
219
+ SWSS_LOG_ERROR (" Failed to process table update" );
220
+ return ;
221
+ case task_process_status::task_need_retry:
222
+ SWSS_LOG_INFO (" Unable to process table update. Will retry..." );
223
+ ++it;
224
+ break ;
225
+ default :
226
+ it = consumer.m_toSync .erase (it);
227
+ break ;
228
+ }
211
229
}
212
230
}
0 commit comments