-
Notifications
You must be signed in to change notification settings - Fork 0
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
COSI-46 expose metrics service in kubernetes and E2E test #72
Open
anurag4DSB
wants to merge
5
commits into
feature/COSI-19-add-s3-and-iam-metrics
Choose a base branch
from
feature/COSI-46-expose-metrics-service-in-kubernetes
base: feature/COSI-19-add-s3-and-iam-metrics
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8f4f38a
Expose metrics service in Kubernetes
anurag4DSB d46982a
Add metrics service to helm chart
anurag4DSB e477885
Add end-2-end tests for metrics service
anurag4DSB c65a2b1
fixup post review 1
anurag4DSB 7e74398
debug commit
anurag4DSB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
LOG_FILE=".github/e2e_tests/artifacts/logs/e2e_tests/metrics_service.log" | ||
mkdir -p "$(dirname "$LOG_FILE")" | ||
|
||
NAMESPACE="scality-object-storage" | ||
SERVICE="scality-cosi-metrics" | ||
LOCAL_PORT=8080 | ||
TARGET_PORT=8080 | ||
|
||
# Error handling function | ||
error_handler() { | ||
echo "An error occurred during bucket creation tests. Check the log file for details." | tee -a "$LOG_FILE" | ||
echo "Failed command: $BASH_COMMAND" | tee -a "$LOG_FILE" | ||
exit 1 | ||
} | ||
|
||
# Trap errors and call the error handler | ||
trap 'error_handler' ERR | ||
|
||
# Log command execution to the log file for debugging | ||
log_and_run() { | ||
"$@" 2>&1 | tee -a "$LOG_FILE" | ||
} | ||
|
||
log_and_run kubectl describe svc scality-cosi-driver-metrics -n scality-object-storage | ||
|
||
log_and_run kubectl port-forward svc/scality-cosi-driver-metrics -n scality-object-storage 8080:8080 & | ||
PORT_FORWARD_PID=$! | ||
|
||
if ps -p $PORT_FORWARD_PID > /dev/null; then | ||
log_and_run echo "Port-forwarding established. Querying metrics..." | ||
|
||
log_and_run curl -f http://localhost:$LOCAL_PORT/metrics > metrics_output.txt | ||
|
||
if [ $? -eq 0 ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you might lose the curl return code with the pipe |
||
log_and_run echo "Metrics fetched successfully. Metrics output:" | ||
log_and_run cat metrics_output.txt | ||
METRICS_WORKING=true | ||
else | ||
log_and_run echo "Failed to fetch metrics from http://localhost:$LOCAL_PORT/metrics" | ||
METRICS_WORKING=false | ||
fi | ||
|
||
log_and_run kill $PORT_FORWARD_PID | ||
else | ||
log_and_run echo "Port-forwarding failed to establish." | ||
METRICS_WORKING=false | ||
fi | ||
|
||
if [ "$METRICS_WORKING" = true ]; then | ||
log_and_run echo "Metrics service is working as expected." | ||
exit 0 | ||
else | ||
log_and_run echo "Metrics service is not working as expected." | ||
exit 1 | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,10 @@ jobs: | |
run: | | ||
.github/scripts/e2e_tests_brownfield_use_case.sh | ||
|
||
- name: E2E tests for metrics service using kustomize | ||
run: | | ||
.github/scripts/e2e_tests_metrics_service.sh | ||
|
||
- name: "Delay completion" | ||
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} | ||
uses: scality/actions/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ include "scality-cosi-driver.fullname" . }}-metrics | ||
labels: | ||
app.kubernetes.io/name: {{ include "scality-cosi-driver.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/part-of: container-object-storage-interface | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
spec: | ||
selector: | ||
app.kubernetes.io/name: {{ include "scality-cosi-driver.name" . }} | ||
ports: | ||
- protocol: TCP | ||
port: {{ .Values.metrics.port }} | ||
targetPort: {{ .Values.metrics.port }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing newline at end of some files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ resources: | |
- serviceaccount.yaml | ||
- rbac.yaml | ||
- deployment.yaml | ||
- metrics-service.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: scality-cosi-metrics | ||
labels: | ||
app.kubernetes.io/name: scality-cosi-driver | ||
app.kubernetes.io/part-of: container-object-storage-interface | ||
spec: | ||
selector: | ||
app.kubernetes.io/name: scality-cosi-driver | ||
ports: | ||
- protocol: TCP | ||
port: 8080 # The port Prometheus will scrape | ||
targetPort: 8080 # The port exposed by the container |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be replaced with the
set -x
option on bash