2023-02-03 05:05:42 -05:00
|
|
|
name: e2e test upgrade
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
cloudProvider:
|
|
|
|
description: "Which cloud provider to use."
|
|
|
|
type: choice
|
|
|
|
options:
|
|
|
|
- "gcp"
|
|
|
|
- "azure"
|
2023-05-19 07:57:31 -04:00
|
|
|
- "aws"
|
2023-02-03 05:05:42 -05:00
|
|
|
default: "azure"
|
2023-08-10 06:53:40 -04:00
|
|
|
nodeCount:
|
|
|
|
description: "Number of nodes to use in the cluster. Given in format `<control-plane nodes>:<worker nodes>`."
|
|
|
|
default: "3:2"
|
|
|
|
type: string
|
2023-02-03 05:05:42 -05:00
|
|
|
fromVersion:
|
|
|
|
description: CLI version to create a new cluster with. This has to be a released version, e.g., 'v2.1.3'.
|
|
|
|
type: string
|
|
|
|
required: true
|
2023-02-13 07:58:34 -05:00
|
|
|
gitRef:
|
|
|
|
description: Ref to build upgrading CLI on, empty for HEAD.
|
2023-02-03 05:05:42 -05:00
|
|
|
type: string
|
2023-02-13 07:58:34 -05:00
|
|
|
default: "head"
|
2023-02-03 05:05:42 -05:00
|
|
|
required: false
|
|
|
|
toImage:
|
|
|
|
description: Image (shortpath) the cluster is upgraded to, or empty for main/nightly.
|
|
|
|
type: string
|
|
|
|
required: false
|
|
|
|
toKubernetes:
|
|
|
|
description: Kubernetes version to target for the upgrade, empty for target's default version.
|
|
|
|
type: string
|
|
|
|
required: false
|
|
|
|
toMicroservices:
|
|
|
|
description: Microservice version to target for the upgrade, empty for target's default version.
|
|
|
|
type: string
|
|
|
|
required: false
|
2023-04-24 07:18:57 -04:00
|
|
|
simulatedTargetVersion:
|
|
|
|
description: Enter a version to build the CLI with. This can be used to simulate a patch-upgrade.
|
|
|
|
type: string
|
|
|
|
required: false
|
2023-08-10 06:53:40 -04:00
|
|
|
regionZone:
|
|
|
|
description: "Region or zone to create the cluster in. Leave empty for default region/zone."
|
|
|
|
type: string
|
2023-02-03 05:05:42 -05:00
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
cloudProvider:
|
|
|
|
description: "Which cloud provider to use."
|
|
|
|
type: string
|
|
|
|
required: true
|
2023-08-10 06:53:40 -04:00
|
|
|
nodeCount:
|
|
|
|
description: "Number of nodes to use in the cluster. Given in format `<control-plane nodes>:<worker nodes>`."
|
|
|
|
default: "3:2"
|
|
|
|
type: string
|
2023-02-03 05:05:42 -05:00
|
|
|
fromVersion:
|
|
|
|
description: CLI version to create a new cluster with. This has to be a released version, e.g., 'v2.1.3'.
|
|
|
|
type: string
|
|
|
|
required: true
|
2023-02-13 07:58:34 -05:00
|
|
|
gitRef:
|
|
|
|
description: Ref to build upgrading CLI on.
|
2023-02-03 05:05:42 -05:00
|
|
|
type: string
|
2023-02-13 07:58:34 -05:00
|
|
|
default: "head"
|
2023-02-03 05:05:42 -05:00
|
|
|
required: false
|
|
|
|
toImage:
|
|
|
|
description: Image (shortpath) the cluster is upgraded to, or empty for main/nightly.
|
|
|
|
type: string
|
|
|
|
required: false
|
|
|
|
toKubernetes:
|
|
|
|
description: Kubernetes version to target for the upgrade, empty for target's default version.
|
|
|
|
type: string
|
|
|
|
required: false
|
|
|
|
toMicroservices:
|
|
|
|
description: Kubernetes version to target for the upgrade, empty for target's default version.
|
|
|
|
type: string
|
|
|
|
required: false
|
2023-04-24 07:18:57 -04:00
|
|
|
simulatedTargetVersion:
|
|
|
|
description: Enter a version to build the CLI with. This can be used to simulate a patch-upgrade.
|
|
|
|
type: string
|
|
|
|
required: false
|
2023-04-17 11:30:56 -04:00
|
|
|
scheduled:
|
|
|
|
description: Whether this is a scheduled run.
|
|
|
|
type: boolean
|
|
|
|
default: false
|
|
|
|
required: false
|
2023-02-03 05:05:42 -05:00
|
|
|
|
|
|
|
jobs:
|
2023-08-10 06:53:40 -04:00
|
|
|
split-nodeCount:
|
|
|
|
name: Split nodeCount
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
permissions:
|
|
|
|
id-token: write
|
|
|
|
contents: read
|
|
|
|
outputs:
|
|
|
|
workerNodes: ${{ steps.split-nodeCount.outputs.workerNodes }}
|
|
|
|
controlPlaneNodes: ${{ steps.split-nodeCount.outputs.controlPlaneNodes }}
|
|
|
|
steps:
|
|
|
|
- name: Split nodeCount
|
|
|
|
id: split-nodeCount
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
nodeCount="${{ inputs.nodeCount }}"
|
|
|
|
workerNodes="${nodeCount##*:}"
|
|
|
|
controlPlaneNodes="${nodeCount%%:*}"
|
|
|
|
|
|
|
|
if [[ -z "${workerNodes}" ]] || [[ -z "{controlPlaneNodes}" ]]; then
|
|
|
|
echo "Invalid nodeCount input: '${nodeCount}'."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "workerNodes=${workerNodes}" | tee -a "$GITHUB_OUTPUT"
|
|
|
|
echo "controlPlaneNodes=${controlPlaneNodes}" | tee -a "$GITHUB_OUTPUT"
|
|
|
|
|
2023-02-03 05:05:42 -05:00
|
|
|
e2e-upgrade:
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
permissions:
|
|
|
|
id-token: write
|
2023-04-24 05:32:22 -04:00
|
|
|
checks: write
|
2023-02-03 05:05:42 -05:00
|
|
|
contents: read
|
2023-04-24 05:32:22 -04:00
|
|
|
packages: write
|
2023-08-10 06:53:40 -04:00
|
|
|
needs: [split-nodeCount]
|
2023-02-03 05:05:42 -05:00
|
|
|
steps:
|
2023-02-13 07:58:34 -05:00
|
|
|
- name: Checkout
|
|
|
|
if: inputs.gitRef == 'head'
|
2023-10-11 07:49:50 -04:00
|
|
|
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
2023-02-03 05:05:42 -05:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}
|
|
|
|
|
2023-02-13 07:58:34 -05:00
|
|
|
- name: Checkout ref
|
|
|
|
if: inputs.gitRef != 'head'
|
2023-10-11 07:49:50 -04:00
|
|
|
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
2023-02-13 07:58:34 -05:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
ref: ${{ inputs.gitRef }}
|
|
|
|
|
2023-10-04 07:55:38 -04:00
|
|
|
- uses: ./.github/actions/setup_bazel_nix
|
|
|
|
with:
|
2023-11-08 09:27:40 -05:00
|
|
|
useCache: "true"
|
|
|
|
buildBuddyApiKey: ${{ secrets.BUILDBUDDY_ORG_API_KEY }}
|
2023-10-04 07:55:38 -04:00
|
|
|
|
2023-02-03 05:05:42 -05:00
|
|
|
- name: Login to AWS
|
2023-10-26 02:18:37 -04:00
|
|
|
uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a # v4.0.1
|
2023-02-03 05:05:42 -05:00
|
|
|
with:
|
|
|
|
role-to-assume: arn:aws:iam::795746500882:role/GithubConstellationVersionsAPIRead
|
|
|
|
aws-region: eu-central-1
|
|
|
|
|
|
|
|
- name: Find latest nightly image
|
|
|
|
id: find-image
|
|
|
|
if: inputs.toImage == ''
|
|
|
|
uses: ./.github/actions/versionsapi
|
|
|
|
with:
|
|
|
|
command: latest
|
|
|
|
ref: main
|
|
|
|
stream: nightly
|
|
|
|
|
2023-04-24 07:18:57 -04:00
|
|
|
- name: Simulate patch upgrade
|
|
|
|
if: inputs.simulatedTargetVersion != ''
|
|
|
|
run: |
|
|
|
|
echo ${{ inputs.simulatedTargetVersion }} > version.txt
|
|
|
|
|
2023-02-03 05:05:42 -05:00
|
|
|
- name: Create cluster with 'fromVersion' CLI.
|
|
|
|
id: e2e_test
|
|
|
|
uses: ./.github/actions/e2e_test
|
|
|
|
with:
|
2023-08-10 06:53:40 -04:00
|
|
|
workerNodesCount: ${{ needs.split-nodeCount.outputs.workerNodes }}
|
|
|
|
controlNodesCount: ${{ needs.split-nodeCount.outputs.controlPlaneNodes }}
|
2023-02-03 05:05:42 -05:00
|
|
|
cloudProvider: ${{ inputs.cloudProvider }}
|
|
|
|
osImage: ${{ inputs.fromVersion }}
|
|
|
|
isDebugImage: "false"
|
2023-04-13 04:49:45 -04:00
|
|
|
cliVersion: ${{ inputs.fromVersion }}
|
2023-08-10 06:53:40 -04:00
|
|
|
regionZone: ${{ inputs.regionZone }}
|
2023-11-28 04:54:58 -05:00
|
|
|
gcpProject: constellation-e2e
|
2023-11-27 07:04:41 -05:00
|
|
|
gcpClusterCreateServiceAccount: "infrastructure-e2e@constellation-e2e.iam.gserviceaccount.com"
|
|
|
|
gcpIAMCreateServiceAccount: "iam-e2e@constellation-e2e.iam.gserviceaccount.com"
|
2023-09-26 07:17:59 -04:00
|
|
|
test: "upgrade"
|
2023-02-03 05:05:42 -05:00
|
|
|
buildBuddyApiKey: ${{ secrets.BUILDBUDDY_ORG_API_KEY }}
|
2023-04-12 07:24:13 -04:00
|
|
|
azureClusterCreateCredentials: ${{ secrets.AZURE_E2E_CLUSTER_CREDENTIALS }}
|
|
|
|
azureIAMCreateCredentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}
|
2023-04-04 04:16:04 -04:00
|
|
|
registry: ghcr.io
|
|
|
|
githubToken: ${{ secrets.GITHUB_TOKEN }}
|
2023-08-21 02:01:33 -04:00
|
|
|
awsOpenSearchDomain: ${{ secrets.AWS_OPENSEARCH_DOMAIN }}
|
|
|
|
awsOpenSearchUsers: ${{ secrets.AWS_OPENSEARCH_USER }}
|
|
|
|
awsOpenSearchPwd: ${{ secrets.AWS_OPENSEARCH_PWD }}
|
2023-12-15 04:37:29 -05:00
|
|
|
clusterCreation: "cli"
|
2023-02-03 05:05:42 -05:00
|
|
|
|
2023-07-03 09:13:36 -04:00
|
|
|
- name: Build CLI
|
|
|
|
uses: ./.github/actions/build_cli
|
|
|
|
with:
|
|
|
|
enterpriseCLI: true
|
|
|
|
outputPath: "build/constellation"
|
|
|
|
push: true
|
|
|
|
|
2023-07-26 11:29:03 -04:00
|
|
|
- name: Login to GCP (IAM service account)
|
|
|
|
if: inputs.cloudProvider == 'gcp'
|
|
|
|
uses: ./.github/actions/login_gcp
|
|
|
|
with:
|
2023-11-27 07:04:41 -05:00
|
|
|
service_account: "iam-e2e@constellation-e2e.iam.gserviceaccount.com"
|
2023-07-26 11:29:03 -04:00
|
|
|
|
|
|
|
- name: Login to AWS (IAM role)
|
|
|
|
if: inputs.cloudProvider == 'aws'
|
2023-10-26 02:18:37 -04:00
|
|
|
uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a # v4.0.1
|
2023-07-26 11:29:03 -04:00
|
|
|
with:
|
|
|
|
role-to-assume: arn:aws:iam::795746500882:role/GithubActionsE2EIAM
|
|
|
|
aws-region: eu-central-1
|
|
|
|
# extend token expiry to 6 hours to ensure constellation can terminate
|
|
|
|
role-duration-seconds: 21600
|
|
|
|
|
|
|
|
- name: Login to Azure (IAM service principal)
|
|
|
|
if: inputs.cloudProvider == 'azure'
|
|
|
|
uses: ./.github/actions/login_azure
|
|
|
|
with:
|
|
|
|
azure_credentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}
|
2023-09-01 10:15:13 -04:00
|
|
|
|
2023-08-09 04:28:13 -04:00
|
|
|
- name: Migrate config
|
|
|
|
id: constellation-config-migrate
|
|
|
|
run: |
|
|
|
|
./build/constellation config migrate --debug
|
2023-09-01 10:15:13 -04:00
|
|
|
|
2023-07-26 11:29:03 -04:00
|
|
|
- name: Upgrade IAM configuration
|
|
|
|
id: constellation-iam-upgrade
|
|
|
|
uses: ./.github/actions/constellation_iam_upgrade
|
|
|
|
|
|
|
|
- name: Login to GCP (Cluster service account)
|
2023-09-01 10:15:13 -04:00
|
|
|
if: always() && inputs.cloudProvider == 'gcp'
|
2023-07-26 11:29:03 -04:00
|
|
|
uses: ./.github/actions/login_gcp
|
|
|
|
with:
|
2023-11-27 07:04:41 -05:00
|
|
|
service_account: "infrastructure-e2e@constellation-e2e.iam.gserviceaccount.com"
|
2023-07-26 11:29:03 -04:00
|
|
|
|
|
|
|
- name: Login to AWS (Cluster role)
|
2023-09-01 10:15:13 -04:00
|
|
|
if: always() && inputs.cloudProvider == 'aws'
|
2023-10-26 02:18:37 -04:00
|
|
|
uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a # v4.0.1
|
2023-07-26 11:29:03 -04:00
|
|
|
with:
|
|
|
|
role-to-assume: arn:aws:iam::795746500882:role/GithubActionsE2ECluster
|
|
|
|
aws-region: eu-central-1
|
|
|
|
# extend token expiry to 6 hours to ensure constellation can terminate
|
|
|
|
role-duration-seconds: 21600
|
|
|
|
|
|
|
|
- name: Login to Azure (Cluster service principal)
|
2023-09-01 10:15:13 -04:00
|
|
|
if: always() && inputs.cloudProvider == 'azure'
|
2023-07-26 11:29:03 -04:00
|
|
|
uses: ./.github/actions/login_azure
|
|
|
|
with:
|
|
|
|
azure_credentials: ${{ secrets.AZURE_E2E_CLUSTER_CREDENTIALS }}
|
|
|
|
|
2023-02-03 05:05:42 -05:00
|
|
|
- name: Run upgrade test
|
2023-04-13 04:50:51 -04:00
|
|
|
env:
|
|
|
|
KUBECONFIG: ${{ steps.e2e_test.outputs.kubeconfig }}
|
|
|
|
IMAGE: ${{ inputs.toImage && inputs.toImage || steps.find-image.outputs.output }}
|
|
|
|
KUBERNETES: ${{ inputs.toKubernetes }}
|
|
|
|
MICROSERVICES: ${{ inputs.toMicroservices }}
|
2023-08-10 06:53:40 -04:00
|
|
|
WORKERNODES: ${{ needs.split-nodeCount.outputs.workerNodes }}
|
|
|
|
CONTROLNODES: ${{ needs.split-nodeCount.outputs.controlPlaneNodes }}
|
2023-02-03 05:05:42 -05:00
|
|
|
run: |
|
|
|
|
echo "Image target: $IMAGE"
|
|
|
|
echo "K8s target: $KUBERNETES"
|
|
|
|
echo "Microservice target: $MICROSERVICES"
|
|
|
|
|
|
|
|
if [[ -n ${MICROSERVICES} ]]; then
|
2023-04-13 09:58:37 -04:00
|
|
|
MICROSERVICES_FLAG="--target-microservices=$MICROSERVICES"
|
2023-02-03 05:05:42 -05:00
|
|
|
fi
|
|
|
|
if [[ -n ${KUBERNETES} ]]; then
|
2023-04-13 09:58:37 -04:00
|
|
|
KUBERNETES_FLAG="--target-kubernetes=$KUBERNETES"
|
2023-02-03 05:05:42 -05:00
|
|
|
fi
|
|
|
|
|
2023-05-19 09:36:54 -04:00
|
|
|
bazel run //e2e/internal/upgrade:upgrade_test -- --want-worker "$WORKERNODES" --want-control "$CONTROLNODES" --target-image "$IMAGE" "$KUBERNETES_FLAG" "$MICROSERVICES_FLAG"
|
2023-02-03 05:05:42 -05:00
|
|
|
|
|
|
|
- name: Always fetch logs
|
|
|
|
if: always()
|
2023-04-13 04:50:51 -04:00
|
|
|
env:
|
|
|
|
KUBECONFIG: ${{ steps.e2e_test.outputs.kubeconfig }}
|
2023-02-03 05:05:42 -05:00
|
|
|
run: |
|
2023-06-06 09:22:06 -04:00
|
|
|
kubectl logs -n kube-system -l "app.kubernetes.io/name=constellation-operator" --tail=-1 > node-operator.logs
|
2023-02-03 05:05:42 -05:00
|
|
|
kubectl logs -n kube-system -l "app.kubernetes.io/name=node-maintenance-operator" --tail=-1 > node-maintenance-operator.logs
|
|
|
|
kubectl get nodeversions.update.edgeless.systems constellation-version -o yaml > constellation-version.yaml
|
|
|
|
|
|
|
|
- name: Always upload logs
|
|
|
|
if: always()
|
2023-10-11 07:49:50 -04:00
|
|
|
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
|
2023-02-03 05:05:42 -05:00
|
|
|
with:
|
|
|
|
name: upgrade-logs
|
|
|
|
path: |
|
2023-06-06 09:22:06 -04:00
|
|
|
node-operator.logs
|
2023-02-03 05:05:42 -05:00
|
|
|
node-maintenance-operator.logs
|
|
|
|
constellation-version.yaml
|
|
|
|
|
|
|
|
- name: Always terminate cluster
|
|
|
|
if: always()
|
|
|
|
uses: ./.github/actions/constellation_destroy
|
|
|
|
with:
|
|
|
|
kubeconfig: ${{ steps.e2e_test.outputs.kubeconfig }}
|
2023-12-15 04:37:29 -05:00
|
|
|
clusterCreation: "cli"
|
2023-11-14 07:25:52 -05:00
|
|
|
cloudProvider: ${{ inputs.cloudProvider }}
|
|
|
|
azureClusterDeleteCredentials: ${{ secrets.AZURE_E2E_CLUSTER_CREDENTIALS }}
|
2023-11-28 04:54:58 -05:00
|
|
|
gcpClusterDeleteServiceAccount: "infrastructure-e2e@constellation-e2e.iam.gserviceaccount.com"
|
2023-02-03 05:05:42 -05:00
|
|
|
|
2023-04-13 04:49:45 -04:00
|
|
|
- name: Always delete IAM configuration
|
|
|
|
if: always()
|
|
|
|
uses: ./.github/actions/constellation_iam_destroy
|
|
|
|
with:
|
|
|
|
cloudProvider: ${{ inputs.cloudProvider }}
|
|
|
|
azureCredentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}
|
2023-11-27 07:04:41 -05:00
|
|
|
gcpServiceAccount: "iam-e2e@constellation-e2e.iam.gserviceaccount.com"
|
2023-04-12 10:06:26 -04:00
|
|
|
|
|
|
|
- name: Notify about failure
|
2023-04-17 11:30:56 -04:00
|
|
|
if: |
|
|
|
|
failure() &&
|
|
|
|
github.ref == 'refs/heads/main' &&
|
2023-08-14 05:45:04 -04:00
|
|
|
inputs.scheduled
|
2023-04-12 10:06:26 -04:00
|
|
|
continue-on-error: true
|
2023-11-15 02:48:13 -05:00
|
|
|
uses: ./.github/actions/notify_e2e_failure
|
2023-04-12 10:06:26 -04:00
|
|
|
with:
|
|
|
|
projectWriteToken: ${{ secrets.PROJECT_WRITE_TOKEN }}
|
|
|
|
test: "upgrade"
|
|
|
|
provider: ${{ inputs.cloudProvider }}
|