Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vishiy committed Dec 4, 2024
1 parent 6bf6e00 commit 6223611
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
1 change: 0 additions & 1 deletion otelcollector/configuration-reader-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ func main() {
"--outfile", "/opt/inotifyoutput.txt",
"--event", "create",
"--event", "delete",
"--event", "modify",
"--format", "%e : %T",
"--timefmt", "+%s",
)
Expand Down
15 changes: 11 additions & 4 deletions otelcollector/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,22 @@ func main() {

if osType == "linux" {
outputFile := "/opt/inotifyoutput.txt"
if err := shared.Inotify(outputFile, "/etc/config/settings"); err != nil {
log.Fatal(err)
}

if ccpMetricsEnabled != "true" { //data-plane

if err := shared.Inotify(outputFile, "/etc/config/settings"); err != nil {
log.Fatal(err)
}

if ccpMetricsEnabled != "true" {
if err := shared.Inotify(outputFile, "/etc/prometheus/certs"); err != nil {
log.Fatal(err)
}
}
else { //control-plane
if err := shared.InotifyCCP(outputFile, "/etc/config/settings"); err != nil {
log.Fatal(err)
}
}
} else if osType == "windows" {
fmt.Println("Starting filesystemwatcher.ps1")
shared.StartCommand("powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", "C:\\opt\\scripts\\filesystemwatcher.ps1")
Expand Down
33 changes: 33 additions & 0 deletions otelcollector/shared/file_utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,39 @@ func Inotify(outputFile string, location string) error {
fmt.Println("Error creating inotify output file:", err)
}

// Define the command to start inotify
inotifyCommand := exec.Command(
"inotifywait",
location,
"--daemon",
"--recursive",
"--outfile", outputFile,
"--event", "create",
"--event", "delete",
"--format", "%e : %T",
"--timefmt", "+%s",
)

// Start the inotify process
err = inotifyCommand.Start()
if err != nil {
log.Fatalf("Error starting inotify process: %v\n", err)
fmt.Println("Error starting inotify process:", err)
}

return nil
}

func InotifyCCP(outputFile string, location string) error {
// Start inotify to watch for changes
fmt.Println("Starting inotify for watching config map update for ccp")

_, err := os.Create(outputFile)
if err != nil {
log.Fatalf("Error creating output file: %v\n", err)
fmt.Println("Error creating inotify output file:", err)
}

// Define the command to start inotify
inotifyCommand := exec.Command(
"inotifywait",
Expand Down

0 comments on commit 6223611

Please sign in to comment.