From a1fb1dccaf4a8cb215920ada23026aad17ed21b2 Mon Sep 17 00:00:00 2001 From: andrii-codefresh Date: Thu, 26 Oct 2023 14:30:07 +0300 Subject: [PATCH] logs --- VERSION | 2 +- .../version_config_manager.go | 3 ++- .../application/application_event_reporter.go | 27 +++++++++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 30404fe992bda..d3c1d0e3b22ca 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.8.1-cap-CR-app-version \ No newline at end of file +2.8.1-cap-CR-app-version3 \ No newline at end of file diff --git a/pkg/version_config_manager/version_config_manager.go b/pkg/version_config_manager/version_config_manager.go index c4be2e79ca946..46ba14d83a0fe 100644 --- a/pkg/version_config_manager/version_config_manager.go +++ b/pkg/version_config_manager/version_config_manager.go @@ -2,6 +2,7 @@ package version_config_manager import ( "errors" + log "github.com/sirupsen/logrus" ) @@ -78,7 +79,7 @@ func GetVersionConfig() *VersionConfig { versionConfig, err := versionConfigManager.ObtainConfig() if err != nil { - log.Printf("ERROR: Failed to obtain config: %v", err) + log.Printf("Failed to obtain config: %v", err) return nil } diff --git a/server/application/application_event_reporter.go b/server/application/application_event_reporter.go index 9019238bbf07e..e8bd0a4896e2e 100644 --- a/server/application/application_event_reporter.go +++ b/server/application/application_event_reporter.go @@ -177,7 +177,7 @@ func (s *applicationEventReporter) streamApplicationEvents( return nil } - logWithAppStatus(a, logCtx, ts).Info("sending root application event") + logWithAppStatus(a, logCtx, ts).Infof("sending root application event %v", appEvent) if err := stream.Send(appEvent); err != nil { return fmt.Errorf("failed to send event for root application %s/%s: %w", a.Namespace, a.Name, err) } @@ -305,7 +305,7 @@ func (s *applicationEventReporter) processResource( appRes := appv1.Application{} if isApp(rs) && actualState.Manifest != nil && json.Unmarshal([]byte(*actualState.Manifest), &appRes) == nil { - logWithAppStatus(&appRes, logCtx, ts).Info("streaming resource event") + logWithAppStatus(&appRes, logCtx, ts).Infof("streaming resource event %v", ev) } else { logWithResourceStatus(logCtx, rs).Info("streaming resource event") } @@ -612,6 +612,14 @@ func getResourceEventPayload( Errors: errors, AppVersions: applicationVersionsEvents, } + payload.AppVersions.AppVersion = nil + logCtx.Infof("AppVersion before encoding: %v", safeString(payload.AppVersions.AppVersion)) + logCtx.Infof( + "AppVersion deps before encoding: %v ||| %v ||| %v", + safeString(payload.AppVersions.Dependencies.Lock), + safeString(payload.AppVersions.Dependencies.Deps), + safeString(payload.AppVersions.Dependencies.Requirements), + ) payloadBytes, err := json.Marshal(&payload) if err != nil { @@ -720,6 +728,14 @@ func (s *applicationEventReporter) getApplicationEventPayload( AppVersions: applicationVersionsEvents, } + logCtx.Infof("AppVersion before encoding: %v", safeString(payload.AppVersions.AppVersion)) + logCtx.Infof( + "AppVersion deps before encoding: %v ||| %v ||| %v", + safeString(payload.AppVersions.Dependencies.Lock), + safeString(payload.AppVersions.Dependencies.Deps), + safeString(payload.AppVersions.Dependencies.Requirements), + ) + payloadBytes, err := json.Marshal(&payload) if err != nil { return nil, fmt.Errorf("failed to marshal payload for resource %s/%s: %w", a.Namespace, a.Name, err) @@ -799,3 +815,10 @@ func repoAppVersionsToEvent(applicationVersions *apiclient.ApplicationVersions) } return applicationVersionsEvents, nil } + +func safeString(s *string) string { + if s == nil { + return "" + } + return *s +}