Skip to content

Commit

Permalink
Creates -datadir immediately on startup (#56)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
nkinkade authored Jul 18, 2023
1 parent 4b67b33 commit 19a66c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (j *job) WriteFile(dir string, data *annotator.Annotations) error {

// Create the necessary subdirectories.
dir = dir + j.timestamp.Format("/2006/01/02/")
err = fs.MkdirAll(dir, 0777)
err = fs.MkdirAll(dir, 0755)
if err != nil {
return err
}
Expand Down
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"log"
"net"
"os"
"sync"
"time"

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

// Create the datatype directory immediately, since pusher will crash
// without it.
rtx.Must(os.MkdirAll(*datadir, 0755), "Could not create datatype dir %s", datadir)

// Parse the node's name into its constituent parts. This ensures that the
// value of the -hostname flag is actually valid. Additionally, virtual
// nodes which are part of a managed instance group may have a random
Expand Down

0 comments on commit 19a66c0

Please sign in to comment.