Skip to content

Commit 19a66c0

Browse files
authored
Creates -datadir immediately on startup (#56)
* Creates -datadir immediately on startup Currently, the value of the flag -datadir is only created when uuid-annotator goes to write the first annotation file. If uuid-annotator is running in a pod that doesn't get sufficient traffic which would cause tcp-info to generate an event, then the datatype directory will not be created. However, pusher will crashloop until this directory exists. This commit causes uuid-annotator to create the datatype directory immediately upon startup. * Uses mode 755 for MkdirAll() in handler.go 777 is unnecessary, and using 755 is more consistent with the permission on the base datatype directory, as well as more consistent with how other sidecar services permission their directories.
1 parent 4b67b33 commit 19a66c0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

handler/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (j *job) WriteFile(dir string, data *annotator.Annotations) error {
3434

3535
// Create the necessary subdirectories.
3636
dir = dir + j.timestamp.Format("/2006/01/02/")
37-
err = fs.MkdirAll(dir, 0777)
37+
err = fs.MkdirAll(dir, 0755)
3838
if err != nil {
3939
return err
4040
}

main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"flag"
66
"log"
77
"net"
8+
"os"
89
"sync"
910
"time"
1011

@@ -72,6 +73,10 @@ func main() {
7273
flag.Parse()
7374
rtx.Must(flagx.ArgsFromEnv(flag.CommandLine), "Could not get args from environment variables")
7475

76+
// Create the datatype directory immediately, since pusher will crash
77+
// without it.
78+
rtx.Must(os.MkdirAll(*datadir, 0755), "Could not create datatype dir %s", datadir)
79+
7580
// Parse the node's name into its constituent parts. This ensures that the
7681
// value of the -hostname flag is actually valid. Additionally, virtual
7782
// nodes which are part of a managed instance group may have a random

0 commit comments

Comments
 (0)