Skip to content

Commit

Permalink
Add option to force image check for disabled/suspended workloads
Browse files Browse the repository at this point in the history
  • Loading branch information
verdel committed Oct 5, 2023
1 parent 908b3b0 commit 9206af7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func main() {
insecureSkipVerify := flag.Bool("skip-registry-cert-verification", false, "whether to skip registries' certificate verification")
defaultRegistry := flag.String("default-registry", "",
fmt.Sprintf("default registry to use in absence of a fully qualified image name, defaults to %q", name.DefaultRegistry))
checkDisabled := flag.Bool("check-disabled", false, "whether to force image check for disabled / suspended workloads")

flag.Parse()

Expand Down Expand Up @@ -77,6 +78,7 @@ func main() {
stopCh,
kubeClient,
*insecureSkipVerify,
*checkDisabled,
regexes,
*defaultRegistry,
*namespaceLabels,
Expand Down
3 changes: 3 additions & 0 deletions pkg/registry_checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func NewRegistryChecker(
stopCh <-chan struct{},
kubeClient *kubernetes.Clientset,
skipVerify bool,
checkDisabled bool,
ignoredImages []regexp.Regexp,
defaultRegistry string,
namespaceLabel string,
Expand Down Expand Up @@ -195,6 +196,8 @@ func NewRegistryChecker(

rc.controllerIndexers.secretIndexer = rc.secretsInformer.Informer().GetIndexer()

rc.controllerIndexers.checkDisabled = checkDisabled

go informerFactory.Start(stopCh)
logrus.Info("Waiting for cache sync")
informerFactory.WaitForCacheSync(stopCh)
Expand Down
3 changes: 2 additions & 1 deletion pkg/registry_checker/indexers.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type ControllerIndexers struct {
daemonSetIndexer cache.Indexer
cronJobIndexer cache.Indexer
secretIndexer cache.Indexer
checkDisabled bool
}

type controllerWithContainerInfos struct {
Expand Down Expand Up @@ -233,7 +234,7 @@ func (ci ControllerIndexers) GetContainerInfosForImage(image string) (ret []stor

for _, obj := range objs {
controllerWithInfos := obj.(*controllerWithContainerInfos)
if !ci.validCi(controllerWithInfos) {
if !ci.validCi(controllerWithInfos) && !ci.checkDisabled {
continue
}

Expand Down

0 comments on commit 9206af7

Please sign in to comment.