Skip to content

Commit

Permalink
Actually log when a replicated secret is screwing up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Miles-Garnsey committed May 20, 2024
1 parent 893c400 commit a00f1ef
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions controllers/replication/secret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (s *SecretSyncController) Reconcile(ctx context.Context, req ctrl.Request)

secrets, err := s.fetchAllMatchingSecrets(ctx, selector, rsec.Namespace)
if err != nil {
logger.Error(err, "Failed to fetch the replicated secrets to cleanup", "ReplicatedSecret", req.NamespacedName)
logger.Error(err, "Failed to fetch the replicated secrets to cleanup", "ReplicatedSecret", req.NamespacedName, "Namespace", rsec.Namespace)
return reconcile.Result{}, err
}

Expand Down Expand Up @@ -186,7 +186,7 @@ func (s *SecretSyncController) Reconcile(ctx context.Context, req ctrl.Request)
// Fetch all the secrets that match the ReplicatedSecret's rules
secrets, err := s.fetchAllMatchingSecrets(ctx, selector, req.Namespace)
if err != nil {
logger.Error(err, "Failed to fetch linked secrets", "ReplicatedSecret", req.NamespacedName)
logger.Error(err, "Failed to fetch linked secrets", "ReplicatedSecret", req.NamespacedName, "namespace", req.Namespace)
return reconcile.Result{Requeue: true}, err
}
// Verify secrets have up-to-date hashes
Expand Down
6 changes: 4 additions & 2 deletions controllers/replication/secret_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ func TestSecretController(t *testing.T) {
ctx := testutils.TestSetup(t)
ctx, cancel := context.WithCancel(ctx)
testEnv = &testutils.MultiClusterTestEnv{NumDataPlanes: 2}
err := testEnv.Start(ctx, t, func(mgr manager.Manager, clientCache *clientcache.ClientCache, clusters []cluster.Cluster) error {
logger, err := logr.FromContext(ctx)
require.NoError(t, err)
err = testEnv.Start(ctx, t, func(mgr manager.Manager, clientCache *clientcache.ClientCache, clusters []cluster.Cluster) error {
scheme = mgr.GetScheme()
logger = mgr.GetLogger()
return (&SecretSyncController{
ReconcilerConfig: config.InitConfig(),
ClientCache: clientCache,
}).SetupWithManager(mgr, clusters)
}).SetupWithManager(mgr, clusters, logger)
})
if err != nil {
t.Fatalf("failed to start test environment: %s", err)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func main() {
ReconcilerConfig: reconcilerConfig,
ClientCache: clientCache,
WatchNamespaces: []string{watchNamespace},
}).SetupWithManager(mgr, additionalClusters); err != nil {
}).SetupWithManager(mgr, additionalClusters, setupLog); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "SecretSync")
os.Exit(1)
}
Expand Down

0 comments on commit a00f1ef

Please sign in to comment.