Skip to content

Commit f28c07e

Browse files
committed
more curl timeout and version check removal
1 parent ed71949 commit f28c07e

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

splunkconf-backup/bin/splunkconf-backup.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ exec > /tmp/splunkconf-backup-debug.log 2>&1
150150
# 20251007 fix regression on BACKUPSTATE and BACKUPKV flag support to disable specific backups
151151
# 20251215 remove version check for kvdump, assuming always version at minimum 7.1
152152
# 20251215 add timeout for curl command to speed up backup for on prem with firewalls
153+
# 20251216 more versioncheck removal
154+
# 20251216 more curl timeout
153155

154-
VERSION="20251215b"
156+
VERSION="20251216b"
155157

156158
###### BEGIN default parameters
157159
# dont change here, use the configuration file to override them
@@ -1012,32 +1014,32 @@ if [ $CHECK -ne 0 ]; then
10121014
fi
10131015
elif [[ "cloud_type" -eq 2 ]]; then
10141016
# GCP
1015-
splunkinstanceType=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunkinstanceType`
1017+
splunkinstanceType=`curl --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunkinstanceType`
10161018
if [ -z ${splunkinstanceType+x} ]; then
10171019
debug_log "GCP : Missing splunkinstanceType in instance metadata"
10181020
else
10191021
# > to overwrite any old file here (upgrade case)
10201022
echo -e "splunkinstanceType=${splunkinstanceType}\n" > $INSTANCEFILE
10211023
fi
1022-
splunks3installbucket=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunks3installbucket`
1024+
splunks3installbucket=`curl --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunks3installbucket`
10231025
if [ -z ${splunks3installbucket+x} ]; then
10241026
debug_log "GCP : Missing splunks3installbucket in instance metadata"
10251027
else
10261028
echo -e "splunks3installbucket=${splunks3installbucket}\n" >> $INSTANCEFILE
10271029
fi
1028-
splunks3backupbucket=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunks3backupbucket`
1030+
splunks3backupbucket=`curl --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunks3backupbucket`
10291031
if [ -z ${splunks3backupbucket+x} ]; then
10301032
debug_log "GCP : Missing splunks3backupbucket in instance metadata"
10311033
else
10321034
echo -e "splunks3backupbucket=${splunks3backupbucket}\n" >> $INSTANCEFILE
10331035
fi
1034-
splunks3databucket=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunks3databucket`
1036+
splunks3databucket=`curl --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunks3databucket`
10351037
if [ -z ${splunks3databucket+x} ]; then
10361038
debug_log "GCP : Missing splunks3databucket in instance metadata"
10371039
else
10381040
echo -e "splunks3databucket=${splunks3databucket}\n" >> $INSTANCEFILE
10391041
fi
1040-
splunks3endpointurl=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunks3endpointurl`
1042+
splunks3endpointurl=`curl --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunks3endpointurl`
10411043

10421044
else
10431045
warn_log "aws cloud tag detection disabled (missing commands)"
@@ -2070,7 +2072,8 @@ fi
20702072
do_remote_copy;
20712073
fi
20722074

2073-
if (( $vermajor > $minimalversion )) && ([[ "$MODE" == "0" ]] || [[ "$MODE" == "kvdump" ]] || [[ "$MODE" == "kvauto" ]]); then
2075+
#if (( $vermajor > $minimalversion )) && ([[ "$MODE" == "0" ]] || [[ "$MODE" == "kvdump" ]] || [[ "$MODE" == "kvauto" ]]); then
2076+
if ([[ "$MODE" == "0" ]] || [[ "$MODE" == "kvdump" ]] || [[ "$MODE" == "kvauto" ]]); then
20742077
OBJECT="kvdump"
20752078
LFIC=${LFICKVDUMP}
20762079
RFIC=${FICKVDUMP}

splunkconf-backup/bin/splunkconf-purgebackup.sh

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ exec > /tmp/splunkconf-purgebackup-debug.log 2>&1
6262
# 20251007 resync load settings with updated regex
6363
# 20251215 add mode=purge to have more consistent logging
6464
# 20251215 add timeout for curl command to speed up backup for on prem with firewalls
65+
# 20251216 more curl timeout
6566

6667

67-
VERSION="20251215b"
68+
VERSION="20251216a"
6869

6970
###### BEGIN default parameters
7071
# dont change here, use the configuration file to override them
@@ -372,10 +373,10 @@ if [ $CHECK -ne 0 ]; then
372373
if [[ "cloud_type" -eq 1 ]]; then
373374
# aws
374375
# setting up token (IMDSv2)
375-
TOKEN=`curl --silent --show-error -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 900"`
376+
TOKEN=`curl --silent --show-error --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 900"`
376377
# lets get the s3splunkinstall from instance tags
377-
INSTANCE_ID=`curl --silent --show-error -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/instance-id `
378-
REGION=`curl --silent --show-error -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/.$//' `
378+
INSTANCE_ID=`curl --silent --show-error --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/instance-id `
379+
REGION=`curl --silent --show-error --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/.$//' `
379380

380381
# we put store tags in instance-tags file-> we will use this later on
381382
aws ec2 describe-tags --region $REGION --filter "Name=resource-id,Values=$INSTANCE_ID" --output=text | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:]]*=[[:space:]]*/=/' | sed -r 's/TAGS\t(.*)\t.*\t.*\t(.*)/\1="\2"/' | grep -E "^splunk" > $INSTANCEFILE
@@ -390,38 +391,38 @@ if [ $CHECK -ne 0 ]; then
390391
fi
391392
elif [[ "cloud_type" -eq 2 ]]; then
392393
# GCP
393-
splunkinstanceType=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunkinstanceType`
394+
splunkinstanceType=`curl ---connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunkinstanceType`
394395
if [ -z ${splunkinstanceType+x} ]; then
395396
debug_log "GCP : Missing splunkinstanceType in instance metadata"
396397
else
397398
# > to overwrite any old file here (upgrade case)
398399
echo -e "splunkinstanceType=${splunkinstanceType}\n" > $INSTANCEFILE
399400
fi
400-
splunks3installbucket=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunks3installbucket`
401+
splunks3installbucket=`curl --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunks3installbucket`
401402
if [ -z ${splunks3installbucket+x} ]; then
402403
debug_log "GCP : Missing splunks3installbucket in instance metadata"
403404
else
404405
echo -e "splunks3installbucket=${splunks3installbucket}\n" >> $INSTANCEFILE
405406
fi
406-
splunks3backupbucket=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunks3backupbucket`
407+
splunks3backupbucket=`curl --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunks3backupbucket`
407408
if [ -z ${splunks3backupbucket+x} ]; then
408409
debug_log "GCP : Missing splunks3backupbucket in instance metadata"
409410
else
410411
echo -e "splunks3backupbucket=${splunks3backupbucket}\n" >> $INSTANCEFILE
411412
fi
412-
splunks3databucket=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunks3databucket`
413+
splunks3databucket=`curl --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunks3databucket`
413414
if [ -z ${splunks3databucket+x} ]; then
414415
debug_log "GCP : Missing splunks3databucket in instance metadata"
415416
else
416417
echo -e "splunks3databucket=${splunks3databucket}\n" >> $INSTANCEFILE
417418
fi
418-
splunklocalbackupretentiondays=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunklocalbackupretentiondays`
419-
splunklocalbackupkvretentiondays=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunklocalbackupkvretentiondays`
420-
splunklocalbackupscriptsretentiondays=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunklocalbackupscriptsretentiondays`
421-
splunklocalbackupstateretentiondays=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunklocalbackupstateretentiondays`
422-
splunklocalbackupdir=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunklocalbackupdir`
423-
splunklocalmaxsize=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunklocalmaxsize`
424-
splunklocalmaxsizeauto=`curl -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunklocalmaxsizeauto`
419+
splunklocalbackupretentiondays=`curl --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunklocalbackupretentiondays`
420+
splunklocalbackupkvretentiondays=`curl --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunklocalbackupkvretentiondays`
421+
splunklocalbackupscriptsretentiondays=`curl --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunklocalbackupscriptsretentiondays`
422+
splunklocalbackupstateretentiondays=`curl --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunklocalbackupstateretentiondays`
423+
splunklocalbackupdir=`curl --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunklocalbackupdir`
424+
splunklocalmaxsize=`curl --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunklocalmaxsize`
425+
splunklocalmaxsizeauto=`curl --connect-timeout $CURLCONNECTTIMEOUT --max-time $CURLMAXTIME -H "Metadata-Flavor: Google" -fs http://metadata/computeMetadata/v1/instance/attributes/splunklocalmaxsizeauto`
425426

426427
else
427428
warn_log "aws cloud tag detection disabled (missing commands)"

0 commit comments

Comments
 (0)