Skip to content

Commit

Permalink
v1.9.7
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyorlando authored Aug 20, 2024
2 parents 284cf68 + 081c6bd commit a0c4210
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 759 deletions.
1 change: 1 addition & 0 deletions .github/workflows/on-pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ jobs:
snyk-security-scan:
name: Snyk security scan
uses: ./.github/workflows/snyk-security-scan.yml
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/on-release-published.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
snyk-security-scan:
name: Snyk security scan
uses: ./.github/workflows/snyk-security-scan.yml
secrets: inherit

build-sign-and-publish-plugin-to-gcom:
name: Build, sign, and publish frontend plugin to grafana.com
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/snyk-security-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,20 @@ jobs:
uses: ./.github/actions/install-frontend-dependencies
- name: Install Snyk
uses: snyk/actions/setup@master
- name: Run Snyk
continue-on-error: true
run: snyk monitor --all-projects --severity-threshold=high
# NOTE: on the snyk monitor and snyk test commands, we are excluding the dev and tools directories
# because we can't install the requirements.txt files of these directories alongside the main engine
# requirements.txt (some conflicting dep versions). If we realllly wanted to test these, we should do it
# as a seperate job and setup a separate Python env w/ just the deps of those projects. Since these projects
# are really just dev/internal scripts we don't really need to worry about them for now
- name: snyk monitor
# https://docs.snyk.io/snyk-cli/commands/monitor
run: snyk monitor --all-projects --severity-threshold=high --exclude=dev,tools
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
- name: snyk test
# https://docs.snyk.io/snyk-cli/commands/test
# yamllint disable rule:line-length
run: snyk test --all-projects --severity-threshold=high --exclude=dev,tools --fail-on=all --show-vulnerable-paths=all
# yamllint enable rule:line-length
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
54 changes: 33 additions & 21 deletions engine/apps/grafana_plugin/tasks/sync_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from apps.grafana_plugin.helpers.gcom import get_active_instance_ids
from apps.user_management.models import Organization
from common.custom_celery_tasks import shared_dedicated_queue_retry_task
from common.utils import task_lock

logger = get_task_logger(__name__)
logger.setLevel(logging.DEBUG)
Expand All @@ -18,25 +19,36 @@


@shared_dedicated_queue_retry_task(autoretry_for=(Exception,), retry_backoff=True, max_retries=0)
def sync_organizations_v2():
organization_qs = Organization.objects.all()
active_instance_ids, is_cloud_configured = get_active_instance_ids()
if is_cloud_configured:
if not active_instance_ids:
logger.warning("Did not find any active instances!")
return
def sync_organizations_v2(org_ids=None):
lock_id = "sync_organizations_v2"
with task_lock(lock_id, "main") as acquired:
if acquired:
if org_ids:
logger.debug(f"Starting with provided {len(org_ids)} org_ids")
organization_qs = Organization.objects.filter(id__in=org_ids)
else:
logger.debug("Starting with all org ids")
organization_qs = Organization.objects.all()
active_instance_ids, is_cloud_configured = get_active_instance_ids()
if is_cloud_configured:
if not active_instance_ids:
logger.warning("Did not find any active instances!")
return
else:
logger.debug(f"Found {len(active_instance_ids)} active instances")
organization_qs = organization_qs.filter(stack_id__in=active_instance_ids)

orgs_per_second = math.ceil(len(organization_qs) / SYNC_PERIOD.seconds)
logger.info(f"Syncing {len(organization_qs)} organizations @ {orgs_per_second} per 1s pause")
for idx, org in enumerate(organization_qs):
client = GrafanaAPIClient(api_url=org.grafana_url, api_token=org.api_token)
_, status = client.sync()
if status["status_code"] != 200:
logger.error(
f"Failed to request sync stack_slug={org.stack_slug} status_code={status['status_code']} url={status['url']} message={status['message']}"
)
if idx % orgs_per_second == 0:
logger.info(f"Sleep 1s after {idx + 1} organizations processed")
sleep(1)
else:
logger.debug(f"Found {len(active_instance_ids)} active instances")
organization_qs = organization_qs.filter(stack_id__in=active_instance_ids)

