Skip to content

Commit

Permalink
PMM-13132 Changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriCtvrtka committed Sep 19, 2024
1 parent 7986a5b commit 236ade5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
21 changes: 9 additions & 12 deletions .github/workflows/encryption-rotation.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: 'Encryption Rotation Tool'

on:
push:
branches:
Expand All @@ -24,16 +23,22 @@ on:

jobs:
test:
name: Tests
name: Encryption Rotation Test
runs-on: ubuntu-22.04
timeout-minutes: 10

defaults:
run:
working-directory: ${{ github.workspace }}/encryption-rotation

continue-on-error: true

env:
PMM_SERVER_IMAGE: perconalab/pmm-server:3-dev-latest

defaults:
run:
working-directory: ${{ github.workspace }}/encryption-rotation
working-directory: ${{ github.workspace }}/agent

steps:
- name: Check out code
Expand Down Expand Up @@ -75,15 +80,6 @@ jobs:
- name: Run tests
run: go test ./...

- name: Upload coverage results
uses: codecov/codecov-action@v4
with:
file: cover.out
flags: agent
env_vars: MYSQL_IMAGE,MONGO_IMAGE,POSTGRES_IMAGE,PMM_SERVER_IMAGE
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}

- name: Run debug commands on failure
if: ${{ failure() }}
run: |
Expand All @@ -92,3 +88,4 @@ jobs:
echo "--- GO Environment ---"
go env | sort
git status
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
- v[0-9]+.[0-9]+.[0-9]+*

pull_request:
paths-ignore:
- "encryption-rotation/**"

jobs:
check:
Expand Down
12 changes: 6 additions & 6 deletions encryption-rotation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,29 +116,29 @@ func isPMMServerStatus(status string) bool {

func rotateEncryptionKey(db *reform.DB, dbName string) error {
return db.InTransaction(func(tx *reform.TX) error {
logrus.Infof("DB is being decrypted")
logrus.Infof("DB %s is being decrypted", dbName)
err := models.DecryptDB(tx, dbName, models.DefaultAgentEncryptionColumns)
if err != nil {
return err
}
logrus.Infof("DB is successfully decrypted")
logrus.Infof("DB %s is successfully decrypted", dbName)

logrus.Infof("Rotating encryption key")
logrus.Infoln("Rotating encryption key")
err = encryption.RotateEncryptionKey()
if err != nil {
return err
}
logrus.Infof("New encryption key generated")

logrus.Infof("DB is being encrypted")
logrus.Infof("DB %s is being encrypted", dbName)
err = models.EncryptDB(tx, dbName, models.DefaultAgentEncryptionColumns)
if err != nil {
if e := encryption.RestoreOldEncryptionKey(); e != nil {
return errors.Wrap(e, e.Error())
return errors.Wrap(err, e.Error())
}
return err
}
logrus.Infof("DB is successfully encrypted")
logrus.Infof("DB %s is successfully encrypted", dbName)

return nil
})
Expand Down

0 comments on commit 236ade5

Please sign in to comment.