Skip to content

Commit

Permalink
lxd: Add patchRemoveCoreTrustPassword
Browse files Browse the repository at this point in the history
This removes the core.trust_password config setting from
the cluster config.

Signed-off-by: Julian Pelizäus <[email protected]>
  • Loading branch information
roosterfish committed Jun 12, 2024
1 parent 6c5d7aa commit 27e36e9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lxd/patches.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ var patches = []patch{
{name: "storage_set_volume_uuid_v2", stage: patchPostDaemonStorage, run: patchStorageSetVolumeUUIDV2},
{name: "storage_move_custom_iso_block_volumes_v2", stage: patchPostDaemonStorage, run: patchStorageRenameCustomISOBlockVolumesV2},
{name: "storage_unset_invalid_block_settings_v2", stage: patchPostDaemonStorage, run: patchStorageUnsetInvalidBlockSettingsV2},
{name: "config_remove_core_trust_password", stage: patchPreLoadClusterConfig, run: patchRemoveCoreTrustPassword},
}

type patch struct {
Expand Down Expand Up @@ -1431,4 +1432,19 @@ DELETE FROM storage_volumes_config
return err
}

// patchRemoveCoreTrustPassword removes the core.trust_password config key from the cluster.
func patchRemoveCoreTrustPassword(_ string, d *Daemon) error {
s := d.State()
err := s.DB.Cluster.Transaction(s.ShutdownCtx, func(ctx context.Context, tx *db.ClusterTx) error {
return tx.UpdateClusterConfig(map[string]string{
"core.trust_password": "",
})
})
if err != nil {
return fmt.Errorf("Failed to remove core.trust_password config key: %w", err)
}

return nil
}

// Patches end here

0 comments on commit 27e36e9

Please sign in to comment.