import rhc-0.2.1-11.el9_1

c9 imports/c9/rhc-0.2.1-11.el9_1
CentOS Sources 2 years ago committed by MSVSphere Packaging Team
parent 10dbc1eeae
commit 0d4356435b

@ -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
Version: 0.2.1
Release: 10%{?dist}
Release: 11%{?dist}
Epoch: 1
Summary: rhc connects the system to Red Hat hosted services
License: GPLv3
@ -24,6 +24,8 @@ Source4: rhc-package-manager.toml
Patch0: 0001-feat-default-config-file-location.patch
# Fixed upstream https://github.com/RedHatInsights/rhc/commit/0e3ce2489f92cc037936866a1d6d7901fb14d440
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}
@ -79,6 +81,8 @@ cd %{_builddir}/%{name}/yggdrasil-worker-package-manager
%patch0 -p0
cd %{_builddir}/%{name}/%{name}-%{version}
%patch1 -p1
cd %{_builddir}/%{name}/yggdrasil-%{yggdrasil_ver}
%patch2 -p1
%build
@ -143,6 +147,9 @@ fi
%changelog
* 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
- Set SELinux policy to permissive for rhcd_t module (RHBZ#2141445)

Loading…
Cancel
Save