Skip to content

Commit

Permalink
chore: Nuke async migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
tiina303 committed Jan 4, 2024
1 parent 1da03ed commit f224e94
Show file tree
Hide file tree
Showing 99 changed files with 52 additions and 6,350 deletions.
9 changes: 4 additions & 5 deletions .github/actions/run-backend-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,12 @@ runs:
PERSON_ON_EVENTS_V2_ENABLED: ${{ inputs.person-on-events }}
GROUPS_ON_EVENTS_ENABLED: ${{ inputs.person-on-events }}
shell: bash
run: | # async_migrations covered in ci-async-migrations.yml
run: |
pytest ${{
inputs.person-on-events == 'true'
&& './posthog/clickhouse/ ./posthog/hogql/ ./posthog/queries/ ./posthog/api/test/test_insight* ./posthog/api/test/dashboards/test_dashboard.py'
|| 'hogvm posthog'
}} -m "not async_migrations" \
--splits ${{ inputs.concurrency }} --group ${{ inputs.group }} \
}} --splits ${{ inputs.concurrency }} --group ${{ inputs.group }} \
--durations=100 --durations-min=1.0 \
$PYTEST_ARGS
Expand All @@ -168,8 +167,8 @@ runs:
PERSON_ON_EVENTS_V2_ENABLED: ${{ inputs.person-on-events }}
GROUPS_ON_EVENTS_ENABLED: ${{ inputs.person-on-events }}
shell: bash
run: | # async_migrations covered in ci-async-migrations.yml
pytest ${{ inputs.person-on-events == 'true' && 'ee/clickhouse/' || 'ee/' }} -m "not async_migrations" \
run: |
pytest ${{ inputs.person-on-events == 'true' && 'ee/clickhouse/' || 'ee/' }} \
--splits ${{ inputs.concurrency }} --group ${{ inputs.group }} \
--durations=100 --durations-min=1.0 \
$PYTEST_ARGS
Expand Down
63 changes: 0 additions & 63 deletions .github/workflows/ci-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,66 +305,3 @@ jobs:
name: email_renders
path: posthog/tasks/test/__emails__
retention-days: 5

async-migrations:
name: Async migrations tests - ${{ matrix.clickhouse-server-image }}
needs: changes
strategy:
fail-fast: false
matrix:
clickhouse-server-image:
['clickhouse/clickhouse-server:23.6.1.1524', 'clickhouse/clickhouse-server:23.11.2.11-alpine']
if: needs.changes.outputs.backend == 'true'
runs-on: ubuntu-latest
steps:
- name: 'Checkout repo'
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Start stack with Docker Compose
run: |
export CLICKHOUSE_SERVER_IMAGE_VERSION=${{ matrix.clickhouse-server-image }}
docker compose -f docker-compose.dev.yml down
docker compose -f docker-compose.dev.yml up -d
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.10.10
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'
token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }}

- uses: syphar/restore-virtualenv@v1
id: cache-backend-tests
with:
custom_cache_key_element: v2-

- name: Install SAML (python3-saml) dependencies
run: |
sudo apt-get update
sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl
- name: Install python dependencies
if: steps.cache-backend-tests.outputs.cache-hit != 'true'
shell: bash
run: |
python -m pip install -r requirements.txt -r requirements-dev.txt
- name: Add kafka host to /etc/hosts for kafka connectivity
run: sudo echo "127.0.0.1 kafka" | sudo tee -a /etc/hosts

- name: Set up needed files
run: |
mkdir -p frontend/dist
touch frontend/dist/index.html
touch frontend/dist/layout.html
touch frontend/dist/exporter.html
- name: Wait for Clickhouse & Kafka
run: bin/check_kafka_clickhouse_up

