import rhc-0.2.1-11.el9_1

i9c changed/i9c/rhc-0.2.1-11.el9_1
MSVSphere Packaging Team 2 years ago
parent 449842b69a
commit a4c82c7a4e

@ -0,0 +1,89 @@
From d75dc60df73a88b0a14c799f3b6f1e8f66cee3d4 Mon Sep 17 00:00:00 2001
From: Link Dupont <link@sub-pop.net>
Date: Tue, 22 Nov 2022 13:07:41 -0500
Subject: [PATCH] fix: read worker output using io.Read
Some workers output a lot of text to stderr and stdout. Rather than
scanning stderr and stdout into a buffer using a bufio.Scanner, read a
fixed number of bytes at a time. This will break lines of output from
the worker in the middle of words, making reading stdout in the logs
more difficult, but avoids the overly verbose workers from hitting the
bufio.ErrTooLong error.
Signed-off-by: Link Dupont <link@sub-pop.net>
---
cmd/yggd/exec.go | 46 +++++++++++++++++++++++++++++++++-------------
1 file changed, 33 insertions(+), 13 deletions(-)
diff --git a/cmd/yggd/exec.go b/cmd/yggd/exec.go
index 4eb1757..a2a3d29 100644
--- a/cmd/yggd/exec.go
+++ b/cmd/yggd/exec.go
@@ -1,8 +1,8 @@
package main
import (
- "bufio"
"fmt"
+ "io"
"io/ioutil"
"os"
"os/exec"
@@ -54,22 +54,42 @@ func startProcess(file string, env []string, delay time.Duration, died chan int)
log.Debugf("started process: %v", cmd.Process.Pid)
go func() {
- scanner := bufio.NewScanner(stdout)
- for scanner.Scan() {
- log.Tracef("[%v] %v", file, scanner.Text())
- }
- if err := scanner.Err(); err != nil {
- log.Errorf("cannot read from stdout: %v", err)
+ for {
+ buf := make([]byte, 4096)
+ n, err := stdout.Read(buf)
+ if n > 0 {
+ log.Tracef("[%v] %v", file, strings.TrimRight(string(buf), "\n\x00"))
+ }
+ if err != nil {
+ switch err {
+ case io.EOF:
+ log.Debugf("%v stdout reached EOF: %v", file, err)
+ return
+ default:
+ log.Errorf("cannot read from stdout: %v", err)
+ continue
+ }
+ }
}
}()
go func() {
- scanner := bufio.NewScanner(stderr)
- for scanner.Scan() {
- log.Errorf("[%v] %v", file, scanner.Text())
- }
- if err := scanner.Err(); err != nil {
- log.Errorf("cannot read from stderr: %v", err)
+ for {
+ buf := make([]byte, 4096)
+ n, err := stderr.Read(buf)
+ if n > 0 {
+ log.Errorf("[%v] %v", file, strings.TrimRight(string(buf), "\n\x00"))
+ }
+ if err != nil {
+ switch err {
+ case io.EOF:
+ log.Debugf("%v stderr reached EOF: %v", file, err)
+ return
+ default:
+ log.Errorf("cannot read from stderr: %v", err)
+ continue
+ }
+ }
}
}()
--
2.38.1

@ -8,7 +8,7 @@
Name: rhc Name: rhc
Version: 0.2.1 Version: 0.2.1
Release: 10%{?dist} Release: 11%{?dist}
Epoch: 1 Epoch: 1
Summary: rhc connects the system to Red Hat hosted services Summary: rhc connects the system to Red Hat hosted services
License: GPLv3 License: GPLv3
@ -24,6 +24,8 @@ Source4: rhc-package-manager.toml
Patch0: 0001-feat-default-config-file-location.patch Patch0: 0001-feat-default-config-file-location.patch
# Fixed upstream https://github.com/RedHatInsights/rhc/commit/0e3ce2489f92cc037936866a1d6d7901fb14d440 # Fixed upstream https://github.com/RedHatInsights/rhc/commit/0e3ce2489f92cc037936866a1d6d7901fb14d440
Patch1: 0003-fix-collect-error-messages-during-disconnect.patch Patch1: 0003-fix-collect-error-messages-during-disconnect.patch
# Fixed upstream https://github.com/RedHatInsights/yggdrasil/pull/100/commits/d75dc60df73a88b0a14c799f3b6f1e8f66cee3d4
Patch2: 0001-fix-read-worker-output-using-io.Read.patch
ExclusiveArch: %{go_arches} ExclusiveArch: %{go_arches}
@ -79,6 +81,8 @@ cd %{_builddir}/%{name}/yggdrasil-worker-package-manager
%patch0 -p0 %patch0 -p0
cd %{_builddir}/%{name}/%{name}-%{version} cd %{_builddir}/%{name}/%{name}-%{version}
%patch1 -p1 %patch1 -p1
cd %{_builddir}/%{name}/yggdrasil-%{yggdrasil_ver}
%patch2 -p1
%build %build
@ -146,6 +150,9 @@ fi
* Wed Mar 15 2023 MSVSphere Packaging Team <packager@msvsphere.ru> - 0.2.1-9 * Wed Mar 15 2023 MSVSphere Packaging Team <packager@msvsphere.ru> - 0.2.1-9
- Rebuilt for MSVSphere 9.1. - Rebuilt for MSVSphere 9.1.
* Tue Nov 22 2022 Link Dupont <link@redhat.com> - 0.2.1-11
- Fix an issue scanning worker's stdout (RHBZ#2151964)
* Thu Nov 10 2022 Link Dupont <link@redhat.com> - 0.2.1-10 * Thu Nov 10 2022 Link Dupont <link@redhat.com> - 0.2.1-10
- Set SELinux policy to permissive for rhcd_t module (RHBZ#2141445) - Set SELinux policy to permissive for rhcd_t module (RHBZ#2141445)

Loading…
Cancel
Save