Package: ganeti-2.15 / 2.15.2-15

0033-hinotify-0.3.10-changes.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
From: Apollon Oikonomopoulos <apoikos@debian.org>
Date: Thu, 1 Nov 2018 12:18:26 +0200
Subject: hinotify 0.3.10 changes

Paths must now be ByteString's and not Strings. Since this breaks
compatibility, bump hinotify minimum version to 0.3.10.
---
 cabal/ganeti.template.cabal |  2 +-
 src/Ganeti/ConfigReader.hs  |  3 ++-
 src/Ganeti/JQScheduler.hs   |  5 +++--
 src/Ganeti/Kvmd.hs          | 26 +++++++++++++++-----------
 src/Ganeti/Utils.hs         |  4 ++--
 5 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/cabal/ganeti.template.cabal b/cabal/ganeti.template.cabal
index f3bed66..de70a2d 100644
--- a/cabal/ganeti.template.cabal
+++ b/cabal/ganeti.template.cabal
@@ -59,7 +59,7 @@ library
     , case-insensitive              >= 0.4.0.1    && < 1.3
     , Crypto                        >= 4.2.4      && < 4.3
     , curl                          >= 1.3.7      && < 1.4
-    , hinotify                      >= 0.3.2      && < 0.4
+    , hinotify                      >= 0.3.10     && < 0.4
     , hslogger                      >= 1.1.4      && < 1.3
     , json                          >= 0.5
     , lens                          >= 3.10
diff --git a/src/Ganeti/ConfigReader.hs b/src/Ganeti/ConfigReader.hs
index d5e9b81..b17813b 100644
--- a/src/Ganeti/ConfigReader.hs
+++ b/src/Ganeti/ConfigReader.hs
@@ -42,6 +42,7 @@ module Ganeti.ConfigReader
 import Control.Concurrent
 import Control.Exception
 import Control.Monad (unless)
+import qualified Data.ByteString.UTF8 as UTF8
 import System.INotify
 
 import Ganeti.BasicTypes
@@ -247,7 +248,7 @@ addNotifier :: INotify -> FilePath -> (Result ConfigData -> IO ())
             -> MVar ServerState -> IO Bool
 addNotifier inotify path save_fn mstate =
   Control.Exception.catch
