mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
feat(gpu): rework docker GPU for UI performance [EE-4918] (#8518)
This commit is contained in:
parent
769c8372fb
commit
fd916bc8a2
52 changed files with 692 additions and 285 deletions
|
@ -3,11 +3,16 @@ package migrator
|
|||
import (
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
portainer "github.com/portainer/portainer/api"
|
||||
portainerDsErrors "github.com/portainer/portainer/api/dataservices/errors"
|
||||
)
|
||||
|
||||
func (m *Migrator) migrateDBVersionToDB90() error {
|
||||
if err := m.updateUserThemForDB90(); err != nil {
|
||||
if err := m.updateUserThemeForDB90(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := m.updateEnableGpuManagementFeatures(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -39,7 +44,7 @@ func (m *Migrator) updateEdgeStackStatusForDB90() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *Migrator) updateUserThemForDB90() error {
|
||||
func (m *Migrator) updateUserThemeForDB90() error {
|
||||
log.Info().Msg("updating existing user theme settings")
|
||||
|
||||
users, err := m.userService.Users()
|
||||
|
@ -60,3 +65,28 @@ func (m *Migrator) updateUserThemForDB90() error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Migrator) updateEnableGpuManagementFeatures() error {
|
||||
// get all environments
|
||||
environments, err := m.endpointService.Endpoints()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, environment := range environments {
|
||||
if environment.Type == portainer.DockerEnvironment {
|
||||
// set the PostInitMigrations.MigrateGPUs to true on this environment to run the migration only on the 2.18 upgrade
|
||||
environment.PostInitMigrations.MigrateGPUs = true
|
||||
// if there's one or more gpu, set the EnableGpuManagement setting to true
|
||||
gpuList := environment.Gpus
|
||||
if len(gpuList) > 0 {
|
||||
environment.EnableGPUManagement = true
|
||||
}
|
||||
// update the environment
|
||||
if err := m.endpointService.UpdateEndpoint(environment.ID, &environment); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue