diff --git a/cmd/node-joiner/main.go b/cmd/node-joiner/main.go index eb83d3fbda9..cf5785fe9d9 100644 --- a/cmd/node-joiner/main.go +++ b/cmd/node-joiner/main.go @@ -38,7 +38,7 @@ func nodeJoiner() error { nodesAddCmd.Flags().BoolP("pxe", "p", false, "Instead of an ISO, generates PXE artifacts that can be used to boot the configured nodes to let them join an existing cluster") nodesMonitorCmd := &cobra.Command{ - Use: "monitor-add-nodes", + Use: "monitor-add-nodes ", Short: "Monitors the configured nodes while they are joining an existing cluster", RunE: func(cmd *cobra.Command, args []string) error { dir, kubeConfig, err := getCommonFlags(cmd) diff --git a/pkg/agent/cluster.go b/pkg/agent/cluster.go index 7b77310ae91..6ff0d908790 100644 --- a/pkg/agent/cluster.go +++ b/pkg/agent/cluster.go @@ -193,7 +193,7 @@ func (czero *Cluster) IsBootstrapComplete() (bool, bool, error) { // Agent Rest API is available if agentRestAPILive { - exitOnErr, err := czero.MonitorStatusFromAssistedService() + exitOnErr, err := czero.MonitorStatusFromAssistedService(nil) if err != nil { return false, exitOnErr, err } @@ -214,17 +214,16 @@ func (czero *Cluster) IsBootstrapComplete() (bool, bool, error) { // After cluster or host installation has started, new events from // the Assisted Service API are also logged and updated to the cluster's // install history. -func (czero *Cluster) MonitorStatusFromAssistedService() (bool, error) { +func (czero *Cluster) MonitorStatusFromAssistedService(ch chan logEntry) (bool, error) { + logger := logrus.StandardLogger() resource := "cluster" - logPrefix := "" if czero.workflow == workflow.AgentWorkflowTypeAddNodes { resource = "host" - logPrefix = fmt.Sprintf("Node %s: ", czero.API.Rest.NodeZeroIP) } // First time we see the agent Rest API if !czero.installHistory.RestAPISeen { - logrus.Debugf("%sAgent Rest API Initialized", logPrefix) + log(Debug, "Agent Rest API Initialized", logger, ch) czero.installHistory.RestAPISeen = true czero.installHistory.NotReadyTime = time.Now() } @@ -256,18 +255,14 @@ func (czero *Cluster) MonitorStatusFromAssistedService() (bool, error) { return false, errors.New("cluster metadata returned nil from Agent Rest API") } - czero.PrintInstallStatus(clusterMetadata) + czero.PrintInstallStatus(clusterMetadata, ch) // If status indicates pending action, log host info to help pinpoint what is missing if (*clusterMetadata.Status != czero.installHistory.RestAPIPreviousClusterStatus) && (*clusterMetadata.Status == models.ClusterStatusInstallingPendingUserAction) { for _, host := range clusterMetadata.Hosts { if *host.Status == models.ClusterStatusInstallingPendingUserAction { - if logPrefix != "" { - logrus.Warningf("%s%s %s", logPrefix, host.RequestedHostname, *host.StatusInfo) - } else { - logrus.Warningf("Host %s %s", host.RequestedHostname, *host.StatusInfo) - } + log(Warning, fmt.Sprintf("Host %s %s", host.RequestedHostname, *host.StatusInfo), logger, ch) } } } @@ -293,7 +288,7 @@ func (czero *Cluster) MonitorStatusFromAssistedService() (bool, error) { } } - validationsErr := checkValidations(clusterMetadata, czero.installHistory.ValidationResults, logrus.StandardLogger(), logPrefix) + validationsErr := checkValidations(clusterMetadata, czero.installHistory.ValidationResults, logger, ch) if validationsErr != nil { return false, errors.Wrap(validationsErr, "host validations failed") } @@ -310,9 +305,9 @@ func (czero *Cluster) MonitorStatusFromAssistedService() (bool, error) { // Don't print the same status message back to back if *mostRecentEvent.Message != czero.installHistory.RestAPIPreviousEventMessage { if *mostRecentEvent.Severity == models.EventSeverityInfo { - logrus.Infof("%s%s", logPrefix, *mostRecentEvent.Message) + log(Info, *mostRecentEvent.Message, logger, ch) } else { - logrus.Warnf("%s%s", logPrefix, *mostRecentEvent.Message) + log(Warning, *mostRecentEvent.Message, logger, ch) } } czero.installHistory.RestAPIPreviousEventMessage = *mostRecentEvent.Message @@ -473,11 +468,11 @@ func (czero *Cluster) PrintInstallationComplete() error { } // PrintInstallStatus Print a human friendly message using the models from the Agent Rest API. -func (czero *Cluster) PrintInstallStatus(cluster *models.Cluster) { +func (czero *Cluster) PrintInstallStatus(cluster *models.Cluster, ch chan logEntry) { friendlyStatus := czero.humanFriendlyClusterInstallStatus(*cluster.Status) // Don't print the same status message back to back if *cluster.Status != czero.installHistory.RestAPIPreviousClusterStatus { - logrus.Info(friendlyStatus) + log(Info, friendlyStatus, logrus.StandardLogger(), ch) } } diff --git a/pkg/agent/logging.go b/pkg/agent/logging.go new file mode 100644 index 00000000000..6cb78ceec15 --- /dev/null +++ b/pkg/agent/logging.go @@ -0,0 +1,84 @@ +package agent + +import ( + "fmt" + "sync" + "time" + + "github.com/sirupsen/logrus" +) + +// Constants representing logging levels. +const ( + Debug = "Debug" + Info = "Info" + Warning = "Warning" + Trace = "Trace" + Error = "Error" +) + +const ( + logInterval = 5 +) + +type logEntry struct { + level string + message string +} + +// Uses logger if ch is nil. +func log(level, message string, logger *logrus.Logger, ch chan logEntry) { + if ch != nil { + ch <- logEntry{level: level, message: message} + } else { + switch level { + case Debug: + logger.Debug(message) + case Info: + logger.Info(message) + case Warning: + logger.Warn(message) + case Trace: + logger.Trace(message) + } + } +} + +func printChannelLogs(ip string, ch chan logEntry) { + for len(ch) > 0 { + entry := <-ch + message := fmt.Sprintf("Node %s: %s", ip, entry.message) + switch entry.level { + case Debug: + logrus.Debug(message) + case Info: + logrus.Info(message) + case Warning: + logrus.Warn(message) + default: + logrus.Info(message) + } + } +} + +func printLogs(wg *sync.WaitGroup, ipChanMap map[string]chan logEntry) { + defer wg.Done() + for { + if len(ipChanMap) == 0 { + // no IPs to monitor or all channels are closed, exit loop + break + } + for ip, ch := range ipChanMap { + if len(ch) == 0 { + // check if channel is closed + _, ok := <-ch + if !ok { + // channel is closed, remove IP from map to stop checking for logs + delete(ipChanMap, ip) + } + } + printChannelLogs(ip, ch) + } + time.Sleep(logInterval * time.Second) + } +} diff --git a/pkg/agent/monitoraddnodes.go b/pkg/agent/monitoraddnodes.go index 07a67a5fb4f..023bd4a85aa 100644 --- a/pkg/agent/monitoraddnodes.go +++ b/pkg/agent/monitoraddnodes.go @@ -12,7 +12,6 @@ import ( "time" "github.com/pkg/errors" - "github.com/sirupsen/logrus" certificatesv1 "k8s.io/api/certificates/v1" corev1 "k8s.io/api/core/v1" ) @@ -40,9 +39,10 @@ type addNodeMonitor struct { hostnames []string cluster *Cluster status addNodeStatusHistory + ch chan logEntry } -func newAddNodeMonitor(nodeIP string, cluster *Cluster) (*addNodeMonitor, error) { +func newAddNodeMonitor(nodeIP string, cluster *Cluster, ch chan logEntry) (*addNodeMonitor, error) { parsedIPAddress := net.ParseIP(nodeIP) if parsedIPAddress == nil { return nil, fmt.Errorf("%s is not valid IP Address", nodeIP) @@ -58,20 +58,17 @@ func newAddNodeMonitor(nodeIP string, cluster *Cluster) (*addNodeMonitor, error) NodeJoinedCluster: false, NodeIsReady: false, }, + ch: ch, } hostnames, err := net.LookupAddr(nodeIP) if err != nil { - logrus.Infof("Cannot resolve IP address %v to a hostname. Skipping checks for pending CSRs.", nodeIP) + mon.logStatus(Info, fmt.Sprintf("Cannot resolve IP address %v to a hostname. Skipping checks for pending CSRs.", nodeIP)) } else { mon.hostnames = hostnames } return &mon, nil } -func (mon *addNodeMonitor) logStatus(status string) { - logrus.Infof("Node %s: %s", mon.nodeIPAddress, status) -} - // MonitorAddNodes display the progress of one or more nodes being // added to a cluster. ipAddresses is an array of IP addresses to be // monitored. clusters is an array of their corresponding initialized Cluster @@ -80,23 +77,30 @@ func MonitorAddNodes(ctx context.Context, clusters []*Cluster, ipAddresses []str waitContext, cancel := context.WithTimeout(ctx, timeout) defer cancel() var wg sync.WaitGroup + ipChanMap := make(map[string]chan logEntry) for i, ipAddress := range ipAddresses { wg.Add(1) - go MonitorSingleNode(waitContext, clusters[i], ipAddress, &wg) + ch := make(chan logEntry, 100) + ipChanMap[ipAddress] = ch + go MonitorSingleNode(waitContext, clusters[i], ipAddress, &wg, ch) } + wg.Add(1) + go printLogs(&wg, ipChanMap) + wg.Wait() } // MonitorSingleNode waits for the a node to be added to the cluster // and reports its status until it becomes Ready. -func MonitorSingleNode(waitContext context.Context, cluster *Cluster, nodeIPAddress string, wg *sync.WaitGroup) { +func MonitorSingleNode(waitContext context.Context, cluster *Cluster, nodeIPAddress string, wg *sync.WaitGroup, ch chan logEntry) { defer wg.Done() + defer close(ch) - mon, err := newAddNodeMonitor(nodeIPAddress, cluster) + mon, err := newAddNodeMonitor(nodeIPAddress, cluster, ch) if err != nil { - logrus.Errorf("could not initialize node monitor for node %v: %v", nodeIPAddress, err) + mon.logStatus(Error, fmt.Sprintf("Could not initialize node monitor: %v", err)) return } @@ -104,20 +108,20 @@ func MonitorSingleNode(waitContext context.Context, cluster *Cluster, nodeIPAddr if !mon.status.RestAPISeen && mon.cluster.API.Rest.IsRestAPILive() { mon.status.RestAPISeen = true - mon.logStatus("Assisted Service API is available") + mon.logStatus(Info, "Assisted Service API is available") } if !mon.status.KubeletIsRunningOnNode && mon.isKubeletRunningOnNode() { mon.status.KubeletIsRunningOnNode = true - mon.logStatus("Kubelet is running") + mon.logStatus(Info, "Kubelet is running") } if mon.status.KubeletIsRunningOnNode && !mon.status.FirstCSRSeen && mon.clusterHasFirstCSRPending() { mon.status.FirstCSRSeen = true - mon.logStatus("First CSR Pending approval") + mon.logStatus(Info, "First CSR Pending approval") mon.logCSRsPendingApproval(firstCSRSignerName) } @@ -125,61 +129,68 @@ func MonitorSingleNode(waitContext context.Context, cluster *Cluster, nodeIPAddr !mon.status.SecondCSRSeen && mon.clusterHasSecondCSRPending() { mon.status.SecondCSRSeen = true - mon.logStatus("Second CSR Pending approval") + mon.logStatus(Info, "Second CSR Pending approval") mon.logCSRsPendingApproval(secondCSRSignerName) } hasJoined, isReady, err := mon.nodeHasJoinedClusterAndIsReady() if err != nil { - logrus.Debugf("Node %v joined cluster and is ready check returned err: %v", nodeIPAddress, err) + mon.logStatus(Debug, fmt.Sprintf("Node joined cluster and is ready check returned err: %v", err)) } if !mon.status.NodeJoinedCluster && hasJoined { mon.status.NodeJoinedCluster = true - mon.logStatus("Node joined cluster") + mon.logStatus(Info, "Node joined cluster") } if !mon.status.NodeIsReady && isReady { mon.status.NodeIsReady = true if !mon.clusterHasSecondCSRPending() { - mon.logStatus("Node is Ready") + mon.logStatus(Info, "Node is Ready") } else { // The node becomes Ready before second CSR is approved. Log Pending CSRs // so users are aware there are still some waiting their approval even // though the node status is Ready. - mon.logStatus("Node is Ready but has CSRs pending approval. Until all CSRs are approved, the node may not be fully functional.") + mon.logStatus(Info, "Node is Ready but has CSRs pending approval. Until all CSRs are approved, the node may not be fully functional.") mon.logCSRsPendingApproval(secondCSRSignerName) } - return + break } if mon.cluster.API.Rest.IsRestAPILive() { - _, err = cluster.MonitorStatusFromAssistedService() + _, err = cluster.MonitorStatusFromAssistedService(mon.ch) if err != nil { - logrus.Warnf("error fetching status from assisted-service for node %s: %s", nodeIPAddress, err) + mon.logStatus(Warning, fmt.Sprintf("Error fetching status from assisted-service for node %s: %s", nodeIPAddress, err)) } } waitErr := waitContext.Err() if waitErr != nil { if errors.Is(waitErr, context.Canceled) { - mon.logStatus(fmt.Sprintf("Node monitoring cancelled: %v", waitErr)) - return + mon.logStatus(Info, fmt.Sprintf("Node monitoring cancelled: %v", waitErr)) + break } if errors.Is(waitErr, context.DeadlineExceeded) { - mon.logStatus(fmt.Sprintf("Node monitoring timed out after %v minutes", timeout)) - return + mon.logStatus(Info, fmt.Sprintf("Node monitoring timed out after %v minutes", timeout)) + break } } - time.Sleep(5 * time.Second) + time.Sleep(logInterval * time.Second) } + + // print out logs before channel is closed + printChannelLogs(nodeIPAddress, ch) +} + +func (mon *addNodeMonitor) logStatus(level, message string) { + mon.ch <- logEntry{level: level, message: message} } func (mon *addNodeMonitor) nodeHasJoinedClusterAndIsReady() (bool, bool, error) { nodes, err := mon.cluster.API.Kube.ListNodes() if err != nil { - logrus.Debugf("error getting node list %v", err) + mon.logStatus(Debug, fmt.Sprintf("Error getting node list %v", err)) return false, false, nil } @@ -198,19 +209,19 @@ func (mon *addNodeMonitor) nodeHasJoinedClusterAndIsReady() (bool, bool, error) isReady := false if hasJoined { - logrus.Debugf("Node %v (%s) has joined cluster", mon.nodeIPAddress, joinedNode.Name) + mon.logStatus(Debug, fmt.Sprintf("%s has joined cluster", joinedNode.Name)) for _, cond := range joinedNode.Status.Conditions { if cond.Type == corev1.NodeReady && cond.Status == corev1.ConditionTrue { isReady = true } } if isReady { - logrus.Debugf("Node %s (%s) is Ready", mon.nodeIPAddress, joinedNode.Name) + mon.logStatus(Debug, fmt.Sprintf("%s is Ready", joinedNode.Name)) } else { - logrus.Debugf("Node %s (%s) is not Ready", mon.nodeIPAddress, joinedNode.Name) + mon.logStatus(Debug, fmt.Sprintf("%s is not Ready", joinedNode.Name)) } } else { - logrus.Debugf("Node %s has not joined cluster", mon.nodeIPAddress) + mon.logStatus(Debug, "Node has not joined cluster") } return hasJoined, isReady, nil @@ -220,7 +231,7 @@ func (mon *addNodeMonitor) logCSRsPendingApproval(signerName string) { csrsPendingApproval := mon.getCSRsPendingApproval(signerName) for _, csr := range csrsPendingApproval { - mon.logStatus(fmt.Sprintf("CSR %s with signerName %s and username %s is Pending and awaiting approval", + mon.logStatus(Info, fmt.Sprintf("CSR %s with signerName %s and username %s is Pending and awaiting approval", csr.Name, csr.Spec.SignerName, csr.Spec.Username)) } } @@ -240,15 +251,15 @@ func (mon *addNodeMonitor) getCSRsPendingApproval(signerName string) []certifica csrs, err := mon.cluster.API.Kube.ListCSRs() if err != nil { - logrus.Debugf("error calling listCSRs(): %v", err) - logrus.Infof("Cannot retrieve CSRs from Kube API. Skipping checks for pending CSRs") + mon.logStatus(Debug, fmt.Sprintf("Error calling listCSRs(): %v", err)) + mon.logStatus(Info, "Cannot retrieve CSRs from Kube API. Skipping checks for pending CSRs") return []certificatesv1.CertificateSigningRequest{} } - return filterCSRsMatchingHostname(signerName, csrs, mon.hostnames) + return filterCSRsMatchingHostname(signerName, csrs, mon.hostnames, mon.ch) } -func filterCSRsMatchingHostname(signerName string, csrs *certificatesv1.CertificateSigningRequestList, hostnames []string) []certificatesv1.CertificateSigningRequest { +func filterCSRsMatchingHostname(signerName string, csrs *certificatesv1.CertificateSigningRequestList, hostnames []string, ch chan logEntry) []certificatesv1.CertificateSigningRequest { matchedCSRs := []certificatesv1.CertificateSigningRequest{} for _, csr := range csrs.Items { if len(csr.Status.Conditions) > 0 { @@ -256,7 +267,7 @@ func filterCSRsMatchingHostname(signerName string, csrs *certificatesv1.Certific continue } if signerName == firstCSRSignerName && csr.Spec.SignerName == firstCSRSignerName && - containsHostname(decodedFirstCSRSubject(csr.Spec.Request), hostnames) { + containsHostname(decodedFirstCSRSubject(csr.Spec.Request, ch), hostnames) { matchedCSRs = append(matchedCSRs, csr) } if signerName == secondCSRSignerName && csr.Spec.SignerName == secondCSRSignerName && @@ -289,7 +300,7 @@ func (mon *addNodeMonitor) isKubeletRunningOnNode() bool { // http get without authentication resp, err := http.Get(url) //nolint mon.nodeIPAddress is prevalidated to be IP address if err != nil { - logrus.Debugf("kubelet http err: %v", err) + mon.logStatus(Debug, fmt.Sprintf("kubelet http err: %v", err)) if strings.Contains(err.Error(), "remote error: tls: internal error") { // nodes being added will return this error return true @@ -302,7 +313,7 @@ func (mon *addNodeMonitor) isKubeletRunningOnNode() bool { return false } } else { - logrus.Debugf("kubelet http status code: %v", resp.StatusCode) + mon.logStatus(Debug, fmt.Sprintf("kubelet http status code: %v", resp.StatusCode)) } return false } @@ -331,7 +342,7 @@ func (mon *addNodeMonitor) isKubeletRunningOnNode() bool { // Signature Algorithm: ecdsa-with-SHA256 // // *snip* -func decodedFirstCSRSubject(request []byte) string { +func decodedFirstCSRSubject(request []byte, ch chan logEntry) string { block, _ := pem.Decode(request) if block == nil { return "" @@ -339,7 +350,9 @@ func decodedFirstCSRSubject(request []byte) string { csrDER := block.Bytes decodedRequest, err := x509.ParseCertificateRequest(csrDER) if err != nil { - logrus.Warn("error in x509.ParseCertificateRequest(csrDER)") + if ch != nil { + log(Warning, "error in x509.ParseCertificateRequest(csrDER)", nil, ch) + } return "" } return decodedRequest.Subject.String() diff --git a/pkg/agent/monitoraddnodes_test.go b/pkg/agent/monitoraddnodes_test.go index 0d118c544a2..2efb123d54c 100644 --- a/pkg/agent/monitoraddnodes_test.go +++ b/pkg/agent/monitoraddnodes_test.go @@ -48,7 +48,7 @@ func TestDecodedFirstCSRSubjectContainsHostname(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - containsHostname := containsHostname(decodedFirstCSRSubject([]byte(tt.request)), tt.hostnames) + containsHostname := containsHostname(decodedFirstCSRSubject([]byte(tt.request), nil), tt.hostnames) assert.Equal(t, tt.expectedResult, containsHostname) }) } @@ -154,7 +154,7 @@ func TestFilterCSRsMatchingHostnames(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - filteredCSRs := filterCSRsMatchingHostname(tt.signerName, tt.csrs, tt.hostnames) + filteredCSRs := filterCSRsMatchingHostname(tt.signerName, tt.csrs, tt.hostnames, nil) assert.Equal(t, tt.expectedResult, filteredCSRs) }) } diff --git a/pkg/agent/validations.go b/pkg/agent/validations.go index c137e3caf61..213e91920ce 100644 --- a/pkg/agent/validations.go +++ b/pkg/agent/validations.go @@ -34,23 +34,20 @@ type validationResultHistory struct { previousMessage string } -func checkValidations(cluster *models.Cluster, validationResults *validationResults, log *logrus.Logger, logPrefix string) error { +func checkValidations(cluster *models.Cluster, validationResults *validationResults, log *logrus.Logger, ch chan logEntry) error { clusterLogPrefix := "Cluster validation: " - updatedClusterValidationHistory, err := updateValidationResultHistory(clusterLogPrefix, cluster.ValidationsInfo, validationResults.ClusterValidationHistory, log) + updatedClusterValidationHistory, err := updateValidationResultHistory(clusterLogPrefix, cluster.ValidationsInfo, validationResults.ClusterValidationHistory, log, ch) if err != nil { return err } validationResults.ClusterValidationHistory = updatedClusterValidationHistory for _, h := range cluster.Hosts { - hostLogPrefix := logPrefix - if hostLogPrefix == "" { - hostLogPrefix = "Host " + h.RequestedHostname + " validation: " - } + hostLogPrefix := "Host " + h.RequestedHostname + " validation: " if _, ok := validationResults.HostValidationHistory[h.RequestedHostname]; !ok { validationResults.HostValidationHistory[h.RequestedHostname] = make(map[string]*validationResultHistory) } - updatedHostValidationHistory, err := updateValidationResultHistory(hostLogPrefix, h.ValidationsInfo, validationResults.HostValidationHistory[h.RequestedHostname], log) + updatedHostValidationHistory, err := updateValidationResultHistory(hostLogPrefix, h.ValidationsInfo, validationResults.HostValidationHistory[h.RequestedHostname], log, ch) if err != nil { return err } @@ -59,8 +56,7 @@ func checkValidations(cluster *models.Cluster, validationResults *validationResu return nil } -func updateValidationResultHistory(logPrefix string, validationsInfoString string, validationHistory map[string]*validationResultHistory, log *logrus.Logger) (map[string]*validationResultHistory, error) { - +func updateValidationResultHistory(logPrefix string, validationsInfoString string, validationHistory map[string]*validationResultHistory, log *logrus.Logger, ch chan logEntry) (map[string]*validationResultHistory, error) { if validationsInfoString == "" { return validationHistory, nil } @@ -85,23 +81,23 @@ func updateValidationResultHistory(logPrefix string, validationsInfoString strin case validationFailure, validationError: validationHistory[r.ID].numFailures++ } - logValidationHistory(logPrefix, validationHistory[r.ID], log) + logValidationHistory(logPrefix, validationHistory[r.ID], log, ch) } } return validationHistory, nil } -func logValidationHistory(logPrefix string, history *validationResultHistory, log *logrus.Logger) { +func logValidationHistory(logPrefix string, history *validationResultHistory, logger *logrus.Logger, ch chan logEntry) { // First time we print something if !history.seen { history.seen = true switch history.currentStatus { case validationSuccess: - log.Debug(logPrefix + history.currentMessage) + log(Debug, logPrefix+history.currentMessage, logger, ch) case validationFailure, validationError: - log.Warning(logPrefix + history.currentMessage) + log(Warning, logPrefix+history.currentMessage, logger, ch) default: - log.Trace(logPrefix + history.currentMessage) + log(Trace, logPrefix+history.currentMessage, logger, ch) } return } @@ -110,12 +106,12 @@ func logValidationHistory(logPrefix string, history *validationResultHistory, lo switch history.currentStatus { case validationSuccess: if history.previousStatus == validationError || history.previousStatus == validationFailure { - log.Info(logPrefix + history.currentMessage) + log(Info, logPrefix+history.currentMessage, logger, ch) } case validationFailure, validationError: - log.Warning(logPrefix + history.currentMessage) + log(Warning, logPrefix+history.currentMessage, logger, ch) default: - log.Trace(logPrefix + history.currentMessage) + log(Trace, logPrefix+history.currentMessage, logger, ch) } } } diff --git a/pkg/agent/validations_test.go b/pkg/agent/validations_test.go index 013f2981b64..bc678420a47 100644 --- a/pkg/agent/validations_test.go +++ b/pkg/agent/validations_test.go @@ -179,8 +179,9 @@ func TestUpdateValidationHistory(t *testing.T) { Hooks: make(logrus.LevelHooks), Level: logrus.DebugLevel, } - actualResult, _ := updateValidationResultHistory(testLogPrefix, tt.validationsInfo, tt.inputHistory, logger) + actualResult, err := updateValidationResultHistory(testLogPrefix, tt.validationsInfo, tt.inputHistory, logger, nil) assert.Equal(t, tt.expectedResult, actualResult) + assert.Nil(t, err) }) } } @@ -299,7 +300,7 @@ func TestLogValidationHistory(t *testing.T) { } var hook = test.NewLocal(logger) - logValidationHistory(testLogPrefix, tt.inputHistory, logger) + logValidationHistory(testLogPrefix, tt.inputHistory, logger, nil) actualResult := hook.LastEntry() if actualResult == nil {