Skip to content

Commit

Permalink
V0.8.0 hotfix (#166)
Browse files Browse the repository at this point in the history
* hotfix for version 0.8.0

- reducing the default refresh time for the PD machines to 15 seconds
- fixed the issue with the documentation
- updated documentation

* further fixes to the refresh of machines in the background

* further fixes to the refresh

* fixes to the automation pipeline
  • Loading branch information
cjlapao authored Jun 10, 2024
1 parent 4bfab69 commit 342d51c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Assign Security Label
if: ${{ contains(github.event.issue.title, 'security')}}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GH_PAT }}
run: |
gh issue edit ${{ github.event.issue.number }} --add-label "security"
assign-security-pr:
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Assign Security Label
if: ${{ github.event.pull_request.draft == false && contains(github.event.pull_request.title, 'security')}}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GH_PAT }}
run: |
gh pr edit ${{ github.event.number }} --add-label "security"
assign-triage-pr:
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
- name: Assign Security Label
if: ${{ github.event.pull_request.draft == false }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GH_PAT }}
run: |
${{ github.event.sender.name }}
${{ github.event.pull_request.author_association }}
Expand Down
8 changes: 0 additions & 8 deletions docs/_includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,4 @@
{%- include google-analytics.html -%}
{%- endif -%}
{%- include head-scripts.html -%}
<h1>Parallels Desktop DevOps Service</h1>
<h2>Architecture</h2>
<h2>CI/CD</h2>
<h2>Orchestrator</h2>
<h2>Provisioning</h2>
<h2>Security</h2>
<h2>virtualization</h2>
<h2>Networking</h2>
</head>
6 changes: 3 additions & 3 deletions docs/docs/getting-started/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ The root object of the configuration file is the environment object, which conta
| ROOT_PASSWORD | The root password that will be used to update the root password of the virtual machine | |
| DATABASE_FOLDER_ENV_VAR | The folder where the database will be stored | /User/Folder/.prl-devops-service |
| DATABASE_NUMBER_BACKUP_FILES | The number of backup files that the database will keep | 10 |
| DATABASE_BACKUP_INTERVAL_MINUTES | The interval in minutes that the database will be backed up | 120 |
| DATABASE_SAVE_INTERVAL_MINUTES | The interval in minutes that the database will be saved | 5 |
| DATABASE_BACKUP_INTERVAL_MINUTES | The interval in minutes that the database will be backed up in minutes | 120 minutes |
| DATABASE_SAVE_INTERVAL_MINUTES | The interval in minutes that the database will be saved in minytes | 5 minutes |
| CATALOG_CACHE_FOLDER | The folder where the catalog cache will be stored | /User/Folder/.prl-devops-service/catalog |
| PARALLELS_DESKTOP_REFRESH_INTERVAL | The interval in seconds that the service will refresh the Parallels Desktop virtual machines | 1 |
| PARALLELS_DESKTOP_REFRESH_INTERVAL | The interval in seconds that the service will refresh the Parallels Desktop virtual machines in seconds | 15 seconds |


### Rest API
Expand Down
4 changes: 2 additions & 2 deletions src/config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,10 @@ func (c *Config) DbSaveInterval() time.Duration {
func (c *Config) ParallelsRefreshInterval() time.Duration {
interval := c.GetIntKey(constants.PARALLELS_DESKTOP_REFRESH_INTERVAL_ENV_VAR)
if interval == 0 {
return 30 * time.Second
return 20 * time.Second
}

return time.Duration(interval) * time.Minute
return time.Duration(interval) * time.Second
}

func (c *Config) RootFolder() (string, error) {
Expand Down
32 changes: 21 additions & 11 deletions src/serviceprovider/parallelsdesktop/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ import (
var (
globalParallelsService *ParallelsService
logger = common.Logger
cachedLocalVms []models.ParallelsVM
)

type ParallelsService struct {
ctx basecontext.ApiContext
refreshStarted bool
cachedLocalVms []models.ParallelsVM
executable string
serverExecutable string
Info *models.ParallelsDesktopInfo
Expand All @@ -47,10 +48,6 @@ type ParallelsService struct {
}

func Get(ctx basecontext.ApiContext) *ParallelsService {
if cachedLocalVms == nil {
cachedLocalVms = make([]models.ParallelsVM, 0)
}

if globalParallelsService != nil {
return globalParallelsService
}
Expand All @@ -59,7 +56,13 @@ func Get(ctx basecontext.ApiContext) *ParallelsService {

func New(ctx basecontext.ApiContext) *ParallelsService {
globalParallelsService = &ParallelsService{
ctx: ctx,
refreshStarted: false,
ctx: ctx,
}

if globalParallelsService.cachedLocalVms == nil {
globalParallelsService.cachedLocalVms = make([]models.ParallelsVM, 0)
globalParallelsService.refreshCacheVms(ctx)
}

if globalParallelsService.FindPath() == "" {
Expand Down Expand Up @@ -275,13 +278,20 @@ func (s *ParallelsService) IsLicensed() bool {
}

func (s *ParallelsService) refreshCacheVms(ctx basecontext.ApiContext) {
if s.refreshStarted {
return
}

go func() {
s.refreshStarted = true
for {
ctx.LogInfof("Waiting %s to refresh VM cache", config.Get().ParallelsRefreshInterval())
time.Sleep(config.Get().ParallelsRefreshInterval())
var err error
if cachedLocalVms, err = s.GetVms(ctx); err != nil {
if s.cachedLocalVms, err = s.GetVms(ctx); err != nil {
ctx.LogErrorf("Error refreshing VM cache: %v", err)
}

ctx.LogInfof("VM cache refreshed")
}
}()
Expand Down Expand Up @@ -317,13 +327,13 @@ func (s *ParallelsService) GetCachedVms(ctx basecontext.ApiContext, filter strin
ctx.LogInfof("Getting all VMs for all users with cache")
var systemMachines []models.ParallelsVM
var err error
if len(cachedLocalVms) > 0 {
systemMachines = cachedLocalVms
if len(s.cachedLocalVms) > 0 {
systemMachines = s.cachedLocalVms
} else {
if systemMachines, err = s.GetVms(ctx); err != nil {
return nil, err
}
cachedLocalVms = systemMachines
s.cachedLocalVms = systemMachines
s.refreshCacheVms(ctx)
}

Expand All @@ -348,7 +358,7 @@ func (s *ParallelsService) GetVmsSync(ctx basecontext.ApiContext, filter string)
return nil, err
}

cachedLocalVms = vms
s.cachedLocalVms = vms
systemMachines = vms

dbFilter, err := data.ParseFilter(filter)
Expand Down

0 comments on commit 342d51c

Please sign in to comment.