Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cns/restserver/internalapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,20 @@
defer service.Unlock()
start := time.Now()
programmedNCCount, err := service.syncHostNCVersion(ctx, channelMode)

// even if we get an error, we want to write the CNI conflist if we have any NC programmed to any version
if programmedNCCount > 0 {
// This will only be done once per lifetime of the CNS process. This function is threadsafe and will panic
// if it fails, so it is safe to call in a non-preemptable goroutine.
go service.MustGenerateCNIConflistOnce()
} else {
logger.Printf("No NCs programmed on this host yet, skipping CNI conflist generation")

Check failure on line 185 in cns/restserver/internalapi.go

View workflow job for this annotation

GitHub Actions / Lint (ubuntu-latest)

SA1019: logger.Printf is deprecated: The global logger is deprecated. Migrate to zap using the cns/logger/v2 package and pass the logger instead. (staticcheck)

Check failure on line 185 in cns/restserver/internalapi.go

View workflow job for this annotation

GitHub Actions / Lint (windows-latest)

SA1019: logger.Printf is deprecated: The global logger is deprecated. Migrate to zap using the cns/logger/v2 package and pass the logger instead. (staticcheck)
}

if err != nil {
logger.Errorf("sync host error %v", err)
}

syncHostNCVersionCount.WithLabelValues(strconv.FormatBool(err == nil)).Inc()
syncHostNCVersionLatency.WithLabelValues(strconv.FormatBool(err == nil)).Observe(time.Since(start).Seconds())
}
Expand Down Expand Up @@ -302,7 +307,7 @@
// if we didn't empty out the needs update set, NMA has not programmed all the NCs we are expecting, and we
// need to return an error indicating that
if len(outdatedNCs) > 0 {
return len(programmedNCs), errors.Errorf("unable to update some NCs: %v, missing or bad response from NMA or IMDS", outdatedNCs)
return len(programmedNCs), errors.Errorf("Have outdated NCs: %v, Current Programmed nics from NMA/IMDS %v", outdatedNCs, programmedNCs)
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message has grammar and capitalization issues:

  1. "Have" should be lowercase "have" (error messages typically start with lowercase)
  2. "nics" should be "NICs" (consistent with "NCs" used elsewhere)
  3. "Current Programmed" should be "currently programmed" (grammatically correct)
  4. Missing colon before the second %v placeholder

Suggested fix:

return len(programmedNCs), errors.Errorf("have outdated NCs: %v, currently programmed NICs from NMA/IMDS: %v", outdatedNCs, programmedNCs)
Suggested change
return len(programmedNCs), errors.Errorf("Have outdated NCs: %v, Current Programmed nics from NMA/IMDS %v", outdatedNCs, programmedNCs)
return len(programmedNCs), errors.Errorf("have outdated NCs: %v, currently programmed NICs from NMA/IMDS: %v", outdatedNCs, programmedNCs)

Copilot uses AI. Check for mistakes.
}

return len(programmedNCs), nil
Expand Down
Loading