Skip to content

Commit

Permalink
synccache and not wait
Browse files Browse the repository at this point in the history
Signed-off-by: Qi Wang <qiwan@redhat.com>
  • Loading branch information
QiWang19 committed Feb 23, 2024
1 parent c39d478 commit b7bd380
Showing 1 changed file with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package containerruntimeconfig
import (
"context"
"fmt"
"os"
"reflect"
"strconv"
"strings"
Expand Down Expand Up @@ -233,24 +232,15 @@ func (ctrl *Controller) Run(workers int, stopCh <-chan struct{}) {
listerCaches := []cache.InformerSynced{ctrl.mcpListerSynced, ctrl.mccrListerSynced, ctrl.ccListerSynced,
ctrl.imgListerSynced, ctrl.icspListerSynced, ctrl.idmsListerSynced, ctrl.itmsListerSynced, ctrl.clusterVersionListerSynced}

select {
case <-ctrl.featureGateAccess.InitialFeatureGatesObserved():
_, err := ctrl.featureGateAccess.CurrentFeatureGates()
if err != nil {
klog.Fatalf("containerruntimeconfigcontroller unable to get initial features: %v", err)
}
enabled, err := ctrl.sigstoreAPIEnabled()
klog.Infof("staring containerruntimeconfig controller sigstoreimageverification FeatureGates: %v, error: %v", enabled, err)
if enabled {
ctrl.enableClusterImagePolicyHandler()
// listerCaches = append(listerCaches, ctrl.clusterImagePolicyListerSynced)
}
case <-time.After(1 * time.Minute):
klog.Errorf("timed out waiting for FeatureGate detection")
os.Exit(1)
enabled, err := ctrl.sigstoreAPIEnabled()
klog.Infof("staring containerruntimeconfig controller sigstoreimageverification FeatureGates: %v, error: %v", enabled, err)
if enabled {
ctrl.enableClusterImagePolicyHandler()
listerCaches = append(listerCaches, ctrl.clusterImagePolicyListerSynced)
}

if !cache.WaitForCacheSync(stopCh, listerCaches...) {
if synced := cache.WaitForCacheSync(stopCh, listerCaches...); !synced {
klog.Info("timed out waiting for caches to sync")
return
}

Expand Down

0 comments on commit b7bd380

Please sign in to comment.