Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
revert baseline flow ID rename
Browse files Browse the repository at this point in the history
  • Loading branch information
leoporoli committed Sep 12, 2024
1 parent 33acfed commit ee4e0b8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/ci-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
steps:
- name: Git checkout
uses: actions/checkout@v3

- name: Install Nix
uses: cachix/install-nix-action@v27
# relax sandbox due impure kontrol-service tests during build
Expand All @@ -34,10 +34,10 @@ jobs:
uses: DeterminateSystems/magic-nix-cache-action@v7

- name: Build and load kontrol service image
run: |
run: |
docker load < $(nix build ./#kontrol-service-container --no-link --print-out-paths)
- name: Start kontrol service and Postgres
- name: Start kontrol service and Postgres
run: |
docker version
docker compose -f ci/docker-compose.yml up -d
Expand All @@ -47,9 +47,9 @@ jobs:
run: sleep 10s
shell: bash

- name: Install CLI
- name: Install CLI
run: curl get.kardinal.dev -sL | sh

- name: Verify kardinal command
run: bash -c 'source ~/.bashrc; if kardinal | grep -q "Kardinal CLI"; then exit 0; else exit 1; fi'

Expand All @@ -71,8 +71,8 @@ jobs:
if [ "${services}" != "cartservice frontend postgres productcatalogservice" ]; then exit 1; fi
deployments=$(curl http://localhost:8080/tenant/${tenant_id}/cluster-resources | jq -r '.deployments[].metadata.name' | tr " " "\n" | sort -g | tr "\n" " " | xargs)
echo "Deployments: $deployments"
if [ "${deployments}" != "cartservice-baseline frontend-baseline postgres-baseline productcatalogservice-baseline" ]; then exit 1; fi
if [ "${deployments}" != "cartservice-prod frontend-prod postgres-prod productcatalogservice-prod" ]; then exit 1; fi
- name: Validate topology endpoint
run: |
tenant_id=${{ steps.tenant.outputs.id }}
Expand All @@ -87,7 +87,7 @@ jobs:
tenant_id=${{ steps.tenant.outputs.id }}
deployments=$(curl http://localhost:8080/tenant/${tenant_id}/cluster-resources | jq -r '.deployments[].metadata.name' | tr " " "\n" | sort -g | tr "\n" " " | xargs)
echo "Deployments: $deployments"
if [ "${deployments}" != "cartservice-baseline frontend-baseline frontend-${flow_id} postgres-baseline productcatalogservice-baseline" ]; then exit 1; fi
if [ "${deployments}" != "cartservice-prod frontend-${flow_id} frontend-prod postgres-prod productcatalogservice-prod" ]; then exit 1; fi
KARDINAL_CLI_DEV_MODE=TRUE kardinal flow ls | grep ${flow_id}
KARDINAL_CLI_DEV_MODE=TRUE kardinal flow delete ${flow_id}
Expand All @@ -99,10 +99,10 @@ jobs:
tenant_id=${{ steps.tenant.outputs.id }}
deployments=$(curl http://localhost:8080/tenant/${tenant_id}/cluster-resources | jq -r '.deployments[].metadata.name' | tr " " "\n" | sort -g | tr "\n" " " | xargs)
echo "Deployments: $deployments"
if [ "${deployments}" != "cartservice-baseline frontend-baseline frontend-${flow_id} postgres-baseline productcatalogservice-baseline productcatalogservice-${flow_id}" ]; then exit 1; fi
if [ "${deployments}" != "cartservice-prod frontend-${flow_id} frontend-prod postgres-prod productcatalogservice-${flow_id} productcatalogservice-prod" ]; then exit 1; fi
KARDINAL_CLI_DEV_MODE=TRUE kardinal flow ls | grep ${flow_id}
KARDINAL_CLI_DEV_MODE=TRUE kardinal flow delete ${flow_id}
- name: Create template
run: |
KARDINAL_CLI_DEV_MODE=TRUE kardinal template create extra-item-shared --template-yaml ci/template.yaml --description "Extra item and postgres is shared"
Expand All @@ -114,15 +114,15 @@ jobs:
flow_id=$(grep "Flow.*created" kardinal.out | cut -d ' ' -f2 | tr -d "\"")
KARDINAL_CLI_DEV_MODE=TRUE kardinal flow ls | grep ${flow_id}
KARDINAL_CLI_DEV_MODE=TRUE kardinal flow delete ${flow_id}
- name: Delete template
run: |
KARDINAL_CLI_DEV_MODE=TRUE kardinal template delete extra-item-shared
- name: Delete base topology and dev flows
run: |
KARDINAL_CLI_DEV_MODE=TRUE kardinal flow delete baseline
if KARDINAL_CLI_DEV_MODE=TRUE kardinal flow ls | grep baseline; then echo "Topologies not deleted"; exit 1; fi
KARDINAL_CLI_DEV_MODE=TRUE kardinal flow delete prod
if KARDINAL_CLI_DEV_MODE=TRUE kardinal flow ls | grep prod; then echo "Topologies not deleted"; exit 1; fi
tenant_id=${{ steps.tenant.outputs.id }}
deployments=$(curl http://localhost:8080/tenant/${tenant_id}/cluster-resources | jq -r '.deployments[].metadata.name' | tr " " "\n" | sort -g | tr "\n" " " | xargs)
if [ "${deployments}" != "" ]; then echo "Deployments list not empty"; exit 1; fi
21 changes: 9 additions & 12 deletions kontrol-service/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

const (
defaultBaselineFlowId = "baseline"
prodFlowId = "prod"
)

// optional code omitted
Expand Down Expand Up @@ -69,8 +69,7 @@ func (sv *Server) GetTenantUuidFlows(_ context.Context, request api.GetTenantUui
flowHostMapping := finalTopology.GetFlowHostMapping()

resp := lo.MapToSlice(flowHostMapping, func(flowId string, flowUrls []string) apitypes.Flow {
// the baseline flow ID uses the base cluster topology namespace name
isBaselineFlow := flowId == clusterTopology.Namespace
isBaselineFlow := flowId == prodFlowId
return apitypes.Flow{FlowId: flowId, FlowUrls: flowUrls, IsBaseline: &isBaselineFlow}
})
return api.GetTenantUuidFlows200JSONResponse(resp), nil
Expand All @@ -84,10 +83,10 @@ func (sv *Server) PostTenantUuidDeploy(_ context.Context, request api.PostTenant
namespace := *request.Body.Namespace

if namespace == "" {
namespace = defaultBaselineFlowId
namespace = prodFlowId
}

flowId := namespace
flowId := prodFlowId
err, urls := applyProdOnlyFlow(sv, request.Uuid, serviceConfigs, ingressConfigs, namespace, flowId)
if err != nil {
errMsg := fmt.Sprintf("An error occurred deploying flow '%v'", flowId)
Expand All @@ -106,15 +105,14 @@ func (sv *Server) DeleteTenantUuidFlowFlowId(_ context.Context, request api.Dele
logrus.Infof("deleting dev flow for tenant '%s'", request.Uuid)
sv.analyticsWrapper.TrackEvent(EVENT_FLOW_DELETE, request.Uuid)

baseClusterTopology, allFlows, _, _, _, err := getTenantTopologies(sv, request.Uuid)
_, allFlows, _, _, _, err := getTenantTopologies(sv, request.Uuid)
if err != nil {
resourceType := "tenant"
missing := api.NotFoundJSONResponse{ResourceType: resourceType, Id: request.Uuid}
return api.DeleteTenantUuidFlowFlowId404JSONResponse{NotFoundJSONResponse: missing}, nil
}

// the baseline flow ID uses the base cluster topology namespace name
if request.FlowId == baseClusterTopology.Namespace {
if request.FlowId == prodFlowId {
// We received a request to delete the base topology, so we do that + the flows
err = deleteTenantTopologies(sv, request.Uuid)
if err != nil {
Expand Down Expand Up @@ -461,8 +459,7 @@ func applyProdDevFlow(sv *Server, tenantUuidStr string, patches []flow_spec.Serv
}
serviceConfigs = template.ApplyTemplateOverrides(serviceConfigs, templateSpec)

// the baseline flow ID uses the base cluster topology namespace name
baselineFlowID := baseClusterTopologyMaybeWithTemplateOverrides.Namespace
baselineFlowID := prodFlowId

baseClusterTopologyWithTemplateOverridesPtr, err := engine.GenerateProdOnlyCluster(baselineFlowID, serviceConfigs, ingressConfigs, baseTopology.Namespace)
if err != nil {
Expand Down Expand Up @@ -549,8 +546,8 @@ func getTenantTopologies(sv *Server, tenantUuidStr string) (*resolved.ClusterTop
return nil, nil, nil, nil, nil, err
}
} else {
baseClusterTopology.FlowID = defaultBaselineFlowId
baseClusterTopology.Namespace = defaultBaselineFlowId
baseClusterTopology.FlowID = prodFlowId
baseClusterTopology.Namespace = prodFlowId
}

var serviceConfigs []apitypes.ServiceConfig
Expand Down

0 comments on commit ee4e0b8

Please sign in to comment.