Skip to content

Commit

Permalink
Merge pull request #838 from chaos-genius/develop
Browse files Browse the repository at this point in the history
Release v0.5.1
  • Loading branch information
manassolanki committed Mar 22, 2022
2 parents d64d025 + 3554bcb commit bfe7b38
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 99 deletions.
2 changes: 1 addition & 1 deletion chaos_genius/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _make_bool(val: Union[str, bool]) -> bool:
TASK_CHECKPOINT_LIMIT: int = int(os.getenv("TASK_CHECKPOINT_LIMIT", 1000))
"""Number of last checkpoints to retrieve in Task Monitor"""

CHAOSGENIUS_VERSION_MAIN = os.getenv("CHAOSGENIUS_VERSION_MAIN", "0.5.0")
CHAOSGENIUS_VERSION_MAIN = os.getenv("CHAOSGENIUS_VERSION_MAIN", "0.5.1")
"""ChaosGenius version - semver part only"""
CHAOSGENIUS_VERSION_POSTFIX = os.getenv("CHAOSGENIUS_VERSION_POSTFIX", "git")
"""ChaosGenius version - postfix to identify deployment"""
Expand Down
117 changes: 62 additions & 55 deletions chaos_genius/views/config_setting_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
get_config_object,
create_config_object,
get_all_configurations,
get_multidim_status_for_kpi
get_multidim_status_for_kpi,
)
from chaos_genius.databases.db_utils import chech_editable_field
from copy import deepcopy
Expand All @@ -28,49 +28,47 @@ def get_onboarding_status():
data_sources, kpis, analytics = False, False, False
organisation_settings = False
try:
data_sources = True if DataSource.query.first() is not None else False
kpis = True if Kpi.query.first() is not None else False
data_sources = (
True
if DataSource.query.filter(DataSource.active == True).first() is not None
else False
)
kpis = (
True
if Kpi.query.filter(Kpi.active == True).first() is not None
else False
)
if kpis:
kpi_list = Kpi.query.filter(
Kpi.active == True,
Kpi.anomaly_params != None
).all()
Kpi.active == True, Kpi.anomaly_params != None
).all()

analytics = True if len(kpi_list) > 0 else False

organisation_settings_value = ConfigSetting.query.filter(
ConfigSetting.name == "organisation_settings",
ConfigSetting.active == True
).all()
ConfigSetting.name == "organisation_settings", ConfigSetting.active == True
).all()
organisation_settings = True if len(organisation_settings_value) > 0 else False
except Exception as err_msg:
print(err_msg)

