Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store position and buffer files under the top installation directory. #282

Merged
merged 4 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion windows-installer/fluent-template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<match **>
@type google_cloud
buffer_type file
buffer_path /var/log/google-fluentd/buffers
buffer_path BUFFER_PATH_PLACE_HOLDER
# Set the chunk limit conservatively to avoid exceeding the recommended
# chunk size of 10MB per write request. The API request size can be a few
# times bigger than the raw log size.
Expand Down
22 changes: 19 additions & 3 deletions windows-installer/setup.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
; Directory where the fluentd config will be placed.
jkschulz marked this conversation as resolved.
Show resolved Hide resolved
!define FLUENTD_CONFIG_DIRECTORY "$INSTDIR"

; Directory under which the buffer files will be stored.
!define BUFFER_FILE_DIRECTORY "$INSTDIR\buffers"

; Directory under which the pos files will be stored.
!define POS_FILE_DIRECTORY "$INSTDIR\pos"

; Directory for the user to add custom configs.
!define CUSTOM_CONFIG_DIR "config.d"

Expand Down Expand Up @@ -167,7 +173,7 @@ Section "Install"
; Create a directory for the extracted files.
CreateDirectory ${MAIN_INSTDIR}
; Extract the needed files and show status.
${Print} "Extracting files to $INSTDIR..."
${Print} "Extracting files to $MAIN_INSTDIR..."
nsisunz::Unzip "$OUTDIR\${ZIP_FILE}" "${MAIN_INSTDIR}"
Pop $0

Expand All @@ -182,8 +188,10 @@ Section "Install"
; Delete the zip file after extraction.
Delete "$OUTDIR\${ZIP_FILE}"

; Create a directory to store buffer files.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We make the folders before we know if they set the paths to something custom or not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the buffer path is fixed relative to $INSTDIR. Or were you asking about a custom $INSTDIR?
Yes, we do create the folders unconditionally, but it shouldn't matter, because the operation is idempotent.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if they're set to something custom (i.e. the placeholder is replaced in the config)? Say the default for one of them is defined as default/dir/path but in the config, it's set to custom/dir/path. This looks like it'll only create default/dir/path. Does the custom one get created at another point?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When installing windows agent, it pops up an installer which you can customize the installation directory. Are you sayin it will be replacing the $INSTDIR otherwise the default will be "$env:UserProfile"?
Another question: where we gave the default value all those parameter after CreateDirectory, e.x. ${MAIN_INSTDIR}?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkschulz By the time the installer runs, $INSTDIR is already set.

@sophieyfang Sorry, missed this question. The default value is set by the InstallDir directive (line 78).

CreateDirectory ${BUFFER_FILE_DIRECTORY}
; Create a directory to store position files.
CreateDirectory ${MAIN_INSTDIR}\pos
CreateDirectory ${POS_FILE_DIRECTORY}
; Create a directory for custom configs.
CreateDirectory "${FLUENTD_CONFIG_DIRECTORY}\${CUSTOM_CONFIG_DIR}"

Expand Down Expand Up @@ -213,12 +221,20 @@ Section "Install"
; Trim out newlines as WordFind cannot handle them.
${StrTrimNewLines} $3 "$2"

; Look for 'BUFFER_PATH_PLACE_HOLDER', if found replace it with the
; proper path.
${WordFind} "$3" "BUFFER_PATH_PLACE_HOLDER" "#" $4
${If} $4 == "1"
; Replace the whole line instead of using "StrRep" to avoid unicode issues.
StrCpy $2 " buffer_path '${BUFFER_FILE_DIRECTORY}'$\r$\n"
${EndIf}

; Look for 'WIN_EVT_POS_FILE_PLACE_HOLDER', if found replace it with the
; proper pos_file.
${WordFind} "$3" "WIN_EVT_POS_FILE_PLACE_HOLDER" "#" $4
${If} $4 == "1"
; Replace the whole line instead of using "StrRep" to avoid unicode issues.
StrCpy $2 " path '${MAIN_INSTDIR}\pos\winevtlog.pos'$\r$\n"
StrCpy $2 " path '${POS_FILE_DIRECTORY}\winevtlog.pos'$\r$\n"
${EndIf}

; Look for 'CUSTOM_CONFIG_PLACE_HOLDER', if found replace it with the
Expand Down