-        (addWatch inotify [CloseWrite] path
+        (addWatch inotify [CloseWrite] (UTF8.fromString path)
             (onInotify inotify path save_fn mstate) >> return True)
         (\e -> const (return False) (e::IOError))
 
diff --git a/src/Ganeti/JQScheduler.hs b/src/Ganeti/JQScheduler.hs
index 66c3fd1..aac630b 100644
--- a/src/Ganeti/JQScheduler.hs
+++ b/src/Ganeti/JQScheduler.hs
@@ -54,6 +54,7 @@ import Control.Concurrent
 import Control.Exception
 import Control.Monad
 import Control.Monad.IO.Class
+import qualified Data.ByteString.UTF8 as UTF8
 import Data.Function (on)
 import Data.Functor ((<$))
 import Data.IORef
@@ -270,7 +271,7 @@ jobWatcher state jWS e = do
   when (e == Ignored  && isJust inotify) $ do
     qdir <- queueDir
     let fpath = liveJobFile qdir jid
-    _ <- addWatch (fromJust inotify) [Modify, Delete] fpath
+    _ <- addWatch (fromJust inotify) [Modify, Delete] (UTF8.fromString fpath)
            (jobWatcher state jWS)
     return ()
   updateJob state jWS
@@ -287,7 +288,7 @@ attachWatcher state jWS = when (isNothing $ jINotify jWS) $ do
      let fpath = liveJobFile qdir . qjId $ jJob jWS
          jWS' = jWS { jINotify=Just inotify }
      logDebug $ "Attaching queue watcher for " ++ fpath
-     _ <- addWatch inotify [Modify, Delete] fpath $ jobWatcher state jWS'
+     _ <- addWatch inotify [Modify, Delete] (UTF8.fromString fpath) $ jobWatcher state jWS'
      modifyJobs state . onRunningJobs $ updateJobStatus jWS'
    else logDebug $ "Not attaching watcher for job "
                    ++ (show . fromJobId . qjId $ jJob jWS)
diff --git a/src/Ganeti/Kvmd.hs b/src/Ganeti/Kvmd.hs
index 4979396..e51fea4 100644
--- a/src/Ganeti/Kvmd.hs
+++ b/src/Ganeti/Kvmd.hs
@@ -65,6 +65,7 @@ import Control.Applicative ((<$>))
 import Control.Exception (try)
 import Control.Concurrent
 import Control.Monad (unless, when)
+import qualified Data.ByteString.UTF8 as UTF8
 import Data.List
 import Data.Set (Set)
 import qualified Data.Set as Set (delete, empty, insert, member)
@@ -215,6 +216,9 @@ ensureMonitor monitors monitorFile =
 
 -- * Directory and file watching
 
+evPath :: Event -> String
+evPath = UTF8.toString . filePath
+
 -- | Handles an inotify event outside the target directory.
 --
 -- Tracks events on the parent directory of the KVM control directory
@@ -222,7 +226,7 @@ ensureMonitor monitors monitorFile =
 handleGenericEvent :: Lock -> String -> String -> Event -> IO ()
 handleGenericEvent lock curDir tarDir ev@Created {}
   | isDirectory ev && curDir /= tarDir &&
-    (curDir </> filePath ev) `isPrefixPath` tarDir = putMVar lock ()
+    (curDir </> evPath ev) `isPrefixPath` tarDir = putMVar lock ()
 handleGenericEvent lock _ _ event
   | event == DeletedSelf || event == Unmounted = putMVar lock ()
 handleGenericEvent _ _ _ _ = return ()
@@ -233,23 +237,23 @@ handleGenericEvent _ _ _ _ = return ()
 -- ensures that there is a monitor running for the new Qmp socket.
 handleTargetEvent :: Lock -> Monitors -> String -> Event -> IO ()
 handleTargetEvent _ monitors tarDir ev@Created {}
-  | not (isDirectory ev) && isMonitorPath (filePath ev) =
-    ensureMonitor monitors $ tarDir </> filePath ev
+  | not (isDirectory ev) && isMonitorPath (evPath ev) =
+    ensureMonitor monitors $ tarDir </> evPath ev
 handleTargetEvent lock monitors tarDir ev@Opened {}
   | not (isDirectory ev) =
     case maybeFilePath ev of
-      Just p | isMonitorPath p ->
-        ensureMonitor monitors $ tarDir </> filePath ev
+      Just p | isMonitorPath (UTF8.toString p) ->
+        ensureMonitor monitors $ tarDir </> evPath ev
       _ ->
         handleGenericEvent lock tarDir tarDir ev
 handleTargetEvent _ _ tarDir ev@Created {}
-  | not (isDirectory ev) && takeExtension (filePath ev) == shutdownExtension =
+  | not (isDirectory ev) && takeExtension (evPath ev) == shutdownExtension =
     Logging.logInfo $ "User shutdown file opened " ++
-      show (tarDir </> filePath ev)
+      show (tarDir </> evPath ev)
 handleTargetEvent _ _ tarDir ev@Deleted {}
-  | not (isDirectory ev) && takeExtension (filePath ev) == shutdownExtension =
+  | not (isDirectory ev) && takeExtension (evPath ev) == shutdownExtension =
     Logging.logInfo $ "User shutdown file deleted " ++
-      show (tarDir </> filePath ev)
+      show (tarDir </> evPath ev)
 handleTargetEvent lock _ tarDir ev =
   handleGenericEvent lock tarDir tarDir ev
 
@@ -266,7 +270,7 @@ handleDir lock monitors curDir tarDir event =
 recapDir :: Lock -> Monitors -> FilePath -> IO ()
 recapDir lock monitors dir =
   do files <- getDirectoryContents dir
-     let files' = filter isMonitorPath files
+     let files' = map UTF8.fromString $ filter isMonitorPath files
      mapM_ sendEvent files'
   where sendEvent file =
           handleTargetEvent lock monitors dir Created { isDirectory = False
@@ -290,7 +294,7 @@ watchDir lock tarDir inotify = watchDir' tarDir
                  let events = watchDirEvents dir
                  Logging.logInfo $ "Watch directory " ++ show dir
                  monitors <- newMVar Set.empty
-                 wd <- addWatch inotify events dir
+                 wd <- addWatch inotify events (UTF8.fromString dir)
                        (handleDir lock monitors dir tarDir)
                  when (dir == tarDir) $ recapDir lock monitors dir
                  () <- takeMVar lock
diff --git a/src/Ganeti/Utils.hs b/src/Ganeti/Utils.hs
index 6cb8e27..9f2ce41 100644
--- a/src/Ganeti/Utils.hs
+++ b/src/Ganeti/Utils.hs
@@ -724,11 +724,11 @@ watchFileBy fpath timeout check read_fn = do
                        logDebug $ "Notified of change in " ++ fpath
                                     ++ "; event: " ++ show e
                        when (e == Ignored)
-                         (addWatch inotify [Modify, Delete] fpath do_watch
+                         (addWatch inotify [Modify, Delete] (UTF8.fromString fpath) do_watch
                             >> return ())
                        fstat' <- getFStatSafe fpath
                        writeIORef ref fstat'
-    _ <- addWatch inotify [Modify, Delete] fpath do_watch
+    _ <- addWatch inotify [Modify, Delete] (UTF8.fromString fpath) do_watch
     newval <- read_fn
     if check newval
       then do