steps = [
{
"step_no": 1,
"step_name": "Add Data Source",
"step_done": data_sources
}, {
"step_no": 2,
"step_name": "Add KPI",
"step_done": kpis
}, {
"step_no": 3,
"step_name": "Activate Analytics",
"step_done": analytics
}
{"step_no": 1, "step_name": "Add Data Source", "step_done": data_sources},
{"step_no": 2, "step_name": "Add KPI", "step_done": kpis},
{"step_no": 3, "step_name": "Activate Analytics", "step_done": analytics},
]
completion_precentage = int(
len([step for step in steps if step["step_done"]]) / len(steps) * 100
)
return jsonify({
"data": {
"steps": steps,
"completion_precentage": completion_precentage,
"organisation_onboarding": organisation_settings
return jsonify(
{
"data": {
"steps": steps,
"completion_precentage": completion_precentage,
"organisation_onboarding": organisation_settings,
}
}
})
)


@blueprint.route("/get-config", methods=["POST"])
Expand All @@ -81,10 +79,7 @@ def get_config():
name = data.get("config_name")
config_obj = get_config_object(name)
if not config_obj:
return jsonify({
"status": "not_found",
"message": "Config doesn't exist"
})
return jsonify({"status": "not_found", "message": "Config doesn't exist"})

config_state = get_modified_config_file(config_obj.safe_dict, name)
return jsonify({"data": config_state, "status": "success"})
Expand All @@ -103,11 +98,13 @@ def set_config():
if request.is_json:
data = request.get_json()
config_name = data.get("config_name")
if config_name not in ["email", "slack", "organisation_settings", "alert_digest_settings"]:
return jsonify({
"status": "not_found",
"message": "Config doesn't exist"
})
if config_name not in [
"email",
"slack",
"organisation_settings",
"alert_digest_settings",
]:
return jsonify({"status": "not_found", "message": "Config doesn't exist"})
config_obj = get_config_object(config_name)
config_settings = data.get("config_settings", {})
updated_config_settings = {}
Expand All @@ -119,16 +116,20 @@ def set_config():
for module in config_settings.keys():
updated_config_settings[module].update(config_settings[module])
else:
updated_config_settings.update(data.get("config_settings", {})) #this will work for all email, slack and alert_digest_settings
updated_config_settings.update(
data.get("config_settings", {})
) # this will work for all email, slack and alert_digest_settings

if not updated_config_settings:
updated_config_settings = config_settings
new_config = create_config_object(config_name, updated_config_settings)
new_config.save(commit=True)
return jsonify({
"message": f"{config_name.capitalize()} configuration has been saved successfully.",
"status": "success",
})
return jsonify(
{
"message": f"{config_name.capitalize()} configuration has been saved successfully.",
"status": "success",
}
)
else:
return jsonify(
{
Expand All @@ -143,7 +144,9 @@ def get_all_config():
"""Getting all the setting."""
try:
result = get_all_configurations()
alert_destination_result = [config for config in result if config["name"] in ("slack", "email")]
alert_destination_result = [
config for config in result if config["name"] in ("slack", "email")
]
return jsonify({"data": alert_destination_result, "status": "success"})
except Exception as err:
return jsonify({"message": err, "status": "failure"})
Expand Down Expand Up @@ -171,10 +174,9 @@ def test_alert():
data["alertMessage"],
overall_stats,
)
return jsonify({
"message": "Alert has been tested successfully.",
"status": status
})
return jsonify(
{"message": "Alert has been tested successfully.", "status": status}
)
else:
return jsonify({"error": "The request payload is not in JSON format"})

Expand All @@ -194,9 +196,7 @@ def get_config_meta_data(config):
results["fields"] = fields
return jsonify({"data": results, "status": "success"})
except Exception as err:
current_app.logger.info(
f"Error in getting meta info for Config Setting: {err}"
)
current_app.logger.info(f"Error in getting meta info for Config Setting: {err}")
return jsonify({"message": str(err), "status": "failure"})


Expand All @@ -209,7 +209,7 @@ def multidim_status():
try:
kpi_id = request.args.get("kpi_id")
data["multidim_status"] = get_multidim_status_for_kpi(kpi_id)
status="success"
status = "success"
except Exception as err:
status = "failure"
current_app.logger.info(f"Error in fetching Dashboad Config Data: {err}")
Expand All @@ -232,8 +232,15 @@ def edit_config_setting():

for module in updated_settings.keys():
for key in updated_settings.get(module).keys():
if meta_info["organisation_settings"][module][key]["is_editable"] == True:
new_config_settings[module][key] = updated_settings[module][key]
if (
meta_info["organisation_settings"][module][key][
"is_editable"
]
== True
):
new_config_settings[module][key] = updated_settings[module][
key
]

config_obj.config_setting = new_config_settings
config_obj.save(commit=True)
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.thirdparty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ services:

chaosgenius-server:
container_name: chaosgenius-server
image: chaosgenius/chaosgenius-server:0.5.0
image: chaosgenius/chaosgenius-server:0.5.1
command: sh setup/run-backend-docker.sh
volumes:
- /var/run/docker.sock:/var/run/docker.sock
Expand Down Expand Up @@ -93,7 +93,7 @@ services:

chaosgenius-webapp:
container_name: chaosgenius-webapp
image: chaosgenius/chaosgenius-webapp:0.5.0
image: chaosgenius/chaosgenius-webapp:0.5.1
command: >
sh -c "npx react-inject-env set -d ./ &&
nginx -g 'daemon off;'"
Expand Down Expand Up @@ -133,7 +133,7 @@ services:

chaosgenius-scheduler:
container_name: chaosgenius-scheduler
image: chaosgenius/chaosgenius-server:0.5.0
image: chaosgenius/chaosgenius-server:0.5.1
command: celery -A run.celery beat --loglevel=DEBUG
environment:
- IN_DOCKER=True
Expand Down Expand Up @@ -168,7 +168,7 @@ services:

chaosgenius-worker-analytics:
container_name: chaosgenius-worker-analytics
image: chaosgenius/chaosgenius-server:0.5.0
image: chaosgenius/chaosgenius-server:0.5.1
command: celery -A run.celery worker --loglevel=INFO --concurrency=2 -P processes -Q anomaly-rca
environment:
- IN_DOCKER=True
Expand Down Expand Up @@ -220,7 +220,7 @@ services:

chaosgenius-worker-alerts:
container_name: chaosgenius-worker-alerts
image: chaosgenius/chaosgenius-server:0.5.0
image: chaosgenius/chaosgenius-server:0.5.1
command: celery -A run.celery worker --loglevel=INFO --concurrency=2 -P processes -Q alerts
environment:
- IN_DOCKER=True
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ x-version:
services:
chaosgenius-server:
container_name: chaosgenius-server
image: chaosgenius/chaosgenius-server:0.5.0
image: chaosgenius/chaosgenius-server:0.5.1
command: sh setup/run-backend-docker.sh
volumes:
- /var/run/docker.sock:/var/run/docker.sock
Expand Down Expand Up @@ -67,7 +67,7 @@ services:

chaosgenius-webapp:
container_name: chaosgenius-webapp
image: chaosgenius/chaosgenius-webapp:0.5.0
image: chaosgenius/chaosgenius-webapp:0.5.1
command: >
sh -c "npx react-inject-env set -d ./ &&
nginx -g 'daemon off;'"
Expand Down Expand Up @@ -105,7 +105,7 @@ services:

chaosgenius-scheduler:
container_name: chaosgenius-scheduler
image: chaosgenius/chaosgenius-server:0.5.0
image: chaosgenius/chaosgenius-server:0.5.1
command: celery -A run.celery beat --loglevel=DEBUG
environment:
- IN_DOCKER=True
Expand Down Expand Up @@ -140,7 +140,7 @@ services:

chaosgenius-worker-analytics:
container_name: chaosgenius-worker-analytics
image: chaosgenius/chaosgenius-server:0.5.0
image: chaosgenius/chaosgenius-server:0.5.1
command: celery -A run.celery worker --loglevel=INFO --concurrency=2 -P processes -Q anomaly-rca
environment:
- IN_DOCKER=True
Expand Down Expand Up @@ -192,7 +192,7 @@ services:

chaosgenius-worker-alerts:
container_name: chaosgenius-worker-alerts
image: chaosgenius/chaosgenius-server:0.5.0
image: chaosgenius/chaosgenius-server:0.5.1
command: celery -A run.celery worker --loglevel=INFO --concurrency=2 -P processes -Q alerts
environment:
- IN_DOCKER=True
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/assets/images/sidebar/slack-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions frontend/src/assets/images/slack-small-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions frontend/src/components/DashboardGraph/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,13 @@ const Dashboardgraph = ({ kpi, kpiName, anomalystatus }) => {
},
yAxis: {
type: 'value',
step: 1,
title: {
text: 'values'
},
labels: {
formatter: function () {
return HRNumbers.toHumanString(this.value);
}
},
title: {
margin: 25
}
},
plotOptions: {
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/components/EmptyKPI/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import Documents from '../../assets/images/document-green.svg';

import slacksmall from '../../assets/images/slack-small-logo.svg';
import './emptykpi.scss';

const EmptyKPI = () => {
Expand Down Expand Up @@ -40,7 +40,14 @@ const EmptyKPI = () => {
rel="noopener noreferrer">
Troubleshoot guide{' '}
</a>
for you or feel free to ping us on our Community Slack!
for you or feel free to ping us on our{' '}
<a
href="https://join.slack.com/t/chaosgenius/shared_invite/zt-140042uac-rrm~xbx9o_aydi6PTmp_Mg"
target="_blank"
rel="noopener noreferrer">
Community Slack{' '}
<img src={slacksmall} className="in-active" alt="Slack" />
</a>
</h5>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/FilterAnalystics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const FilterAnalystics = ({ kpi, setKpi, data, onboarding }) => {
<li
key={uuidv4()}
className={
kpi.toString() === item.id.toString() ? 'active' : ''
kpi?.toString() === item?.id?.toString() ? 'active' : ''
}
onClick={() => {
handleClick(item);
Expand Down
Loading

0 comments on commit bfe7b38

Please sign in to comment.