Skip to content

Commit 564e102

Browse files
committed
splitting metrics due to OOM and fix coo installation
1 parent 49f7b2e commit 564e102

File tree

10 files changed

+762
-424
lines changed

10 files changed

+762
-424
lines changed

web/cypress/e2e/monitoring/regression/02.reg_metrics_admin.cy.ts renamed to web/cypress/e2e/monitoring/regression/02.reg_metrics_admin_1.cy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { runAllRegressionMetricsTests } from '../../../support/monitoring/02.reg_metrics.cy';
2-
import { runAllRegressionMetricsTestsNamespace } from '../../../support/monitoring/05.reg_metrics_namespace.cy';
1+
import { runAllRegressionMetricsTests1 } from '../../../support/monitoring/02.reg_metrics_1.cy';
2+
import { runAllRegressionMetricsTestsNamespace1 } from '../../../support/monitoring/05.reg_metrics_namespace_1.cy';
33
import { commonPages } from '../../../views/common';
44
import { nav } from '../../../views/nav';
55
import { guidedTour } from '../../../views/tour';
@@ -26,7 +26,7 @@ describe('Regression: Monitoring - Metrics (Administrator)', { tags: ['@monitori
2626
});
2727

2828
// Run tests in Administrator perspective
29-
runAllRegressionMetricsTests({
29+
runAllRegressionMetricsTests1({
3030
name: 'Administrator',
3131
});
3232

@@ -49,7 +49,7 @@ describe('Regression: Monitoring - Metrics Namespaced (Administrator)', { tags:
4949
});
5050

5151
// Run tests in Administrator perspective
52-
runAllRegressionMetricsTestsNamespace({
52+
runAllRegressionMetricsTestsNamespace1({
5353
name: 'Administrator',
5454
});
5555

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { runAllRegressionMetricsTests2 } from '../../../support/monitoring/02.reg_metrics_2.cy';
2+
import { runAllRegressionMetricsTestsNamespace2 } from '../../../support/monitoring/05.reg_metrics_namespace_2.cy';
3+
import { commonPages } from '../../../views/common';
4+
import { nav } from '../../../views/nav';
5+
import { guidedTour } from '../../../views/tour';
6+
7+
const MP = {
8+
namespace: 'openshift-monitoring',
9+
operatorName: 'Cluster Monitoring Operator',
10+
};
11+
12+
// Test suite for Administrator perspective
13+
describe('Regression: Monitoring - Metrics (Administrator)', { tags: ['@monitoring', '@metrics'] }, () => {
14+
15+
before(() => {
16+
cy.beforeBlock(MP);
17+
});
18+
19+
beforeEach(() => {
20+
cy.visit('/');
21+
guidedTour.close();
22+
cy.validateLogin();
23+
nav.sidenav.clickNavLink(['Observe', 'Metrics']);
24+
commonPages.titleShouldHaveText('Metrics');
25+
cy.changeNamespace("All Projects");
26+
});
27+
28+
// Run tests in Administrator perspective
29+
runAllRegressionMetricsTests2({
30+
name: 'Administrator',
31+
});
32+
33+
});
34+
35+
// Test suite for Administrator perspective
36+
describe('Regression: Monitoring - Metrics Namespaced (Administrator)', { tags: ['@monitoring', '@metrics'] }, () => {
37+
38+
before(() => {
39+
cy.beforeBlock(MP);
40+
});
41+
42+
beforeEach(() => {
43+
cy.visit('/');
44+
guidedTour.close();
45+
cy.validateLogin();
46+
nav.sidenav.clickNavLink(['Observe', 'Metrics']);
47+
commonPages.titleShouldHaveText('Metrics');
48+
cy.changeNamespace(MP.namespace);
49+
});
50+
51+
// Run tests in Administrator perspective
52+
runAllRegressionMetricsTestsNamespace2({
53+
name: 'Administrator',
54+
});
55+
56+
});
57+

web/cypress/e2e/virtualization/02.coo_ivt_metrics.cy.ts renamed to web/cypress/e2e/virtualization/02.coo_ivt_metrics_1.cy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { alerts } from '../../fixtures/monitoring/alert';
2-
import { runAllRegressionMetricsTests } from '../../support/monitoring/02.reg_metrics.cy';
3-
import { runAllRegressionMetricsTestsNamespace } from '../../support/monitoring/05.reg_metrics_namespace.cy';
2+
import { runAllRegressionMetricsTests1 } from '../../support/monitoring/02.reg_metrics_1.cy';
3+
import { runAllRegressionMetricsTestsNamespace1 } from '../../support/monitoring/05.reg_metrics_namespace_1.cy';
44
import { commonPages } from '../../views/common';
55
import { nav } from '../../views/nav';
66
import { guidedTour } from '../../views/tour';
@@ -71,7 +71,7 @@ describe('Regression: Monitoring - Metrics (Virtualization)', { tags: ['@virtual
7171
alerts.getWatchdogAlert();
7272
});
7373

74-
runAllRegressionMetricsTests({
74+
runAllRegressionMetricsTests1({
7575
name: 'Virtualization',
7676
});
7777

@@ -91,7 +91,7 @@ describe('Regression: Monitoring - Metrics Namespaced (Virtualization)', { tags:
9191
alerts.getWatchdogAlert();
9292
});
9393

94-
runAllRegressionMetricsTestsNamespace({
94+
runAllRegressionMetricsTestsNamespace1({
9595
name: 'Virtualization',
9696
});
9797

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { alerts } from '../../fixtures/monitoring/alert';
2+
import { runAllRegressionMetricsTests2 } from '../../support/monitoring/02.reg_metrics_2.cy';
3+
import { runAllRegressionMetricsTestsNamespace2 } from '../../support/monitoring/05.reg_metrics_namespace_2.cy';
4+
import { commonPages } from '../../views/common';
5+
import { nav } from '../../views/nav';
6+
import { guidedTour } from '../../views/tour';
7+
8+
// Set constants for the operators that need to be installed for tests.
9+
const MCP = {
10+
namespace: 'openshift-cluster-observability-operator',
11+
packageName: 'cluster-observability-operator',
12+
operatorName: 'Cluster Observability Operator',
13+
config: {
14+
kind: 'UIPlugin',
15+
name: 'monitoring',
16+
},
17+
};
18+
const MP = {
19+
namespace: 'openshift-monitoring',
20+
operatorName: 'Cluster Monitoring Operator',
21+
};
22+
23+
const KBV = {
24+
namespace: 'openshift-cnv',
25+
packageName: 'kubevirt-hyperconverged',
26+
config: {
27+
kind: 'HyperConverged',
28+
name: 'kubevirt-hyperconverged',
29+
},
30+
crd: {
31+
kubevirt: 'kubevirts.kubevirt.io',
32+
hyperconverged: 'hyperconvergeds.hco.kubevirt.io',
33+
}
34+
};
35+
36+
describe('Installation: COO and setting up Monitoring Plugin', { tags: ['@virtualization', '@slow'] }, () => {
37+
38+
before(() => {
39+
cy.beforeBlockCOO(MCP, MP);
40+
});
41+
42+
it('1. Installation: COO and setting up Monitoring Plugin', () => {
43+
cy.log('Installation: COO and setting up Monitoring Plugin');
44+
});
45+
});
46+
47+
describe('IVT: Monitoring UIPlugin + Virtualization', { tags: ['@virtualization', '@slow'] }, () => {
48+
49+
before(() => {
50+
cy.beforeBlockVirtualization(KBV);
51+
});
52+
53+
it('1. Virtualization perspective - Observe Menu', () => {
54+
cy.log('Virtualization perspective - Observe Menu and verify all submenus');
55+
cy.switchPerspective('Virtualization');
56+
guidedTour.closeKubevirtTour();
57+
});
58+
});
59+
60+
describe('Regression: Monitoring - Metrics (Virtualization)', { tags: ['@virtualization', '@metrics'] }, () => {
61+
62+
beforeEach(() => {
63+
cy.visit('/');
64+
cy.validateLogin();
65+
cy.switchPerspective('Virtualization');
66+
guidedTour.closeKubevirtTour();
67+
alerts.getWatchdogAlert();
68+
nav.sidenav.clickNavLink(['Observe', 'Metrics']);
69+
commonPages.titleShouldHaveText('Metrics');
70+
cy.changeNamespace("All Projects");
71+
alerts.getWatchdogAlert();
72+
});
73+
74+
runAllRegressionMetricsTests2({
75+
name: 'Virtualization',
76+
});
77+
78+
});
79+
80+
describe('Regression: Monitoring - Metrics Namespaced (Virtualization)', { tags: ['@virtualization', '@metrics'] }, () => {
81+
82+
beforeEach(() => {
83+
cy.visit('/');
84+
cy.validateLogin();
85+
cy.switchPerspective('Virtualization');
86+
guidedTour.closeKubevirtTour();
87+
alerts.getWatchdogAlert();
88+
nav.sidenav.clickNavLink(['Observe', 'Metrics']);
89+
commonPages.titleShouldHaveText('Metrics');
90+
cy.changeNamespace(MP.namespace);
91+
alerts.getWatchdogAlert();
92+
});
93+
94+
runAllRegressionMetricsTestsNamespace2({
95+
name: 'Virtualization',
96+
});
97+
98+
});
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
3+
# Script to force-delete a Kubernetes Namespace stuck in a 'Terminating' state
4+
# by automatically clearing its finalizers using sed and tr (instead of jq).
5+
6+
NAMESPACE=$1
7+
KUBECONFIG_PATH=$2
8+
9+
echo "NAMESPACE: $NAMESPACE"
10+
echo "KUBECONFIG_PATH: $KUBECONFIG_PATH"
11+
12+
# --- Input Validation ---
13+
if [ -z "$NAMESPACE" ]; then
14+
echo "Error: Please provide the namespace name as the first argument."
15+
echo "Usage: ./force-delete-ns.sh <namespace-name> [kubeconfig-path]"
16+
exit 1
17+
fi
18+
19+
# Build kubeconfig flag if provided
20+
KUBECONFIG_FLAG=""
21+
if [ -n "$KUBECONFIG_PATH" ]; then
22+
KUBECONFIG_FLAG="--kubeconfig $KUBECONFIG_PATH"
23+
fi
24+
25+
# Check if the namespace exists
26+
if ! oc get namespace "$NAMESPACE" $KUBECONFIG_FLAG &> /dev/null; then
27+
echo "Namespace '$NAMESPACE' not found or already deleted."
28+
exit 0
29+
fi
30+
31+
echo "Attempting to force-delete namespace '$NAMESPACE' by removing finalizers..."
32+
33+
# Step 1: Remove finalizers from common problematic resources
34+
echo "Checking for resources with finalizers in namespace '$NAMESPACE'..."
35+
# Focus on common resources that have finalizers (much faster than checking everything)
36+
RESOURCE_TYPES="perses,persesdashboard,persistentvolumeclaims,pods,services,deployments,statefulsets,daemonsets"
37+
38+
for resource_type in $(echo $RESOURCE_TYPES | tr ',' ' '); do
39+
oc get "$resource_type" -n "$NAMESPACE" $KUBECONFIG_FLAG -o name 2>/dev/null | \
40+
while read -r item; do
41+
if [ -n "$item" ]; then
42+
# Check if the resource has finalizers
43+
HAS_FINALIZERS=$(oc get "$item" -n "$NAMESPACE" $KUBECONFIG_FLAG -o jsonpath='{.metadata.finalizers}' 2>/dev/null || echo "")
44+
if [ -n "$HAS_FINALIZERS" ] && [ "$HAS_FINALIZERS" != "[]" ]; then
45+
echo " Removing finalizers from $item..."
46+
oc patch "$item" -n "$NAMESPACE" $KUBECONFIG_FLAG --type json -p '[{"op": "remove", "path": "/metadata/finalizers"}]' 2>/dev/null || true
47+
fi
48+
fi
49+
done
50+
done
51+
52+
# Step 2: Remove finalizers from the namespace itself (if it still exists)
53+
# Check if namespace still exists before trying to remove its finalizers
54+
if oc get namespace "$NAMESPACE" $KUBECONFIG_FLAG &> /dev/null; then
55+
# 1. Retrieve the namespace JSON.
56+
# 2. Use 'tr' to remove all newlines, creating a single-line JSON string.
57+
# 3. Use 'sed' to perform a substitution:
58+
# - It finds the pattern "finalizers": [ <anything that is not a closing bracket> ]
59+
# - It replaces the entire pattern with "finalizers": [] (an empty array).
60+
# 4. Pipe the modified JSON directly to the Kubernetes /finalize endpoint.
61+
echo "Removing finalizers from namespace '$NAMESPACE' itself..."
62+
oc get namespace "$NAMESPACE" $KUBECONFIG_FLAG -o json | \
63+
tr -d '\n' | \
64+
sed 's/"finalizers": \[[^]]*\]/"finalizers": []/' | \
65+
oc replace $KUBECONFIG_FLAG --raw "/api/v1/namespaces/$NAMESPACE/finalize" -f -
66+
67+
EXIT_CODE=$?
68+
69+
if [ $EXIT_CODE -eq 0 ]; then
70+
echo ""
71+
echo "✅ Success: Finalizers for namespace '$NAMESPACE' have been cleared."
72+
echo "The Namespace should now be fully deleted. Confirm with: oc get ns"
73+
else
74+
echo ""
75+
echo "❌ Error: The command failed with exit code $EXIT_CODE."
76+
echo "Please check your oc connection and the namespace name."
77+
fi
78+
else
79+
echo ""
80+
echo "✅ Success: Namespace '$NAMESPACE' was already deleted after removing resource finalizers."
81+
EXIT_CODE=0
82+
fi

0 commit comments

Comments
 (0)