Skip to content

Commit

Permalink
don't requeue if job has been deleted from etcd but still shows in cache
Browse files Browse the repository at this point in the history
Signed-off-by: Joel Whittaker-Smith <jdws.dev@gmail.com>
  • Loading branch information
jw-s committed Feb 9, 2022
1 parent d308944 commit ad246fc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/operator/controller/ciskubebenchreport.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ func (r *CISKubeBenchReportReconciler) processCompleteScanJob(ctx context.Contex

logsStream, err := r.LogsReader.GetLogsByJobAndContainerName(ctx, job, r.Plugin.GetContainerName())
if err != nil {
if errors.IsNotFound(err) {
log.V(1).Info("Cached job must have been deleted")
return nil
}
if kube.IsPodControlledByJobNotFound(err) {
log.V(1).Info("Pod must have been deleted")
return r.deleteJob(ctx, job)
Expand Down Expand Up @@ -325,6 +329,10 @@ func (r *CISKubeBenchReportReconciler) processFailedScanJob(ctx context.Context,

statuses, err := r.LogsReader.GetTerminatedContainersStatusesByJob(ctx, job)
if err != nil {
if errors.IsNotFound(err) {
log.V(1).Info("Cached job must have been deleted")
return nil
}
if kube.IsPodControlledByJobNotFound(err) {
log.V(1).Info("Pod must have been deleted")
return r.deleteJob(ctx, job)
Expand Down
8 changes: 8 additions & 0 deletions pkg/operator/controller/configauditreport.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ func (r *ConfigAuditReportReconciler) processCompleteScanJob(ctx context.Context

logsStream, err := r.LogsReader.GetLogsByJobAndContainerName(ctx, job, r.Plugin.GetContainerName())
if err != nil {
if errors.IsNotFound(err) {
log.V(1).Info("Cached job must have been deleted")
return nil
}
if kube.IsPodControlledByJobNotFound(err) {
log.V(1).Info("Pod must have been deleted")
return r.deleteJob(ctx, job)
Expand Down Expand Up @@ -443,6 +447,10 @@ func (r *ConfigAuditReportReconciler) processFailedScanJob(ctx context.Context,

statuses, err := r.LogsReader.GetTerminatedContainersStatusesByJob(ctx, scanJob)
if err != nil {
if errors.IsNotFound(err) {
log.V(1).Info("Cached job must have been deleted")
return nil
}
if kube.IsPodControlledByJobNotFound(err) {
log.V(1).Info("Pod must have been deleted")
return r.deleteJob(ctx, scanJob)
Expand Down
8 changes: 8 additions & 0 deletions pkg/operator/controller/vulnerabilityreport.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ func (r *VulnerabilityReportReconciler) processCompleteScanJob(ctx context.Conte
for containerName, containerImage := range containerImages {
logsStream, err := r.LogsReader.GetLogsByJobAndContainerName(ctx, job, containerName)
if err != nil {
if k8sapierror.IsNotFound(err) {
log.V(1).Info("Cached job must have been deleted")
return nil
}
if kube.IsPodControlledByJobNotFound(err) {
log.V(1).Info("Pod must have been deleted")
return r.deleteJob(ctx, job)
Expand Down Expand Up @@ -415,6 +419,10 @@ func (r *VulnerabilityReportReconciler) processFailedScanJob(ctx context.Context

statuses, err := r.GetTerminatedContainersStatusesByJob(ctx, scanJob)
if err != nil {
if k8sapierror.IsNotFound(err) {
log.V(1).Info("Cached job must have been deleted")
return nil
}
if kube.IsPodControlledByJobNotFound(err) {
log.V(1).Info("Pod must have been deleted")
return r.deleteJob(ctx, scanJob)
Expand Down

0 comments on commit ad246fc

Please sign in to comment.