Skip to content

Conversation

@samiura
Copy link

@samiura samiura commented Nov 6, 2025

Added logs uploader for installation scripts and made sure they do not interrupt the installation process even in case of endpoint failure(s). This PR is based on

https://github.com/SumoLogic/sumologic-otel-collector-packaging/pull/64/files#diff-fa1bbdf24117b058c9042b791f3279c4cd60ecfac8af20e23f702b98c5ad6376

@samiura samiura force-pushed the installation-logs-uploaders branch 2 times, most recently from 28a76e7 to f83a9b2 Compare November 6, 2025 21:43
@samiura samiura force-pushed the installation-logs-uploaders branch from f83a9b2 to 0c294be Compare November 6, 2025 21:48
@samiura samiura marked this pull request as ready for review November 7, 2025 00:02
@samiura samiura requested review from a team as code owners November 7, 2025 00:02
# The API URL used to communicate with the SumoLogic backend
[string] $Api,

# DidsableIntallationTelemetry is used to disable reporting the installation
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: Didsable -> Disable

$InstallationLogFile = New-TemporaryFile

if ($InstallationLogFileEndpoint -eq "") {
## https://sumologic.atlassian.net/wiki/spaces/MAIN/pages/1601341782/Production+Deployments+and+More#ProductionDeploymentsandMore-StagingDeployments
Copy link
Contributor

Choose a reason for hiding this comment

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

As much as this is useful for us, you should probably drop that comment since this is a public repo.

$errMsg += ": ${content}"
}

Write-Error -Message $errMsg
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this not equivalent to Write-Error $errMsg?
Also, what happens when there is an error; e.g. have you tried running the script against a non-existent endpoint?

Since we're OK if we don't get those installation logs and we don't want to "scare" the user with an error here, maybe the best course of action is to drop Write-Error altogether?

Copy link
Author

@samiura samiura Nov 7, 2025

Choose a reason for hiding this comment

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

Oh I see the point. I was thinking halting was the cause of customer panic. Okay, we just have to use something else all together/or as you suggested remove. Thinking about using Write-Verbose but I guess removing is the best option as you suggested.

[string] $Api,

# DidsableIntallationTelemetry is used to disable reporting the installation
# DisableIntallationTelemetry is used to disable reporting the installation

Choose a reason for hiding this comment

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

typo: DisableInstallationTelemetry

Copy link
Author

@samiura samiura Nov 7, 2025

Choose a reason for hiding this comment

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

Already addressed in the latest commit. #213 (comment)

Choose a reason for hiding this comment

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

in the PR: DisableIntallationTelemetry (installation is missing an S)

@samiura samiura force-pushed the installation-logs-uploaders branch from ab7a2dd to ea5eb46 Compare November 7, 2025 21:51
Copy link

@chan-tim-sumo chan-tim-sumo left a comment

Choose a reason for hiding this comment

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

looks good overall :D few comments

Write-Error $_.Exception.InnerException.Message -ErrorAction Stop
} finally {
Stop-Transcript | Out-Null
if ($InstallationToken -eq $true) {

Choose a reason for hiding this comment

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

not too familiar with powershell, i'm assuming this line means if installation token equals to true?

is installation token a boolean?

if (!($response.IsSuccessStatusCode)) {
$statusCode = [int]$response.StatusCode
$reasonPhrase = $response.StatusCode.ToString()
$errMsg = "${statusCode} ${reasonPhrase}"
Copy link

@chan-tim-sumo chan-tim-sumo Nov 11, 2025

Choose a reason for hiding this comment

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

will this continue to run even after the error message pops up? should the error message get thrown? i saw write-error on line 408:

        Write-Error "Installation token has not been provided." -ErrorAction Stop

# shellcheck disable=SC2317,SC2119,SC2120,SC2317,SC2329,SC1072,SC1073,SC1125
function reporter {
if ! $DISABLE_INSTALLATION_TELEMETRY; then
echo "SUMOLOGIC_INSTALLATION_TOKEN=${SUMOLOGIC_INSTALLATION_TOKEN}" >> "$INSTALLATION_LOGFILE"

Choose a reason for hiding this comment

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

is writing the installation token to the log file to /tmp safe?

i saw in the repo

function set_tmpdir() {
    # generate a new tmpdir using mktemp
    # need to specify the template for some MacOS versions
    TMPDIR=$(mktemp -d -t 'sumologic-otel-collector-XXXX')
}

i was looking at what mktemp is, and it creates a secure temporary file. would using something like that be better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants