Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DCSG2003
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Raphael Storm Larsen
DCSG2003
Commits
56939cac
Commit
56939cac
authored
2 years ago
by
Raphael Storm Larsen
Browse files
Options
Downloads
Patches
Plain Diff
pushed scaling to live version
parent
af907c75
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
configuration/manager/frontpage_scale.sh
+9
-10
9 additions, 10 deletions
configuration/manager/frontpage_scale.sh
with
9 additions
and
10 deletions
configuration/manager/frontpage_scale.sh
+
9
−
10
View file @
56939cac
...
...
@@ -51,12 +51,11 @@ function scale {
if
[
"
$SAFETY_VALVE
"
-eq
"0"
]
;
then
# Safety valve is off, we're running the command
$SSH_COMMAND
$COMMAND
discord_log
"Scaling to
$1
frontpage users"
else
# Saftey valve is on, we only print what we would do
discord_log
"Safety valve is on, this is what would be executed:
$SSH_COMMAND
$COMMAND
"
echo
"Safety valve is on, this is what would be executed:
$SSH_COMMAND
$COMMAND
"
fi
}
...
...
@@ -68,9 +67,9 @@ function scale {
STATUS
=
$(
curl
-s
-g
'http://admin:admin@192.168.132.61:9090/api/v1/query?query=last_status{name="'
$COMPANY_NAME
'"}'
| jq
-r
'.data.result[].value[1] '
)
if
[
"
$STATUS
"
-gt
"0"
]
;
then
discord_log
"Site is considered up"
echo
"Site is considered up"
else
discord_log
"Site is considered down, we should stop here"
echo
"Site is considered down, we should stop here"
exit
1
fi
...
...
@@ -79,12 +78,12 @@ fi
# Get current download times:
DOWNLOAD_TIME
=
$(
curl
-s
-g
'http://admin:admin@192.168.132.61:9090/api/v1/query?query=last_download_time{name="'
$COMPANY_NAME
'"}'
| jq
-r
'.data.result[].value[1] '
)
NUMBER_OF_FRONTPAGE_USERS
=
$(
curl
-s
-g
'http://admin:admin@192.168.132.61:9090/api/v1/query?query=frontpage_count{name="'
$COMPANY_NAME
'"}'
| jq
-r
'.data.result[].value[1] '
)
discord_log
"Observed download time:
$DOWNLOAD_TIME
"
echo
"Observed download time:
$DOWNLOAD_TIME
"
# check if we are below the lower threshold. If we are, we scale up
if
((
$(
echo
"
$DOWNLOAD_TIME
<
$DOWNLOAD_TIME_LOWER_THRESHOLD
"
| bc
-l
)
))
;
then
NEW_FRONTPAGE_COUNT
=
$(
echo
"
$NUMBER_OF_FRONTPAGE_USERS
+
$SCALE_UP_INCREMENT
"
| bc
)
discord_log
"Download time was lower, we have some capacity to spare. Scaling up to
$NEW_FRONTPAGE_COUNT
"
echo
"Download time was lower, we have some capacity to spare. Scaling up to
$NEW_FRONTPAGE_COUNT
"
scale
$NEW_FRONTPAGE_COUNT
# check if we are above the higher threshold. If we are, scale down, but not lower than the limit
...
...
@@ -92,7 +91,7 @@ elif (( $(echo "$DOWNLOAD_TIME > $DOWNLOAD_TIME_UPPER_THRESHOLD" | bc -l) )); th
# We can't go lower than the bottom
if
[
"
$NUMBER_OF_FRONTPAGE_USERS
"
-eq
"
$FRONTPAGE_COUNT_LIMIT
"
]
;
then
discord_log
"We should go lower, but we are already at the limit"
echo
"We should go lower, but we are already at the limit"
exit
0
fi
...
...
@@ -100,10 +99,10 @@ elif (( $(echo "$DOWNLOAD_TIME > $DOWNLOAD_TIME_UPPER_THRESHOLD" | bc -l) )); th
NEW_FRONTPAGE_COUNT
=
$(
echo
"
$NUMBER_OF_FRONTPAGE_USERS
-
$SCALE_DOWN_INCREMENT
"
| bc
)
if
[
"
$NEW_FRONTPAGE_COUNT
"
-lt
"
$FRONTPAGE_COUNT_LIMIT
"
]
;
then
discord_log
"We should scale down, but can't go lower then the limit, so we end up at
$FRONTPAGE_COUNT_LIMIT
"
echo
"We should scale down, but can't go lower then the limit, so we end up at
$FRONTPAGE_COUNT_LIMIT
"
NEW_FRONTPAGE_COUNT
=
$FRONTPAGE_COUNT_LIMIT
else
discord_log
"Scaling down to
$NEW_FRONTPAGE_COUNT
as new frontpage_limit"
echo
"Scaling down to
$NEW_FRONTPAGE_COUNT
as new frontpage_limit"
scale
$NEW_FRONTPAGE_COUNT
fi
fi
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment