Skip to content

Commit f5b9a90

Browse files
committed
Better error message when nics aren't programmed
1 parent faa9c44 commit f5b9a90

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cns/restserver/internalapi.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,20 @@ func (service *HTTPRestService) SyncHostNCVersion(ctx context.Context, channelMo
175175
defer service.Unlock()
176176
start := time.Now()
177177
programmedNCCount, err := service.syncHostNCVersion(ctx, channelMode)
178+
178179
// even if we get an error, we want to write the CNI conflist if we have any NC programmed to any version
179180
if programmedNCCount > 0 {
180181
// This will only be done once per lifetime of the CNS process. This function is threadsafe and will panic
181182
// if it fails, so it is safe to call in a non-preemptable goroutine.
182183
go service.MustGenerateCNIConflistOnce()
184+
} else {
185+
logger.Printf("No NCs programmed on this host yet, skipping CNI conflist generation")
183186
}
187+
184188
if err != nil {
185189
logger.Errorf("sync host error %v", err)
186190
}
191+
187192
syncHostNCVersionCount.WithLabelValues(strconv.FormatBool(err == nil)).Inc()
188193
syncHostNCVersionLatency.WithLabelValues(strconv.FormatBool(err == nil)).Observe(time.Since(start).Seconds())
189194
}
@@ -302,7 +307,7 @@ func (service *HTTPRestService) syncHostNCVersion(ctx context.Context, channelMo
302307
// if we didn't empty out the needs update set, NMA has not programmed all the NCs we are expecting, and we
303308
// need to return an error indicating that
304309
if len(outdatedNCs) > 0 {
305-
return len(programmedNCs), errors.Errorf("unable to update some NCs: %v, missing or bad response from NMA or IMDS", outdatedNCs)
310+
return len(programmedNCs), errors.Errorf("Have outdated NCs: %v, Current Programmed nics from NMA/IMDS %v", outdatedNCs, programmedNCs)
306311
}
307312

308313
return len(programmedNCs), nil

0 commit comments

Comments
 (0)