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

Check API errors when getting fields quota in setup job #1524

Merged
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
23 changes: 19 additions & 4 deletions deploy/helm/sumologic/conf/setup/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,33 @@ export HTTP_PROXY=${HTTP_PROXY:=""}
export HTTPS_PROXY=${HTTPS_PROXY:=""}
export NO_PROXY=${NO_PROXY:=""}

function remaining_fields() {
local RESPONSE="$(curl -XGET -s \
function get_remaining_fields() {
local RESPONSE
readonly RESPONSE="$(curl -XGET -s \
-u "${SUMOLOGIC_ACCESSID}:${SUMOLOGIC_ACCESSKEY}" \
"${SUMOLOGIC_BASE_URL}"v1/fields/quota)"

echo "${RESPONSE}" | jq '.remaining'
echo "${RESPONSE}"
}

# Check if we'd have at least 10 fields remaining after additional fields
# would be created for the collection
function should_create_fields() {
local REMAINING=$(remaining_fields)
local RESPONSE
readonly RESPONSE=$(get_remaining_fields)
pmalek-sumo marked this conversation as resolved.
Show resolved Hide resolved

if ! jq -e <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

if ! jq -e '.remaining' <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

local REMAINING
readonly REMAINING=$(jq -e '.remaining' <<< "${RESPONSE}")
if [[ $(( REMAINING - {{ len .Values.sumologic.logs.fields }} )) -ge 10 ]] ; then
return 0
else
Expand Down
23 changes: 19 additions & 4 deletions tests/terraform/static/all_fields.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,33 @@ data:
export HTTPS_PROXY=${HTTPS_PROXY:=""}
export NO_PROXY=${NO_PROXY:=""}

function remaining_fields() {
local RESPONSE="$(curl -XGET -s \
function get_remaining_fields() {
local RESPONSE
readonly RESPONSE="$(curl -XGET -s \
-u "${SUMOLOGIC_ACCESSID}:${SUMOLOGIC_ACCESSKEY}" \
"${SUMOLOGIC_BASE_URL}"v1/fields/quota)"

echo "${RESPONSE}" | jq '.remaining'
echo "${RESPONSE}"
}

# Check if we'd have at least 10 fields remaining after additional fields
# would be created for the collection
function should_create_fields() {
local REMAINING=$(remaining_fields)
local RESPONSE
readonly RESPONSE=$(get_remaining_fields)

if ! jq -e <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

if ! jq -e '.remaining' <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

local REMAINING
readonly REMAINING=$(jq -e '.remaining' <<< "${RESPONSE}")
if [[ $(( REMAINING - 8 )) -ge 10 ]] ; then
return 0
else
Expand Down
23 changes: 19 additions & 4 deletions tests/terraform/static/collector_fields.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,33 @@ data:
export HTTPS_PROXY=${HTTPS_PROXY:=""}
export NO_PROXY=${NO_PROXY:=""}

function remaining_fields() {
local RESPONSE="$(curl -XGET -s \
function get_remaining_fields() {
local RESPONSE
readonly RESPONSE="$(curl -XGET -s \
-u "${SUMOLOGIC_ACCESSID}:${SUMOLOGIC_ACCESSKEY}" \
"${SUMOLOGIC_BASE_URL}"v1/fields/quota)"

echo "${RESPONSE}" | jq '.remaining'
echo "${RESPONSE}"
}

# Check if we'd have at least 10 fields remaining after additional fields
# would be created for the collection
function should_create_fields() {
local REMAINING=$(remaining_fields)
local RESPONSE
readonly RESPONSE=$(get_remaining_fields)

if ! jq -e <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

if ! jq -e '.remaining' <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

local REMAINING
readonly REMAINING=$(jq -e '.remaining' <<< "${RESPONSE}")
if [[ $(( REMAINING - 8 )) -ge 10 ]] ; then
return 0
else
Expand Down
23 changes: 19 additions & 4 deletions tests/terraform/static/conditional_sources.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,33 @@ data:
export HTTPS_PROXY=${HTTPS_PROXY:=""}
export NO_PROXY=${NO_PROXY:=""}

function remaining_fields() {
local RESPONSE="$(curl -XGET -s \
function get_remaining_fields() {
local RESPONSE
readonly RESPONSE="$(curl -XGET -s \
-u "${SUMOLOGIC_ACCESSID}:${SUMOLOGIC_ACCESSKEY}" \
"${SUMOLOGIC_BASE_URL}"v1/fields/quota)"

echo "${RESPONSE}" | jq '.remaining'
echo "${RESPONSE}"
}

# Check if we'd have at least 10 fields remaining after additional fields
# would be created for the collection
function should_create_fields() {
local REMAINING=$(remaining_fields)
local RESPONSE
readonly RESPONSE=$(get_remaining_fields)

if ! jq -e <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

if ! jq -e '.remaining' <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

local REMAINING
readonly REMAINING=$(jq -e '.remaining' <<< "${RESPONSE}")
if [[ $(( REMAINING - 8 )) -ge 10 ]] ; then
return 0
else
Expand Down
23 changes: 19 additions & 4 deletions tests/terraform/static/custom.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,33 @@ data:
export HTTPS_PROXY=${HTTPS_PROXY:=""}
export NO_PROXY=${NO_PROXY:=""}

function remaining_fields() {
local RESPONSE="$(curl -XGET -s \
function get_remaining_fields() {
local RESPONSE
readonly RESPONSE="$(curl -XGET -s \
-u "${SUMOLOGIC_ACCESSID}:${SUMOLOGIC_ACCESSKEY}" \
"${SUMOLOGIC_BASE_URL}"v1/fields/quota)"

echo "${RESPONSE}" | jq '.remaining'
echo "${RESPONSE}"
}

# Check if we'd have at least 10 fields remaining after additional fields
# would be created for the collection
function should_create_fields() {
local REMAINING=$(remaining_fields)
local RESPONSE
readonly RESPONSE=$(get_remaining_fields)

if ! jq -e <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

if ! jq -e '.remaining' <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

local REMAINING
readonly REMAINING=$(jq -e '.remaining' <<< "${RESPONSE}")
if [[ $(( REMAINING - 8 )) -ge 10 ]] ; then
return 0
else
Expand Down
23 changes: 19 additions & 4 deletions tests/terraform/static/default.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,33 @@ data:
export HTTPS_PROXY=${HTTPS_PROXY:=""}
export NO_PROXY=${NO_PROXY:=""}

function remaining_fields() {
local RESPONSE="$(curl -XGET -s \
function get_remaining_fields() {
local RESPONSE
readonly RESPONSE="$(curl -XGET -s \
-u "${SUMOLOGIC_ACCESSID}:${SUMOLOGIC_ACCESSKEY}" \
"${SUMOLOGIC_BASE_URL}"v1/fields/quota)"

echo "${RESPONSE}" | jq '.remaining'
echo "${RESPONSE}"
}

# Check if we'd have at least 10 fields remaining after additional fields
# would be created for the collection
function should_create_fields() {
local REMAINING=$(remaining_fields)
local RESPONSE
readonly RESPONSE=$(get_remaining_fields)

if ! jq -e <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

if ! jq -e '.remaining' <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

local REMAINING
readonly REMAINING=$(jq -e '.remaining' <<< "${RESPONSE}")
if [[ $(( REMAINING - 8 )) -ge 10 ]] ; then
return 0
else
Expand Down
23 changes: 19 additions & 4 deletions tests/terraform/static/disable_default_metrics.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -252,18 +252,33 @@ data:
export HTTPS_PROXY=${HTTPS_PROXY:=""}
export NO_PROXY=${NO_PROXY:=""}

function remaining_fields() {
local RESPONSE="$(curl -XGET -s \
function get_remaining_fields() {
local RESPONSE
readonly RESPONSE="$(curl -XGET -s \
-u "${SUMOLOGIC_ACCESSID}:${SUMOLOGIC_ACCESSKEY}" \
"${SUMOLOGIC_BASE_URL}"v1/fields/quota)"

echo "${RESPONSE}" | jq '.remaining'
echo "${RESPONSE}"
}

# Check if we'd have at least 10 fields remaining after additional fields
# would be created for the collection
function should_create_fields() {
local REMAINING=$(remaining_fields)
local RESPONSE
readonly RESPONSE=$(get_remaining_fields)

if ! jq -e <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

if ! jq -e '.remaining' <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

local REMAINING
readonly REMAINING=$(jq -e '.remaining' <<< "${RESPONSE}")
if [[ $(( REMAINING - 8 )) -ge 10 ]] ; then
return 0
else
Expand Down
23 changes: 19 additions & 4 deletions tests/terraform/static/strip_extrapolation.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -260,18 +260,33 @@ data:
export HTTPS_PROXY=${HTTPS_PROXY:=""}
export NO_PROXY=${NO_PROXY:=""}

function remaining_fields() {
local RESPONSE="$(curl -XGET -s \
function get_remaining_fields() {
local RESPONSE
readonly RESPONSE="$(curl -XGET -s \
-u "${SUMOLOGIC_ACCESSID}:${SUMOLOGIC_ACCESSKEY}" \
"${SUMOLOGIC_BASE_URL}"v1/fields/quota)"

echo "${RESPONSE}" | jq '.remaining'
echo "${RESPONSE}"
}

# Check if we'd have at least 10 fields remaining after additional fields
# would be created for the collection
function should_create_fields() {
local REMAINING=$(remaining_fields)
local RESPONSE
readonly RESPONSE=$(get_remaining_fields)

if ! jq -e <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

if ! jq -e '.remaining' <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

local REMAINING
readonly REMAINING=$(jq -e '.remaining' <<< "${RESPONSE}")
if [[ $(( REMAINING - 8 )) -ge 10 ]] ; then
return 0
else
Expand Down
23 changes: 19 additions & 4 deletions tests/terraform/static/traces.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,33 @@ data:
export HTTPS_PROXY=${HTTPS_PROXY:=""}
export NO_PROXY=${NO_PROXY:=""}

function remaining_fields() {
local RESPONSE="$(curl -XGET -s \
function get_remaining_fields() {
local RESPONSE
readonly RESPONSE="$(curl -XGET -s \
-u "${SUMOLOGIC_ACCESSID}:${SUMOLOGIC_ACCESSKEY}" \
"${SUMOLOGIC_BASE_URL}"v1/fields/quota)"

echo "${RESPONSE}" | jq '.remaining'
echo "${RESPONSE}"
}

# Check if we'd have at least 10 fields remaining after additional fields
# would be created for the collection
function should_create_fields() {
local REMAINING=$(remaining_fields)
local RESPONSE
readonly RESPONSE=$(get_remaining_fields)

if ! jq -e <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

if ! jq -e '.remaining' <<< "${RESPONSE}" ; then
printf "Failed requesting fields API:\n%s\n" "${RESPONSE}"
return 1
fi

local REMAINING
readonly REMAINING=$(jq -e '.remaining' <<< "${RESPONSE}")
if [[ $(( REMAINING - 8 )) -ge 10 ]] ; then
return 0
else
Expand Down