Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): validate state version with cached state #4074

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
0221a74
fix(ci): correctly use lowered network caps
gustavovalverde Apr 9, 2022
0d9dc12
imp(ci): get state version from local constants.rs
gustavovalverde Apr 9, 2022
3904f61
imp(ci): use the same get name approach
gustavovalverde Apr 9, 2022
9833ef2
fix(ci): use the correct name for state version variable
gustavovalverde Apr 9, 2022
dc765b7
Merge branch 'main' into fix-disk-naming
gustavovalverde Apr 9, 2022
1c214ee
imp(ci)!: use different disk names for cached states
gustavovalverde Apr 9, 2022
a0b2eac
imp(ci): test-stateful-sync no longer depends on regenerate-stateful-…
gustavovalverde Apr 9, 2022
8726eda
feat(ci): validate state version with cached state
gustavovalverde Apr 9, 2022
cbbfaf4
Apply suggestions from code review
gustavovalverde Apr 9, 2022
2d026be
fix(ci): use a better name for network string conversion
gustavovalverde Apr 9, 2022
1ea389b
Merge branch 'fix-disk-naming' of github.com:ZcashFoundation/zebra in…
gustavovalverde Apr 9, 2022
22ba55c
Revert "Apply suggestions from code review"
gustavovalverde Apr 9, 2022
c478b2c
Merge branch 'fix-disk-naming' into feat-state-versioning
gustavovalverde Apr 9, 2022
db9b9e9
fix(ci): just validate versions if constants.rs does not change
gustavovalverde Apr 9, 2022
70d3b9e
fix(ci): add same constants.rs validation to full sync
gustavovalverde Apr 9, 2022
a563abf
fix: do not get log information if sync was skipped
gustavovalverde Apr 9, 2022
fdfc886
Merge branch 'fix-disk-naming' into feat-state-versioning
gustavovalverde Apr 9, 2022
42f0f04
fix(ci): do not lower the variable name
gustavovalverde Apr 10, 2022
ac41ef9
fix(ci): use the same lowering case for network everywhere
gustavovalverde Apr 10, 2022
6a36533
test: more .dockerignore conditions
gustavovalverde Apr 10, 2022
a144423
fix: use the right approach to lower caps
gustavovalverde Apr 10, 2022
4bb1725
Merge branch 'fix-disk-naming' into feat-state-versioning
gustavovalverde Apr 10, 2022
c80c677
remove extra .dockerignore
gustavovalverde Apr 10, 2022
f1ea775
trigger a change for stateful disk regeneration
gustavovalverde Apr 10, 2022
4ebec9d
imp(ci): use `checkpoint` as the disk reference
gustavovalverde Apr 11, 2022
39d0b8b
revert wrong delete
gustavovalverde Apr 11, 2022
4a614af
fix(ci): add INSTANCE_ID and correct logging message
gustavovalverde Apr 11, 2022
0b332ab
imp(ci): add `v` prefix to state version number
gustavovalverde Apr 11, 2022
8f0f469
fix(ci): remove typo from logging message to get the height
gustavovalverde Apr 11, 2022
53876d8
Merge branch 'fix-disk-naming' into feat-state-versioning
gustavovalverde Apr 11, 2022
8f24f0f
fix(ci): use correct comments and conditions for constants.rs changes
gustavovalverde Apr 11, 2022
e8a9e76
Update .github/workflows/test-full-sync.yml
gustavovalverde Apr 11, 2022
2ce729a
fix: use newet `checkpoint` disk reference
gustavovalverde Apr 12, 2022
4ea9e93
test: force a change to validate behavior
gustavovalverde Apr 12, 2022
f9f995b
Merge branch 'feat-state-versioning' of github.com:ZcashFoundation/ze…
gustavovalverde Apr 12, 2022
9e9ca0b
revert force rebuild
gustavovalverde Apr 12, 2022
0e45e4c
Merge branch 'main' into feat-state-versioning
gustavovalverde Apr 12, 2022
2564f50
fix(ci): grep correctly and exit with a message
gustavovalverde Apr 12, 2022
09a865f
Merge branch 'main' into feat-state-versioning
gustavovalverde Apr 14, 2022
3e53ee8
Merge branch 'main' into feat-state-versioning
gustavovalverde Apr 14, 2022
e9896eb
Merge branch 'main' into feat-state-versioning
gustavovalverde Apr 18, 2022
8945e57
fix(ci): compare against main branch
gustavovalverde Apr 19, 2022
43b20ad
fix(ci): just create disk when rebuild files are changed
gustavovalverde Apr 19, 2022
9509782
refactor(ci): use latest disk just on PRs and manual triggers
gustavovalverde Apr 19, 2022
a7c6b0f
fix(ci): avoid cross-contamination between PRs
gustavovalverde Apr 19, 2022
45a0aa7
style(ci): fix shellcheck warnings
gustavovalverde Apr 19, 2022
3372cd3
imp(ci): do not repeat conditions if not needed
gustavovalverde Apr 19, 2022
3d7aec7
docs(ci): improve reasoning behind new disk selection conditions
gustavovalverde Apr 19, 2022
ff4e40c
Merge branch 'main' into feat-state-versioning
mergify[bot] Apr 20, 2022
c47cccb
Merge branch 'main' into feat-state-versioning
gustavovalverde Apr 27, 2022
fa5925d
Merge branch 'main' into feat-state-versioning
gustavovalverde May 2, 2022
1099369
fix merge
gustavovalverde May 2, 2022
a82d3e9
fix(ci): use tip disk for full sync
gustavovalverde May 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
target
**/*.rs.bk
*.db
Dockerfile
.dockerignore
.git
.github
.gitignore
74 changes: 52 additions & 22 deletions .github/workflows/test-full-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,41 @@ jobs:
with:
short-length: 7

- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/[email protected]
with:
workload_identity_provider: 'projects/143793276228/locations/global/workloadIdentityPools/github-actions/providers/github-oidc'
service_account: '[email protected]'
token_format: 'access_token'

# If we have accidentally changed the format, but not changed the version,
# we want to run with the old cached state, so other jobs fails.
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved
- name: Get specific changed files
id: changed-files-specific
uses: tj-actions/[email protected]
with:
files: |
zebra-state/**/constants.rs

