Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

feat(code-server): skip extension if installed #259

Merged
merged 7 commits into from
Jun 17, 2024

Conversation

michaelbrewer
Copy link
Contributor

@michaelbrewer michaelbrewer commented Jun 9, 2024

To aid faster restarts of workspace with extensions already cached, this change will skip if an extension was already installed.

Before change, extensions would be try to be installed, but this operation can be slow, also extensions are not upgraded

Screenshot 2024-06-08 at 11 47 54 PM

After change with use_cached_extensions set, extensions that are already installed are skipped

module "code-server" {
  source                  = "registry.coder.com/modules/code-server/coder"
  version                 = "1.0.15"
  agent_id                = coder_agent.main.id
  order                   = 1
  folder                  = "/home/${local.username}/modules"
  install_prefix          = "/home/${local.username}/.code-server"
  use_cached              = true
  auto_install_extensions = true
  extensions              = [
    "dracula-theme.theme-dracula"
  ]
  use_cached_extensions   = true
  extensions_dir          = "/home/${local.username}/.code-server/extensions"
}
Screenshot 2024-06-10 at 10 34 22 PM

This change only impacts when use_cached_extensions and extensions_dir are set.


Otherwise on restarts, --force is used to ensure existing extensions are upgraded.

Screenshot 2024-06-10 at 10 32 36 PM

Skip if an extension was already installed
@michaelbrewer
Copy link
Contributor Author

@code-asher turns out locally it is fast, it is actually slower when doing an install if it already exists.

@matifali
Copy link
Member

matifali commented Jun 9, 2024

How about using --install-extension --force? This should auto update the extensions to latest versions too.

Skipping altogether will stuck the extensions to the initially installed version and code-server will then prompt to update them after the workspace starts.

@michaelbrewer
Copy link
Contributor Author

How about using --install-extension --force? This should auto update the extensions to latest versions too.

Skipping altogether will stuck the extensions to the initially installed version and code-server will then prompt to update them after the workspace starts.

Currently, i have set a very short lifecycle for workspace, so there are more restarts, so i am looking at all things to speed up start time.

Our problem is slow starts of coder workspaces. I am trying to allow for caching of extensions and skipping over those already installed.

--force would make startups even slower, once you have code-server open, it may still have an update, but at least you can be coding already.

@michaelbrewer
Copy link
Contributor Author

(so far terraform init, terraform plan is also a very slow like 16 secs, so i am looking for time anywhere i can find it)

@michaelbrewer
Copy link
Contributor Author

@matifali if installing extensions was non-blocking (or at least upgrading them) then we get a win win situation :)

See related issue for running some tasks in the background : coder/coder#12448

@code-asher
Copy link
Member

code-asher commented Jun 10, 2024

Weird that it is so slow. I suppose it must be the query to the marketplace that is taking so long?

Any idea if it is faster to install them all at once? code-server --install-extension $ext1 --install-extension $ext2 etc? Maybe it will make a single query to the marketplace and be faster.

If we do proceed with this, should there be another flag to control it? CACHE_EXTENSIONS or something? And then add --force so by default it updates the version.

@michaelbrewer
Copy link
Contributor Author

Weird that it is so slow. I suppose it must be the query to the marketplace that is taking so long?

Any idea if it is faster to install them all at once? code-server --install-extension $ext1 --install-extension $ex2 etc? Maybe it will make a single query to the marketplace and be faster.

If we do proceed with this, should there be another flag to control it? CACHE_EXTENSIONS or something? And then add --force so by default it updates the version.

Oh. I did not know that could be done. Will add that for sure.

@michaelbrewer
Copy link
Contributor Author

Will look at the "CACHE_EXTENSIONS" option (false by default), then use that when skipping. And the "-force" would be the default

@michaelbrewer
Copy link
Contributor Author

michaelbrewer commented Jun 11, 2024

@code-asher have a look. @matifali it seems like the tests are failing again

(never mind restarting the CI fixed it..)

Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

Awesome thank you!

@michaelbrewer michaelbrewer requested a review from code-asher June 16, 2024 06:42
done
return 1
}

# Install each extension...
IFS=',' read -r -a EXTENSIONLIST <<< "$${EXTENSIONS}"
for extension in "$${EXTENSIONLIST[@]}"; do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@code-asher - see example of why I need to escape the $

Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

Awesome!

@code-asher code-asher merged commit 45456ab into coder:main Jun 17, 2024
@michaelbrewer michaelbrewer deleted the feat/skip-already-installed branch June 19, 2024 23:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants