Skip to content

Comments

Update usage scheduler according to FF#19655

Merged
roboquat merged 10 commits intomainfrom
hw/EXP-1768
Apr 29, 2024
Merged

Update usage scheduler according to FF#19655
roboquat merged 10 commits intomainfrom
hw/EXP-1768

Conversation

@mustard-mh
Copy link
Contributor

@mustard-mh mustard-mh commented Apr 23, 2024

Description

Add FF usage_update_scheduler_duration to control repeat duration of usage data update

Related Issue(s)

Fixes EXP-1768

How to test

  • Create workspace, stop workspace
  • Usage page should show workspace was stopped after you stop it after 1 minute (based on FF setting)
  • Update FF should affect scheduler, after 4 minutes (max: proxy polling 3m + usage polling 1m). You can check usage logs via kubectl logs -f usage-<tab tab> -c usage | code -

You could try run script below in DevTool > Terminal to fetch usage data automatically. Don't forget to update your organization ID in data

const data = {"jsonrpc":"2.0","id":2,"method":"listUsage","params":{"attributionId":"team:d1d0637b-d605-443a-81ef-4631ea08fd92","from":1711900800000,"to":1724060799999,"order":0,"pagination":{"perPage":50,"page":1}}}
const listUsage = () => window._gp.gitpodService.server.listUsage(data.params).then(d => console.log(d))
listUsage()
setInterval(listUsage, 60 * 1000)

Unit tests

Unit tests should pass, see server_test.go, there's a command to exec tests. But tests is flaky because of timing, jobs may exec during each ticker we grab the value. We only need to make sure it can pass one time.

image
✅ Dashboard test result for 2m image

Documentation

Preview status

Gitpod was successfully deployed to your preview environment.

Build Options

Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • /werft preemptible
    Saves cost. Untick this only if you're really sure you need a non-preemtible machine.
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh. If enabled, with-preview and with-large-vm will be enabled.
  • with-monitoring

/hold

@laushinka
Copy link
Contributor

I think we want to keep it to 15 minutes for cloud, but 1 minute for Dedicated. Correct me if I'm wrong @svenefftinge

@mustard-mh mustard-mh marked this pull request as draft April 23, 2024 17:05
@roboquat roboquat removed the size/XS label Apr 23, 2024
@mustard-mh mustard-mh changed the title Update usage data more frequently Update usage scheduler according to FF Apr 23, 2024
{
cacheTime: 1000 * 60 * 10, // 10 minutes
staleTime: 1000 * 60 * 10, // 10 minutes
cacheTime: 1000 * 60 * 1, // 1 minutes
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason data is not updated every 15 minutes is because we have dashboard caches, not sure if we do want to remove caches, 1m should be fine for users

}

spec, err := scheduler.NewResetUsageJob(schedule, jobClientsConstructor)
func startScheduler(ctx context.Context, cfg Config, redsyncPool *redsync.Redsync, jobClientsConstructor scheduler.ClientsConstructor) {
Copy link
Contributor Author

@mustard-mh mustard-mh Apr 24, 2024

Choose a reason for hiding this comment

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

We have to stop scheduler and restart again to update cron. Upstream PR robfig/cron#274 to add update method is there opened for 4 years already 🙈.

@roboquat roboquat added size/XL and removed size/L labels Apr 24, 2024
@mustard-mh mustard-mh marked this pull request as ready for review April 24, 2024 09:48
@mustard-mh
Copy link
Contributor Author

Thank you @svenefftinge , will double check on dogfood

@roboquat roboquat merged commit 9382d33 into main Apr 29, 2024
@roboquat roboquat deleted the hw/EXP-1768 branch April 29, 2024 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants