Skip to content

feat(fga): add openfga backup to bootstrap - #595

Open
NJona wants to merge 3 commits into
mainfrom
jona/openfga-backup-bootstrap
Open

feat(fga): add openfga backup to bootstrap#595
NJona wants to merge 3 commits into
mainfrom
jona/openfga-backup-bootstrap

Conversation

@NJona

@NJona NJona commented Jul 22, 2026

Copy link
Copy Markdown
Member

Stacked PR, only merge after #594.

Adds openfga backup to the bootstrap, so the backup configuration is tested with each PC Installation. Creates a new bucket in gcp in the same project and configures that as backup storage for openfga. On cleanup the bucket is deleted together with the whole project deletion.

@NJona NJona self-assigned this Jul 22, 2026
NJona added a commit that referenced this pull request Aug 3, 2026
Allows to configure openfga backups in the config.yaml.

Thread regarding config schema for that:
https://codesphere-cloud.slack.com/archives/C01Q12KG2Q4/p1784641065573559

Follow up PR adds it to the bootstrap command to test it with each Test
PC Installation:
- #595

Signed-off-by: Jona Neef <Jona.Neef.97@gmail.com>
Base automatically changed from jona/openfga-backup-config to main August 3, 2026 14:01
@NJona
NJona requested a review from NautiluX August 3, 2026 14:04
@NJona
NJona force-pushed the jona/openfga-backup-bootstrap branch from 2f3ccae to 16c2f7d Compare August 3, 2026 15:47

@NautiluX NautiluX left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

literally requesting changes I guess :D

NJona and others added 2 commits August 11, 2026 09:06
Signed-off-by: Jona Neef <Jona.Neef.97@gmail.com>
Signed-off-by: NJona <25478046+NJona@users.noreply.github.com>
@NJona
NJona force-pushed the jona/openfga-backup-bootstrap branch from 634ca0a to 9df21d3 Compare August 11, 2026 07:06
@NJona

NJona commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

literally requesting changes I guess :D

ups, something went wrong with rebase 🤦‍♂️ Fixed now.

@NJona
NJona requested a review from NautiluX August 11, 2026 07:07

@NautiluX NautiluX left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one comment, else looks good :)

Comment on lines +476 to +482
saEmail, _, err := b.GCPClient.CreateServiceAccount(b.Env.ProjectID, openfgaBackupSAName, openfgaBackupSAName)
if err != nil {
return fmt.Errorf("failed to ensure openfga backup service account: %w", err)
}
if err := b.GCPClient.AssignIAMRole(b.Env.ProjectID, openfgaBackupSAName, b.Env.ProjectID, []string{"roles/storage.objectAdmin"}); err != nil {
return fmt.Errorf("failed to assign storage role to openfga backup service account: %w", err)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have a different function creating service accounts. Not saying it's better to have them all in 1 function, but to have it consistently, I think this should move into the same function, or reuse an existing service account if there is no strict requirement to use another one.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the openfga-backup SA creation into EnsureServiceAccounts and its storage.objectAdmin binding into EnsureIAMRoles (using the shared retry helper), so all SAs/roles are provisioned in one place. Kept it as a dedicated SA rather than reusing cloud-controller to avoid granting storage admin to the compute SA. EnsureOpenfgaBackupBucket now just handles the bucket + HMAC key and derives the SA email deterministically.

Move the openfga-backup service account creation into EnsureServiceAccounts
and its storage.objectAdmin role assignment into EnsureIAMRoles (via the
shared retry helper), so all service accounts and roles are provisioned
consistently in one place. EnsureOpenfgaBackupBucket now only ensures the
bucket and HMAC key, reconstructing the SA email deterministically.

Also fix a latent WriteVault/WriteUnencryptedVault mismatch in the backup
config test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Jona Neef <Jona.Neef.97@gmail.com>
@NJona
NJona force-pushed the jona/openfga-backup-bootstrap branch from 91586a0 to 1a9126f Compare August 12, 2026 11:46
@NJona
NJona requested a review from NautiluX August 12, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants