0001-Fix-faulty-runc-version-commit-scrape.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. From 324e7be4b252c13002bca6a9d82e7b2e43664634 Mon Sep 17 00:00:00 2001
  2. From: Christian Stewart <christian@paral.in>
  3. Date: Mon, 26 Nov 2018 22:59:32 -0800
  4. Subject: [PATCH] Fix faulty runc version commit scrape
  5. This commit replaces faulty logic to determine the runc version commit hash.
  6. The original logic takes the second line of the output of "runc --version" and
  7. does not work if there are a different number of lines printed from the command
  8. than expected. The buildroot version of runc outputs two lines instead of the
  9. expected three, causing the error:
  10. unknown output format: runc version commit: ...
  11. This patch replaces this logic with a simple scan of the "runc --version"
  12. output, searching for the "runc version commit" prefixed line.
  13. Signed-off-by: Christian Stewart <christian@paral.in>
  14. ---
  15. daemon/info_unix.go | 9 +++++----
  16. 1 file changed, 5 insertions(+), 4 deletions(-)
  17. diff --git a/daemon/info_unix.go b/daemon/info_unix.go
  18. index 60b2f99870..688a510796 100644
  19. --- a/daemon/info_unix.go
  20. +++ b/daemon/info_unix.go
  21. @@ -32,10 +32,11 @@ func (daemon *Daemon) fillPlatformInfo(v *types.Info, sysInfo *sysinfo.SysInfo)
  22. defaultRuntimeBinary := daemon.configStore.GetRuntime(v.DefaultRuntime).Path
  23. if rv, err := exec.Command(defaultRuntimeBinary, "--version").Output(); err == nil {
  24. parts := strings.Split(strings.TrimSpace(string(rv)), "\n")
  25. - if len(parts) == 3 {
  26. - parts = strings.Split(parts[1], ": ")
  27. - if len(parts) == 2 {
  28. - v.RuncCommit.ID = strings.TrimSpace(parts[1])
  29. + for _, pt := range parts {
  30. + ptKv := strings.Split(pt, ":")
  31. + if strings.HasSuffix(strings.TrimSpace(ptKv[0]), "commit") {
  32. + v.RuncCommit.ID = strings.TrimSpace(ptKv[1])
  33. + break
  34. }
  35. }
  36. --
  37. 2.18.1