orgs_per_second = math.ceil(len(organization_qs) / SYNC_PERIOD.seconds)
for idx, org in enumerate(organization_qs):
client = GrafanaAPIClient(api_url=org.grafana_url, api_token=org.api_token)
_, status = client.sync()
if status["status_code"] != 200:
logger.error(
f"Failed to request sync stack_slug={org.stack_slug} status_code={status['status_code']} url={status['url']} message={status['message']}"
)
if idx % orgs_per_second == 0:
logger.info(f"Sleep 1s after {idx + 1} organizations processed")
sleep(1)
logger.info(f"Issuing sync requests already in progress lock_id={lock_id}, check slow outgoing requests")
14 changes: 7 additions & 7 deletions engine/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ humanize==4.10.0
icalendar==5.0.10
lxml==5.2.2
markdown2==2.4.10
opentelemetry-sdk==1.25.0
opentelemetry-api==1.25.0
opentelemetry-exporter-otlp-proto-grpc==1.25.0
opentelemetry-instrumentation-logging==0.46b0
opentelemetry-instrumentation-wsgi==0.46b0
opentelemetry-instrumentation-requests==0.46b0
opentelemetry-instrumentation-django==0.46b0
opentelemetry-sdk==1.26.0
opentelemetry-api==1.26.0
opentelemetry-exporter-otlp-proto-grpc==1.26.0
opentelemetry-instrumentation-logging==0.47b0
opentelemetry-instrumentation-wsgi==0.47b0
opentelemetry-instrumentation-requests==0.47b0
opentelemetry-instrumentation-django==0.47b0
phonenumbers==8.10.0
prometheus_client==0.16.0
psutil==5.9.4
Expand Down
25 changes: 13 additions & 12 deletions engine/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ deprecated==1.2.14
# via
# opentelemetry-api
# opentelemetry-exporter-otlp-proto-grpc
# opentelemetry-semantic-conventions
django==4.2.15
# via
# -r requirements.in
Expand Down Expand Up @@ -264,7 +265,7 @@ oauthlib==3.2.2
# via
# requests-oauthlib
# social-auth-core
opentelemetry-api==1.25.0
opentelemetry-api==1.26.0
# via
# -r requirements.in
# opentelemetry-exporter-otlp-proto-grpc
Expand All @@ -275,41 +276,41 @@ opentelemetry-api==1.25.0
# opentelemetry-instrumentation-wsgi
# opentelemetry-sdk
# opentelemetry-semantic-conventions
opentelemetry-exporter-otlp-proto-common==1.25.0
opentelemetry-exporter-otlp-proto-common==1.26.0
# via opentelemetry-exporter-otlp-proto-grpc
opentelemetry-exporter-otlp-proto-grpc==1.25.0
opentelemetry-exporter-otlp-proto-grpc==1.26.0
# via -r requirements.in
opentelemetry-instrumentation==0.46b0
opentelemetry-instrumentation==0.47b0
# via
# opentelemetry-instrumentation-django
# opentelemetry-instrumentation-logging
# opentelemetry-instrumentation-requests
# opentelemetry-instrumentation-wsgi
opentelemetry-instrumentation-django==0.46b0
opentelemetry-instrumentation-django==0.47b0
# via -r requirements.in
opentelemetry-instrumentation-logging==0.46b0
opentelemetry-instrumentation-logging==0.47b0
# via -r requirements.in
opentelemetry-instrumentation-requests==0.46b0
opentelemetry-instrumentation-requests==0.47b0
# via -r requirements.in
opentelemetry-instrumentation-wsgi==0.46b0
opentelemetry-instrumentation-wsgi==0.47b0
# via
# -r requirements.in
# opentelemetry-instrumentation-django
opentelemetry-proto==1.25.0
opentelemetry-proto==1.26.0
# via
# opentelemetry-exporter-otlp-proto-common
# opentelemetry-exporter-otlp-proto-grpc
opentelemetry-sdk==1.25.0
opentelemetry-sdk==1.26.0
# via
# -r requirements.in
# opentelemetry-exporter-otlp-proto-grpc
opentelemetry-semantic-conventions==0.46b0
opentelemetry-semantic-conventions==0.47b0
# via
# opentelemetry-instrumentation-django
# opentelemetry-instrumentation-requests
# opentelemetry-instrumentation-wsgi
# opentelemetry-sdk
opentelemetry-util-http==0.46b0
opentelemetry-util-http==0.47b0
# via
# opentelemetry-instrumentation-django
# opentelemetry-instrumentation-requests
Expand Down
5 changes: 3 additions & 2 deletions grafana-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,14 @@
"react-string-replace": "^0.4.4",
"react-transition-group": "^4.4.5",
"react-use": "^17.4.0",
"stylelint": "^13.13.1",
"stylelint": "^14.0.0",
"stylelint-config-standard": "^22.0.0",
"throttle-debounce": "^2.1.0",
"tinycolor2": "^1.6.0",
"tslib": "2.5.3"
},
"resolutions": {
"braces": "3.0.3"
"braces": "3.0.3",
"micromatch": "4.0.6"
}
}
Loading

0 comments on commit a0c4210

Please sign in to comment.