From b122b2dbf725e496db6b78fa8d235b1c89d097f0 Mon Sep 17 00:00:00 2001 From: AbdelrahmanElawady Date: Tue, 21 May 2024 23:34:27 +0300 Subject: [PATCH] Modify hook-injector plugin to monitor directories to match cri-o Signed-off-by: AbdelrahmanElawady --- plugins/hook-injector/hook-injector.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/plugins/hook-injector/hook-injector.go b/plugins/hook-injector/hook-injector.go index c8bc8f12..2522a52f 100644 --- a/plugins/hook-injector/hook-injector.go +++ b/plugins/hook-injector/hook-injector.go @@ -174,6 +174,22 @@ func main() { } p.mgr = mgr + for _, dir := range dirs { + if err = os.MkdirAll(dir, 0755); err != nil { + log.Errorf("failed to create directory %q: %v", dir, err) + os.Exit(1) + } + } + + sync := make(chan error, 2) + go mgr.Monitor(ctx, sync) + + err = <-sync + if err != nil { + log.Errorf("failed to monitor hook directories: %v", err) + os.Exit(1) + } + err = p.stub.Run(ctx) if err != nil { log.Errorf("plugin exited with error %v", err)