- name: Run async migrations tests
run: |
pytest -m "async_migrations"
1 change: 0 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"node@%h"
],
"env": {
"SKIP_ASYNC_MIGRATIONS_SETUP": "0",
"DEBUG": "1",
"BILLING_SERVICE_URL": "https://billing.dev.posthog.dev",
"SKIP_SERVICE_VERSION_REQUIREMENTS": "1"
Expand Down
4 changes: 2 additions & 2 deletions bin/docker-worker-celery
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ FLAGS+=("-n node@%h")
[[ -n "${WEB_CONCURRENCY}" ]] && FLAGS+=" --concurrency $WEB_CONCURRENCY"

echo
echo "SKIP_ASYNC_MIGRATIONS_SETUP=0 celery -A posthog worker ${FLAGS[*]}"
echo "celery -A posthog worker ${FLAGS[*]}"
echo

./bin/migrate-check

SKIP_ASYNC_MIGRATIONS_SETUP=0 celery -A posthog worker ${FLAGS[*]} &
celery -A posthog worker ${FLAGS[*]} &

# Exit if any processes exit, and exit with it's exit code
wait -n
Expand Down
10 changes: 0 additions & 10 deletions bin/migrate
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,4 @@ set -e
python manage.py migrate
python manage.py migrate_clickhouse

# NOTE: we do not apply any non-noop migrations here. Rather these are run
# manually within the UI. See https://posthog.com/docs/runbook/async-migrations
# for details.
python manage.py run_async_migrations --complete-noop-migrations

# NOTE: this check should not fail if a migration isn't complete but within the
# given async migration posthog version range, thus this should not block e.g.
# k8s pod deployments.
python manage.py run_async_migrations --check

python manage.py sync_replicated_schema
1 change: 0 additions & 1 deletion bin/migrate-check
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ set -e
if [ -z "$POSTHOG_SKIP_MIGRATION_CHECKS" ]; then
python manage.py migrate --check
python manage.py migrate_clickhouse --check
python manage.py run_async_migrations --check
fi
2 changes: 1 addition & 1 deletion bin/start-worker
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
trap 'kill $(jobs -p)' EXIT

# start celery worker with heartbeat (-B)
SKIP_ASYNC_MIGRATIONS_SETUP=0 celery -A posthog worker -B --scheduler redbeat.RedBeatScheduler --without-heartbeat --without-gossip --without-mingle -Ofair -n node@%h &
celery -A posthog worker -B --scheduler redbeat.RedBeatScheduler --without-heartbeat --without-gossip --without-mingle -Ofair -n node@%h &

if [[ "$PLUGIN_SERVER_IDLE" != "1" && "$PLUGIN_SERVER_IDLE" != "true" ]]; then
./bin/plugin-server
Expand Down
3 changes: 0 additions & 3 deletions bin/upgrade-hobby
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ rm docker-compose.yml.tmpl

docker-compose pull

echo "Checking if async migrations are up to date"
sudo -E docker-compose run asyncmigrationscheck

echo "Stopping the stack!"
docker-compose stop

Expand Down
10 changes: 0 additions & 10 deletions docker-compose.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,11 @@ services:
command: sh -c "
python manage.py migrate
&& python manage.py migrate_clickhouse
&& python manage.py run_async_migrations
"
restart: 'no'
deploy:
replicas: 0
asyncmigrationscheck:
<<: *worker
command: python manage.py run_async_migrations --check
restart: 'no'
deploy:
replicas: 0
environment:
SKIP_ASYNC_MIGRATIONS_SETUP: 0
# Temporal containers
elasticsearch:
environment:
Expand Down
11 changes: 0 additions & 11 deletions docker-compose.hobby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,6 @@ services:
volumes:
- object_storage:/data

asyncmigrationscheck:
extends:
file: docker-compose.base.yml
service: asyncmigrationscheck
image: $REGISTRY_URL:$POSTHOG_APP_TAG
environment:
SENTRY_DSN: $SENTRY_DSN
SITE_URL: https://$DOMAIN
SECRET_KEY: $POSTHOG_SECRET
SKIP_ASYNC_MIGRATIONS_SETUP: 0

# Temporal containers
temporal:
extends:
Expand Down
3 changes: 0 additions & 3 deletions ee/clickhouse/models/test/test_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,9 +1270,6 @@ def test_breakdown_query_expression_materialised(
expected_without: str,
):
with override_instance_config("GROUPS_ON_EVENTS_ENABLED", True):
from posthog.models.team import util

util.can_enable_actor_on_events = True

materialize(table, breakdown[0], table_column="properties")
actual = get_single_or_multi_property_string_expr(
Expand Down
2 changes: 0 additions & 2 deletions ee/clickhouse/queries/test/test_retention.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,7 @@ def test_groups_aggregating_person_on_events(self):
@also_test_with_materialized_columns(group_properties=[(0, "industry")])
@snapshot_clickhouse_queries
def test_groups_in_period_person_on_events(self):
from posthog.models.team import util

util.can_enable_actor_on_events = True
self._create_groups_and_events()

filter = RetentionFilter(
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/layout/navigation/TopBar/Announcement.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './Announcement.scss'

import { LemonButton, Link } from '@posthog/lemon-ui'
import { Link } from '@posthog/lemon-ui'
import clsx from 'clsx'
import { useActions, useValues } from 'kea'
import { NewFeatureBanner } from 'lib/introductions/NewFeatureBanner'
Expand Down Expand Up @@ -29,11 +29,7 @@ export function Announcement(): JSX.Element | null {
} else if (shownAnnouncementType === AnnouncementType.AttentionRequired) {
message = (
<div>
<strong>Attention required!</strong> Your instance has uncompleted migrations that are required for the
next release.
<LemonButton to="/instance/async_migrations" data-attr="site-banner-async-migrations">
Click here to fix
</LemonButton>
<strong>Attention required!</strong>
</div>
)
} else if (shownAnnouncementType === AnnouncementType.CloudFlag && cloudAnnouncement) {
Expand Down
29 changes: 0 additions & 29 deletions frontend/src/layout/navigation/TopBar/SitePopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
IconOffline,
IconPlus,
IconSettings,
IconUpdate,
} from 'lib/lemon-ui/icons'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonRow } from 'lib/lemon-ui/LemonRow'
Expand Down Expand Up @@ -161,33 +160,6 @@ function SystemStatus(): JSX.Element {
)
}

function AsyncMigrations(): JSX.Element {
const { closeSitePopover } = useActions(navigationLogic)
const { asyncMigrationsOk } = useValues(navigationLogic)

return (
<LemonRow
status={asyncMigrationsOk ? 'success' : 'warning'}
icon={asyncMigrationsOk ? <IconCheckmark /> : <IconUpdate />}
fullWidth
>
<>
<div className="SitePopover__main-info">
{asyncMigrationsOk ? 'Async migrations up-to-date' : 'Pending async migrations'}
</div>
<Link
to={urls.asyncMigrations()}
onClick={closeSitePopover}
className="SitePopover__side-link"
data-attr="async-migrations-status-badge"
>
Manage
</Link>
</>
</LemonRow>
)
}

function InstanceSettings(): JSX.Element | null {
const { closeSitePopover } = useActions(navigationLogic)
const { user } = useValues(userLogic)
Expand Down Expand Up @@ -275,7 +247,6 @@ export function SitePopoverOverlay(): JSX.Element {
{(!(preflight?.cloud || preflight?.demo) || user?.is_staff) && (
<SitePopoverSection title="PostHog instance" className="font-title-3000">
<SystemStatus />
<AsyncMigrations />
<InstanceSettings />
</SitePopoverSection>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { userLogic } from 'scenes/userLogic'

import { initKeaTests } from '~/test/init'

import { navigationLogic } from '../navigationLogic'
import { announcementLogic, AnnouncementType, DEFAULT_CLOUD_ANNOUNCEMENT } from './announcementLogic'

describe('announcementLogic', () => {
Expand All @@ -18,7 +17,7 @@ describe('announcementLogic', () => {
initKeaTests()
logic = announcementLogic()
logic.mount()
await expectLogic(logic).toMount([featureFlagLogic, preflightLogic, userLogic, navigationLogic])
await expectLogic(logic).toMount([featureFlagLogic, preflightLogic, userLogic])
featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.CLOUD_ANNOUNCEMENT], {
[FEATURE_FLAGS.CLOUD_ANNOUNCEMENT]: true,
})
Expand Down
17 changes: 3 additions & 14 deletions frontend/src/layout/navigation/TopBar/announcementLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import posthog from 'posthog-js'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { userLogic } from 'scenes/userLogic'

import { navigationLogic } from '../navigationLogic'
import type { announcementLogicType } from './announcementLogicType'

export enum AnnouncementType {
Expand All @@ -26,16 +25,7 @@ const ShowAttentionRequiredBanner = false
export const announcementLogic = kea<announcementLogicType>([
path(['layout', 'navigation', 'TopBar', 'announcementLogic']),
connect({
values: [
featureFlagLogic,
['featureFlags'],
preflightLogic,
['preflight'],
userLogic,
['user'],
navigationLogic,
['asyncMigrationsOk'],
],
values: [featureFlagLogic, ['featureFlags'], preflightLogic, ['preflight'], userLogic, ['user']],
}),
actions({
hideAnnouncement: (type: AnnouncementType | null) => ({ type }),
Expand Down Expand Up @@ -95,15 +85,14 @@ export const announcementLogic = kea<announcementLogicType>([
},
],
relevantAnnouncementType: [
(s) => [s.cloudAnnouncement, s.preflight, s.user, s.asyncMigrationsOk],
(cloudAnnouncement, preflight, user, asyncMigrationsOk): AnnouncementType | null => {
(s) => [s.cloudAnnouncement, s.preflight, s.user],
(cloudAnnouncement, preflight, user): AnnouncementType | null => {
if (preflight?.demo) {
return AnnouncementType.Demo
} else if (cloudAnnouncement) {
return AnnouncementType.CloudFlag
} else if (
ShowAttentionRequiredBanner &&
!asyncMigrationsOk &&
(user?.is_staff || (user?.organization?.membership_level ?? 0) >= OrganizationMembershipLevel.Admin)
) {
return AnnouncementType.AttentionRequired
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/layout/navigation/navigationLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ export const navigationLogic = kea<navigationLogicType>([
}),
loaders({
navigationStatus: [
{ system_status_ok: true, async_migrations_ok: true } as {
{ system_status_ok: true } as {
system_status_ok: boolean
async_migrations_ok: boolean
},
{
loadNavigationStatus: async () => {
Expand Down Expand Up @@ -137,7 +136,6 @@ export const navigationLogic = kea<navigationLogicType>([
return status.system_status_ok
},
],
asyncMigrationsOk: [(s) => [s.navigationStatus], (status) => status.async_migrations_ok],
projectNoticeVariantWithClosability: [
(s) => [
organizationLogic.selectors.currentOrganization,
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/mocks/fixtures/_instance_status.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
"metric": "Postgres version",
"value": "12.0.9"
},
{
"key": "async_migrations_ok",
"metric": "Async migrations up-to-date",
"value": true
},
{
"key": "clickhouse_alive",
"metric": "Clickhouse database alive",
Expand Down
1 change: 0 additions & 1 deletion frontend/src/scenes/appScenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export const appScenes: Record<Scene, () => any> = {
[Scene.SystemStatus]: () => import('./instance/SystemStatus'),
[Scene.ToolbarLaunch]: () => import('./toolbar-launch/ToolbarLaunch'),
[Scene.Site]: () => import('./sites/Site'),
[Scene.AsyncMigrations]: () => import('./instance/AsyncMigrations/AsyncMigrations'),
[Scene.DeadLetterQueue]: () => import('./instance/DeadLetterQueue/DeadLetterQueue'),
[Scene.PreflightCheck]: () => import('./PreflightCheck/PreflightCheck'),
[Scene.Signup]: () => import('./authentication/signup/SignupContainer'),
Expand Down
Loading

0 comments on commit f224e94

Please sign in to comment.