# Before executing any further steps, validate the local state and remote version are the same,
# or at least that the local state version is lower than the available cached state version.
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved
#
# This step should only be validated if there are no changes in the files specifified
# in the changed-files-specific step.
- name: Validate constants.rs version vs cached state version
id: validate-state-version
if: ${{ steps.changed-files-specific.outputs.any_changed != 'true' }}
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved
run: |
LOCAL_STATE_VERSION=$(grep -oE "DATABASE_FORMAT_VERSION: .* [0-9]+" $GITHUB_WORKSPACE/zebra-state/src/constants.rs | grep -oE "[0-9]+" | tail -n1)
gustavovalverde marked this conversation as resolved.
Show resolved Hide resolved
echo "LOCAL_STATE_VERSION: $LOCAL_STATE_VERSION"

GCP_STATE_DISK=$(gcloud compute images list --filter="name~zebrad-cache AND name~-tip" --format="value(NAME)" --sort-by=~creationTimestamp --limit=1)
GCP_STATE_VERSION=$("$GCP_STATE_DISK" | grep -oE "v[0-9]+" | grep -oE "[0-9]+")
echo "GCP_STATE_VERSION: $GCP_STATE_VERSION"

if [[ "$LOCAL_STATE_VERSION" -lt "$GCP_STATE_VERSION" ]]; then exit 1; fi

# Automatic tag management and OCI Image Format Specification for labels
- name: Docker meta
id: meta
Expand All @@ -82,14 +117,6 @@ jobs:
id: buildx
uses: docker/setup-buildx-action@v1

- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/[email protected]
with:
workload_identity_provider: 'projects/143793276228/locations/global/workloadIdentityPools/github-actions/providers/github-oidc'
service_account: '[email protected]'
token_format: 'access_token'

- name: Login to Google Artifact Registry
uses: docker/[email protected]
with:
Expand Down Expand Up @@ -137,14 +164,20 @@ jobs:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/[email protected]
with:
persist-credentials: false

- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
with:
short-length: 7

- name: Downcase network name for disks
run: |
echo LOWER_NET_NAME="${{ github.event.inputs.network || env.NETWORK }}" | awk '{print tolower($0)}' >> $GITHUB_ENV
NETWORK_CAPS=${{ github.event.inputs.network || env.NETWORK }}
echo "NETWORK=${NETWORK_CAPS,,}" >> $GITHUB_ENV

# Setup gcloud CLI
- name: Authenticate to Google Cloud
id: auth
Expand Down Expand Up @@ -199,18 +232,6 @@ jobs:

echo "CONTAINER_NAME=$CONTAINER_NAME" >> $GITHUB_ENV

- name: Get state version from logs
run: |
STATE_VERSION=""

while [[ ${STATE_VERSION} == "" ]]; do
STATE_VERSION=$(gcloud logging read --format='value(jsonPayload.MESSAGE)' '(resource.labels.instance_id="${{ env.INSTANCE_ID }}" AND jsonPayload.message=~".+Opened Zebra state cache.+v[0-9]+.+")' | grep -oE "v[0-9]+" || [[ $? == 1 ]] )
echo "STATE_VERSION: $STATE_VERSION"
sleep 10
done

echo "STATE_VERSION=$STATE_VERSION" >> $GITHUB_ENV

- name: Full sync
id: full-sync
run: |
Expand All @@ -231,6 +252,15 @@ jobs:

exit ${EXIT_CODE}

- name: Get state version from constants.rs
run: |
STATE_VERSION=""

LOCAL_STATE_VERSION=$(grep -oE "DATABASE_FORMAT_VERSION: .* [0-9]+" $GITHUB_WORKSPACE/zebra-state/src/constants.rs | grep -oE "[0-9]+" | tail -n1)
echo "STATE_VERSION: $LOCAL_STATE_VERSION"

echo "STATE_VERSION=$LOCAL_STATE_VERSION" >> $GITHUB_ENV

- name: Get sync height from logs
run: |
SYNC_HEIGHT=""
Expand All @@ -247,7 +277,7 @@ jobs:
# Force the image creation as the disk is still attached, even though is not being used by the container
- name: Create image from state disk
run: |
gcloud compute images create zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${{ env.STATE_VERSION }}-${{ env.NETWORK }}-${{ env.SYNC_HEIGHT }} \
gcloud compute images create zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${{ env.STATE_VERSION }}-${{ env.NETWORK }}-${{ env.SYNC_HEIGHT }}-tip \
--force \
--source-disk=full-sync-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
--source-disk-zone=${{ env.ZONE }} \
Expand Down
Loading