diff --git a/pkg/compression/compression.go b/pkg/compression/compression.go index 2e695ad45..f593c81d3 100644 --- a/pkg/compression/compression.go +++ b/pkg/compression/compression.go @@ -17,18 +17,19 @@ package compression import ( "bytes" "compress/gzip" - "log" + + "github.com/go-logr/logr" ) -func CompressString(str string) []byte { +func CompressString(str string, log logr.Logger) []byte { var b bytes.Buffer gz := gzip.NewWriter(&b) if _, err := gz.Write([]byte(str)); err != nil { - log.Fatal(err) + log.Error(err, "Failed to compress string") } if err := gz.Close(); err != nil { - log.Fatal(err) + log.Error(err, "Failed to close writer for compress string") } return b.Bytes() diff --git a/pkg/resources/fluentd/appconfigmap.go b/pkg/resources/fluentd/appconfigmap.go index 477cd4114..5fbea9084 100644 --- a/pkg/resources/fluentd/appconfigmap.go +++ b/pkg/resources/fluentd/appconfigmap.go @@ -40,7 +40,7 @@ func (r *Reconciler) appConfigSecret() (runtime.Object, reconciler.DesiredState, if r.Logging.Spec.FluentdSpec.CompressConfigFile { AppConfigKeyCompress := AppConfigKey + ".gz" - data[AppConfigKeyCompress] = compression.CompressString(*r.config) + data[AppConfigKeyCompress] = compression.CompressString(*r.config, r.Log) } else { data[AppConfigKey] = []byte(*r.config) } @@ -206,7 +206,7 @@ func (r *Reconciler) newCheckSecret(hashKey string) (*corev1.Secret, error) { } if r.Logging.Spec.FluentdSpec.CompressConfigFile { ConfigCheckKeyCompress := ConfigCheckKey + ".gz" - data[ConfigCheckKeyCompress] = compression.CompressString(*r.config) + data[ConfigCheckKeyCompress] = compression.CompressString(*r.config, r.Log) } else { data[ConfigCheckKey] = []byte(*r.config) } @@ -222,7 +222,7 @@ func (r *Reconciler) newCheckSecretAppConfig(hashKey string) (*corev1.Secret, er if r.Logging.Spec.FluentdSpec.CompressConfigFile { ConfigCheckKeyCompress := ConfigCheckKey + ".gz" - data[ConfigCheckKeyCompress] = compression.CompressString(*r.config) + data[ConfigCheckKeyCompress] = compression.CompressString(*r.config, r.Log) } else { data[ConfigCheckKey] = []byte(*r.config) }