Skip to content

Commit

Permalink
adjust log level of some rather important messages
Browse files Browse the repository at this point in the history
  • Loading branch information
tremes committed Feb 2, 2024
1 parent 9db82ef commit 93e1c20
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func runOperator(operator *controller.Operator, cfg *controllercmd.ControllerCom
if data, err := os.ReadFile(serviceCACertPath); err == nil {
startingFileContent[serviceCACertPath] = data
} else {
klog.V(4).Infof("Unable to read service ca bundle: %v", err)
klog.Infof("Unable to read service ca bundle: %v", err)
}
observedFiles = append(observedFiles, serviceCACertPath)

Expand Down
4 changes: 2 additions & 2 deletions pkg/config/configobserver/secretconfigobserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (c *Controller) fetchSecret(ctx context.Context, name string) (*v1.Secret,
secret, err := c.kubeClient.CoreV1().Secrets("openshift-config").Get(ctx, name, metav1.GetOptions{})
if err != nil {
if errors.IsNotFound(err) {
klog.V(4).Infof("%s secret does not exist", name)
klog.Infof("%s secret does not exist", name)
err = nil
secret = nil
} else if errors.IsForbidden(err) {
Expand Down Expand Up @@ -246,7 +246,7 @@ func tokenFromSecret(secret *v1.Secret) (string, error) {
return "", fmt.Errorf("cluster authorization token is not valid: contains newlines")
}
if len(token) > 0 {
klog.V(4).Info("Found cloud.openshift.com token")
klog.Info("Found cloud.openshift.com token")
return token, nil
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/gather_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (g *GatherJob) GatherAndUpload(kubeConfig, protoKubeConfig *rest.Config) er
return err
}
updateDataGatherStatus(ctx, insightsV1alphaCli, dataGatherCR, &dataProcessedCon, insightsv1alpha1.Completed)
klog.V(4).Infof("Data was successfully processed. New Insights analysis for the request ID %s will be downloaded by the operator",
klog.Infof("Data was successfully processed. New Insights analysis for the request ID %s will be downloaded by the operator",
insightsRequestID)
return nil
}
Expand Down Expand Up @@ -327,7 +327,7 @@ func wasDataProcessed(ctx context.Context,
insightsRequestID string, conf *config.InsightsConfiguration) (bool, error) {
delay := conf.DataReporting.ReportPullingDelay
retryCounter := 0
klog.V(4).Infof("Initial delay when checking processing status: %v", delay)
klog.Infof("Initial delay when checking processing status: %v", delay)

var resp *http.Response
err := wait.PollUntilContextCancel(ctx, delay, false, func(ctx context.Context) (done bool, err error) {
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/periodic/periodic.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (c *Controller) Run(stopCh <-chan struct{}, initialDelay time.Duration) {
// Gather Runs the gatherers one after the other.
func (c *Controller) Gather() {
if c.isGatheringDisabled() {
klog.V(3).Info("Gather is disabled by configuration.")
klog.Info("Gather is disabled by configuration.")
return
}

Expand Down Expand Up @@ -203,13 +203,13 @@ func (c *Controller) Gather() {
name := gatherer.GetName()
start := time.Now()

klog.V(4).Infof("Running %s gatherer", gatherer.GetName())
klog.Infof("Running %s gatherer", gatherer.GetName())
functionReports, err := gather.CollectAndRecordGatherer(ctx, gatherer, c.recorder, nil)
for i := range functionReports {
allFunctionReports[functionReports[i].FuncName] = functionReports[i]
}
if err == nil {
klog.V(3).Infof("Periodic gather %s completed in %s", name, time.Since(start).Truncate(time.Millisecond))
klog.Infof("Periodic gather %s completed in %s", name, time.Since(start).Truncate(time.Millisecond))
c.statuses[name].UpdateStatus(controllerstatus.Summary{Healthy: true})
return
}
Expand Down Expand Up @@ -301,7 +301,7 @@ func (c *Controller) onDemandGather(stopCh <-chan struct{}) {

func (c *Controller) GatherJob() {
if c.isGatheringDisabled() {
klog.V(3).Info("Gather is disabled by configuration.")
klog.Info("Gather is disabled by configuration.")
return
}
ctx, cancel := context.WithTimeout(context.Background(), c.configAggregator.Config().DataReporting.Interval*4)
Expand Down
18 changes: 9 additions & 9 deletions pkg/controller/status/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,28 +213,28 @@ func (c *Controller) currentControllerStatus() (allReady bool) { //nolint: gocyc

if summary.Operation.Name == controllerstatus.Uploading.Name {
if summary.Count < uploadFailuresCountThreshold {
klog.V(4).Infof("Number of last upload failures %d lower than threshold %d. Not marking as degraded.",
klog.Infof("Number of last upload failures %d lower than threshold %d. Not marking as degraded.",
summary.Count, uploadFailuresCountThreshold)
} else {
degradingFailure = true
klog.V(4).Infof("Number of last upload failures %d exceeded the threshold %d. Marking as degraded.",
klog.Infof("Number of last upload failures %d exceeded the threshold %d. Marking as degraded.",
summary.Count, uploadFailuresCountThreshold)
}
c.ctrlStatus.setStatus(UploadStatus, summary.Reason, summary.Message)
} else if summary.Operation.Name == controllerstatus.DownloadingReport.Name {
klog.V(4).Info("Failed to download Insights report")
klog.Info("Failed to download Insights report")
c.ctrlStatus.setStatus(DownloadStatus, summary.Reason, summary.Message)
} else if summary.Operation.Name == controllerstatus.PullingSCACerts.Name {
// mark as degraded only in case of HTTP 500 and higher
if summary.Operation.HTTPStatusCode >= 500 {
klog.V(4).Infof("Failed to download the SCA certs within the threshold %d with exponential backoff. Marking as degraded.",
klog.Infof("Failed to download the SCA certs within the threshold %d with exponential backoff. Marking as degraded.",
ocm.FailureCountThreshold)
degradingFailure = true
}
} else if summary.Operation.Name == controllerstatus.PullingClusterTransfer.Name {
// mark as degraded only in case of HTTP 500 and higher
if summary.Operation.HTTPStatusCode >= 500 {
klog.V(4).Infof("Failed to pull the cluster transfer object within the threshold %d with exponential backoff. Marking as degraded.",
klog.Infof("Failed to pull the cluster transfer object within the threshold %d with exponential backoff. Marking as degraded.",
ocm.FailureCountThreshold)
degradingFailure = true
}
Expand Down Expand Up @@ -416,7 +416,7 @@ func (c *Controller) checkDisabledGathering() {
// update the current controller state by it status
func (c *Controller) updateControllerConditionsByStatus(cs *conditions, isInitializing bool) {
if isInitializing {
klog.V(4).Infof("The operator is still being initialized")
klog.Infof("The operator is still being initialized")
// if we're still starting up and some sources are not ready, initialize the conditions
// but don't update
if !cs.hasCondition(configv1.OperatorProgressing) {
Expand All @@ -425,7 +425,7 @@ func (c *Controller) updateControllerConditionsByStatus(cs *conditions, isInitia
}

if es := c.ctrlStatus.getStatus(ErrorStatus); es != nil && !c.ctrlStatus.isDisabled() {
klog.V(4).Infof("The operator has some internal errors: %s", es.message)
klog.Infof("The operator has some internal errors: %s", es.message)
cs.setCondition(configv1.OperatorProgressing, configv1.ConditionFalse, degradedReason, "An error has occurred")
cs.setCondition(configv1.OperatorAvailable, configv1.ConditionFalse, es.reason, es.message)
cs.setCondition(configv1.OperatorUpgradeable, configv1.ConditionFalse, degradedReason, es.message)
Expand All @@ -434,14 +434,14 @@ func (c *Controller) updateControllerConditionsByStatus(cs *conditions, isInitia
// when the operator is already healthy then it doesn't make sense to set those, but when it's degraded and then
// marked as disabled then it's reasonable to set Available=True
if ds := c.ctrlStatus.getStatus(DisabledStatus); ds != nil && !c.ctrlStatus.isHealthy() {
klog.V(4).Infof("The operator is marked as disabled")
klog.Infof("The operator is marked as disabled")
cs.setCondition(configv1.OperatorProgressing, configv1.ConditionFalse, asExpectedReason, monitoringMsg)
cs.setCondition(configv1.OperatorAvailable, configv1.ConditionTrue, asExpectedReason, insightsAvailableMessage)
cs.setCondition(configv1.OperatorUpgradeable, configv1.ConditionTrue, upgradeableReason, canBeUpgradedMsg)
}

if c.ctrlStatus.isHealthy() {
klog.V(4).Infof("The operator is healthy")
klog.Infof("The operator is healthy")
cs.setCondition(configv1.OperatorProgressing, configv1.ConditionFalse, asExpectedReason, monitoringMsg)
cs.setCondition(configv1.OperatorAvailable, configv1.ConditionTrue, asExpectedReason, insightsAvailableMessage)
cs.setCondition(configv1.OperatorUpgradeable, configv1.ConditionTrue, upgradeableReason, canBeUpgradedMsg)
Expand Down
8 changes: 4 additions & 4 deletions pkg/gather/tasks_processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func HandleTasksConcurrently(ctx context.Context, tasks []Task) chan GatheringFu
if len(tasks) < workerNum {
workerNum = len(tasks)
}
klog.V(4).Infof("number of workers: %d", workerNum)
klog.Infof("number of workers: %d", workerNum)

// create workers
for i := 0; i < workerNum; i++ {
Expand All @@ -66,12 +66,12 @@ func HandleTasksConcurrently(ctx context.Context, tasks []Task) chan GatheringFu

func worker(ctx context.Context, id int, wg *sync.WaitGroup, tasksChan <-chan Task, resultsChan chan<- GatheringFunctionResult) {
defer wg.Done()
klog.V(4).Infof("worker %d listening for tasks.", id)
klog.Infof("worker %d listening for tasks.", id)
for task := range tasksChan {
klog.V(4).Infof("worker %d working on %s task.", id, task.Name)
klog.Infof("worker %d working on %s task.", id, task.Name)
handleTask(ctx, task, resultsChan)
}
klog.V(4).Infof("worker %d stopped.", id)
klog.Infof("worker %d stopped.", id)
}

func handleTask(ctx context.Context, task Task, resultsChan chan<- GatheringFunctionResult) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/gatherers/workloads/gather_workloads_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func imageFromID(ctx context.Context, client imageclient.ImageInterface, id stri
start := time.Now()
image, err := client.Get(ctx, id, metav1.GetOptions{})
if kerrors.IsNotFound(err) {
klog.V(4).Infof("No image %s (%s)", id, time.Since(start).Round(time.Millisecond).String())
klog.Infof("No image %s (%s)", id, time.Since(start).Round(time.Millisecond).String())
return nil
}
if errors.Is(err, context.Canceled) {
Expand All @@ -374,7 +374,7 @@ func imageFromID(ctx context.Context, client imageclient.ImageInterface, id stri
return nil
}

klog.V(4).Infof("Found image %s (%s)", id, time.Since(start).Round(time.Millisecond).String())
klog.Infof("Found image %s (%s)", id, time.Since(start).Round(time.Millisecond).String())
return image
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/insights/insightsclient/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ func (c *Client) SendAndGetID(ctx context.Context, endpoint string, source Sourc
// dynamically set the proxy environment
c.client.Transport = clientTransport(c.authorizer)

klog.V(4).Infof("Uploading %s to %s", source.Type, req.URL.String())
klog.Infof("Uploading %s to %s", source.Type, req.URL.String())
resp, err := c.client.Do(req)
if err != nil {
klog.V(4).Infof("Unable to build a request, possible invalid token: %v", err)
klog.Infof("Unable to build a request, possible invalid token: %v", err)
// if the request is not build, for example because of invalid endpoint,(maybe some problem with DNS), we want to have record about it in metrics as well.
insights.IncrementCounterRequestSend(noHttpStatusCode)
return "", noHttpStatusCode, fmt.Errorf("unable to build request to connect to Insights server: %v", err)
Expand Down Expand Up @@ -119,7 +119,7 @@ func (c *Client) RecvReport(ctx context.Context, endpoint string) (*http.Respons
// dynamically set the proxy environment
c.client.Transport = clientTransport(c.authorizer)

klog.V(4).Infof("Retrieving report from %s", req.URL.String())
klog.Infof("Retrieving report from %s", req.URL.String())
resp, err := c.client.Do(req)

if err != nil {
Expand Down
18 changes: 9 additions & 9 deletions pkg/insights/insightsreport/insightsreport.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (c *Controller) PullReportTechpreview(insightsRequestID string) (*types.Ins
reportEndpointTP := config.DataReporting.DownloadEndpointTechPreview

if len(reportEndpointTP) == 0 {
klog.V(4).Info("Not downloading report because the insights-results-agregator endpoint is not configured")
klog.Info("Not downloading report because the insights-results-agregator endpoint is not configured")
c.StatusController.UpdateStatus(controllerstatus.Summary{Healthy: true})
return nil, nil
}
Expand Down Expand Up @@ -139,14 +139,14 @@ func (c *Controller) PullSmartProxy() (bool, error) {
reportEndpoint := config.DataReporting.DownloadEndpoint

if len(reportEndpoint) == 0 {
klog.V(4).Info("Not downloading report because Smart Proxy client is not properly configured: missing report endpoint")
klog.Info("Not downloading report because Smart Proxy client is not properly configured: missing report endpoint")
return true, nil
}

ctx, cancelFunc := context.WithTimeout(context.Background(), time.Minute)
defer cancelFunc()

klog.V(4).Info("Retrieving report")
klog.Info("Retrieving report")
resp, err := c.client.RecvReport(ctx, reportEndpoint)
if authorizer.IsAuthorizationError(err) {
c.StatusController.UpdateStatus(controllerstatus.Summary{
Expand Down Expand Up @@ -181,7 +181,7 @@ func (c *Controller) PullSmartProxy() (bool, error) {
}
}()

klog.V(4).Info("Report retrieved")
klog.Info("Report retrieved")
downloadTime := metav1.Now()
reportResponse := types.Response{}

Expand All @@ -193,7 +193,7 @@ func (c *Controller) PullSmartProxy() (bool, error) {
klog.V(4).Info("Smart Proxy report correctly parsed")

if c.LastReport.Meta.LastCheckedAt == reportResponse.Report.Meta.LastCheckedAt {
klog.V(2).Info("Retrieved report is equal to previus one. Retrying...")
klog.Info("Retrieved report is equal to previus one. Retrying...")
return true, fmt.Errorf("report not updated")
}

Expand All @@ -212,13 +212,13 @@ func (c *Controller) PullSmartProxy() (bool, error) {

// RetrieveReport gets the report from Smart Proxy, if possible, handling the delays and timeouts
func (c *Controller) RetrieveReport() {
klog.V(4).Info("Starting retrieving report from Smart Proxy")
klog.Info("Starting retrieving report from Smart Proxy")
config := c.configurator.Config()
configCh, cancelFn := c.configurator.ConfigChanged()
defer cancelFn()

delay := config.DataReporting.ReportPullingDelay
klog.V(4).Infof("Initial delay for pulling: %v", delay)
klog.Infof("Initial delay for pulling: %v", delay)
startTime := time.Now()
delayTimer := time.NewTimer(wait.Jitter(delay, 0.1))
timeoutTimer := time.NewTimer(reportDownloadTimeout)
Expand All @@ -236,7 +236,7 @@ func (c *Controller) RetrieveReport() {
if err != nil {
klog.Errorf("Unrecoverable problem retrieving the report: %v", err)
} else {
klog.V(4).Info("Report retrieved correctly")
klog.Info("Report retrieved correctly")
}
return
}
Expand Down Expand Up @@ -301,7 +301,7 @@ func (c *Controller) Run(ctx context.Context) {
// always wait for new uploaded archive or insights-operator ends
select {
case <-c.archiveUploadReporter:
klog.V(4).Info("Archive uploaded, starting pulling report...")
klog.Info("Archive uploaded, starting pulling report...")
c.RetrieveReport()

case <-ctx.Done():
Expand Down
10 changes: 5 additions & 5 deletions pkg/insights/insightsuploader/insightsuploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ func (c *Controller) checkSummaryAndSend(interval time.Duration, lastReported ti
return
}
if !ok {
klog.V(4).Infof("Nothing to report since %s", lastReported.Format(time.RFC3339))
klog.Infof("Nothing to report since %s", lastReported.Format(time.RFC3339))
return
}
defer source.Contents.Close()
if reportingEnabled && len(endpoint) > 0 {
// send the results
start := time.Now()
id := start.Format(time.RFC3339)
klog.V(4).Infof("Uploading latest report since %s", lastReported.Format(time.RFC3339))
klog.Infof("Uploading latest report since %s", lastReported.Format(time.RFC3339))
source.ID = id
source.Type = "application/vnd.redhat.openshift.periodic"
if err := c.client.Send(ctx, endpoint, *source); err != nil {
Expand All @@ -186,17 +186,17 @@ func (c *Controller) checkSummaryAndSend(interval time.Duration, lastReported ti
Reason: "UploadFailed", Message: fmt.Sprintf("Unable to report: %v", err)})
return
}
klog.V(4).Infof("Uploaded report successfully in %s", time.Since(start))
klog.Infof("Uploaded report successfully in %s", time.Since(start))
select {
case c.archiveUploaded <- struct{}{}:
default:
}
lastReported = start.UTC()
c.StatusController.UpdateStatus(controllerstatus.Summary{Healthy: true})
} else {
klog.V(4).Info("Display report that would be sent")
klog.Info("Display report that would be sent")
// display what would have been sent (to ensure we always exercise source processing)
if err := reportToLogs(source.Contents, klog.V(4)); err != nil {
if err := reportToLogs(source.Contents, klog.V(2)); err != nil {
klog.Errorf("Unable to log upload: %v", err)
}
// we didn't actually report logs, so don't advance the report date
Expand Down
6 changes: 3 additions & 3 deletions pkg/recorder/diskrecorder/diskrecorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (d *DiskRecorder) SaveAtPath(records record.MemoryRecords, path string) (re
wrote = len(completed)
}()

klog.V(4).Infof("Writing %d records to %s", len(records), path)
klog.Infof("Writing %d records to %s", len(records), path)

gw := gzip.NewWriter(f)
tw := tar.NewWriter(gw)
Expand Down Expand Up @@ -133,7 +133,7 @@ func (d *DiskRecorder) Prune(olderThan time.Time) error {
return fmt.Errorf("failed to delete %d expired files: %v", len(errors), errors[0])
}
if count > 0 {
klog.V(4).Infof("Deleted %d files older than %s", count, olderThan.UTC().Format(time.RFC3339))
klog.Infof("Deleted %d files older than %s", count, olderThan.UTC().Format(time.RFC3339))
}
return nil
}
Expand Down Expand Up @@ -167,7 +167,7 @@ func (d *DiskRecorder) Summary(_ context.Context, since time.Time) (*insightscli
return nil, false, nil
}
lastFile := recentFiles[len(recentFiles)-1]
klog.V(4).Infof("Found files to send: %v", lastFile)
klog.Infof("Found files to send: %v", lastFile)
f, err := os.Open(filepath.Join(d.basePath, lastFile))
if err != nil {
return nil, false, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/recorder/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (r *Recorder) Record(rec record.Record) (errs []error) {
return errs
}

klog.V(4).Infof("Recording %s with fingerprint=%s", rec.Name, fingerprint)
klog.Infof("Recording %s with fingerprint=%s", rec.Name, fingerprint)

at := rec.Captured
if at.IsZero() {
Expand Down

0 comments on commit 93e1c20

Please sign in to comment.