Skip to content

Commit

Permalink
Merge branch 'main' into fix-unhandled-is-not-found-error
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentaTomas authored Jan 8, 2025
2 parents 6ea98ae + de3decb commit 72af861
Show file tree
Hide file tree
Showing 23 changed files with 372 additions and 40 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ init:
plan:
@ printf "Planning Terraform for env: `tput setaf 2``tput bold`$(ENV)`tput sgr0`\n\n"
terraform fmt -recursive
$(tf_vars) terraform plan -out=.tfplan.$(ENV) -compact-warnings -detailed-exitcode $$(echo $(ALL_MODULES) | tr ' ' '\n' | awk '{print "-target=module." $$0 ""}' | xargs)
$(eval TARGET := $(shell echo $(ALL_MODULES) | tr ' ' '\n' | awk '{print "-target=module." $$0 ""}' | xargs))
$(tf_vars) terraform plan -out=.tfplan.$(ENV) -compact-warnings -detailed-exitcode $(TARGET)

.PHONY: apply
apply:
Expand All @@ -69,13 +70,14 @@ apply:
.PHONY: plan-without-jobs
plan-without-jobs:
@ printf "Planning Terraform for env: `tput setaf 2``tput bold`$(ENV)`tput sgr0`\n\n"
$(eval TARGET := $(shell echo $(ALL_MODULES) | tr ' ' '\n' | grep -v -e "nomad" | awk '{print "-target=module." $$0 ""}' | xargs))
$(tf_vars) \
terraform plan \
-out=.tfplan.$(ENV) \
-input=false \
-compact-warnings \
-parallelism=20 \
$$(echo $(ALL_MODULES) | tr ' ' '\n' | grep -v -e "nomad" | awk '{print "-target=module." $$0 ""}' | xargs)
$(TARGET)

.PHONY: destroy
destroy:
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module "buckets" {
gcp_project_id = var.gcp_project_id
gcp_region = var.gcp_region

fc_template_bucket_name = var.template_bucket_name
fc_template_bucket_name = length(var.template_bucket_name) > 0 ? var.template_bucket_name : "${var.gcp_project_id}-fc-templates"
fc_template_bucket_location = var.template_bucket_location

labels = var.labels
Expand Down
9 changes: 1 addition & 8 deletions packages/envd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,7 @@ start-docker:

build-and-upload:
make build
make upload-local
gcloud compute instance-groups list-instances $(PREFIX)orch-client-ig \
--zone=$(GCP_ZONE) \
--project=$(GCP_PROJECT_ID) \
--format="value(instance)" \
--quiet | xargs -I {} -P 5 sh -c "gcloud compute ssh {} --zone=$(GCP_ZONE) --command='sudo rm -rf /fc-vm/envd && \
sudo cp /mnt/disks/envs-pipeline/envd /fc-vm/envd && sudo chmod +x /fc-vm/envd"
@echo "Uploaded envd to all clients"
make upload

.PHONY: generate
generate:
Expand Down
10 changes: 0 additions & 10 deletions packages/envd/upload-local.sh

This file was deleted.

4 changes: 2 additions & 2 deletions packages/envd/upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

GCP_PROJECT_ID=$1

chmod +x dist/envd_linux_amd64_v1/envd
chmod +x bin/envd

gsutil -h "Cache-Control:no-cache, max-age=0" \
cp dist/envd_linux_amd64_v1/envd "gs://${GCP_PROJECT_ID}-fc-env-pipeline/envd"
cp bin/envd "gs://${GCP_PROJECT_ID}-fc-env-pipeline/envd"
3 changes: 2 additions & 1 deletion packages/nomad/orchestrator.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ job "orchestrator" {
driver = "raw_exec"

resources {
memory = var.memory_mb
memory_max = var.memory_mb
cpu = var.cpu_mhz

}

env {
Expand Down
1 change: 1 addition & 0 deletions packages/nomad/otel-collector.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ processors:
- "nomad_client_host_memory_available"
- "nomad_client_host_memory_total"
- "nomad_client_unallocated_memory"
- "nomad_nomad_job_summary_running"
- "orchestrator.*"
- "api.*"
attributes/session-proxy:
Expand Down
8 changes: 8 additions & 0 deletions packages/shared/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ generate-models:
rm -rf pkg/models/*
go generate ./pkg/generate_models.go

.PHONY: prep-dev-cluster
prep-dev-cluster:
@echo "Seeding database..."
@POSTGRES_CONNECTION_STRING=$(POSTGRES_CONNECTION_STRING) go run ./scripts/seed-db.go
@echo "Building base template..."
@E2B_DOMAIN=$(DOMAIN_NAME) e2b tpl build -p scripts
@echo "Done"

check-atlas:
@if ! command -v atlas >/dev/null 2>&1; then \
echo "Atlas is not installed. Do you want to install it? (Y/n): "; \
Expand Down
27 changes: 27 additions & 0 deletions packages/shared/migrations/20250601142106.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-- Alter "teams" table
ALTER TABLE "public"."teams" DROP COLUMN "is_default";

CREATE OR REPLACE FUNCTION public.post_user_signup()
RETURNS TRIGGER
LANGUAGE plpgsql
AS $post_user_signup$
DECLARE
team_id uuid;
BEGIN
RAISE NOTICE 'Creating default team for user %', NEW.id;
INSERT INTO public.teams(name, tier, email) VALUES (NEW.email, 'base_v1', NEW.email) RETURNING id INTO team_id;
INSERT INTO public.users_teams(user_id, team_id, is_default) VALUES (NEW.id, team_id, true);
RAISE NOTICE 'Created default team for user % and team %', NEW.id, team_id;

-- Generate a random 20 byte string and encode it as hex, so it's 40 characters
INSERT INTO public.team_api_keys (team_id)
VALUES (team_id);

INSERT INTO public.access_tokens (user_id)
VALUES (NEW.id);

PERFORM public.extra_for_post_user_signup(NEW.id, team_id);

RETURN NEW;
END
$post_user_signup$ SECURITY DEFINER SET search_path = public;
1 change: 1 addition & 0 deletions packages/shared/pkg/db/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (db *DB) GetEnvs(ctx context.Context, teamID uuid.UUID) (result []*Template
Where(
env.TeamID(teamID),
env.HasBuildsWith(envbuild.StatusEQ(envbuild.StatusUploaded)),
env.Not(env.HasSnapshots()),
).
Order(models.Asc(env.FieldCreatedAt)).
WithEnvAliases().
Expand Down
10 changes: 10 additions & 0 deletions packages/shared/pkg/models/accesstoken/where.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions packages/shared/pkg/models/accesstoken_create.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/shared/pkg/models/accesstoken_update.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/shared/pkg/models/migrate/schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 61 additions & 1 deletion packages/shared/pkg/models/mutation.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions packages/shared/pkg/models/team/where.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 72af861

Please sign in to comment.