Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not download instance types if cache loadable #1732

Merged
merged 3 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion cmd/incusd/instance_instance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,19 @@ func instanceRefreshTypes(ctx context.Context, s *state.State) error {

// Set an initial value from the cache
if instanceTypes == nil {
_ = instanceLoadCache()
instanceTypes = map[string]map[string]*instanceType{}
}

if len(instanceTypes) == 0 {
err := instanceLoadCache()
if err != nil {
return err
}
}

// Allow disabling instance type download.
if util.IsTrue(os.Getenv("INCUS_SKIP_INSTANCE_TYPES")) {
return nil
}

// Get the list of instance type sources
Expand Down
7 changes: 4 additions & 3 deletions doc/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ Name | Description
Name | Description
:--- | :----
`EDITOR` | What text editor to use
`VISUAL` | What text editor to use (if `EDITOR` isn't set)
`INCUS_CONF` | Path to the client configuration directory
`INCUS_GLOBAL_CONF` | Path to the global client configuration directory
`INCUS_REMOTE` | Name of the remote to use (overrides configured default remote)
`INCUS_PROJECT` | Name of the project to use (overrides configured default project)
`INCUS_REMOTE` | Name of the remote to use (overrides configured default remote)
`VISUAL` | What text editor to use (if `EDITOR` isn't set)

## Server environment variable

Expand All @@ -33,10 +33,11 @@ Name | Description
`INCUS_CLUSTER_UPDATE` | Script to call on a cluster update
`INCUS_DEVMONITOR_DIR` | Path to be monitored by the device monitor. This is primarily for testing
`INCUS_DOCUMENTATION` | Path to the documentation to serve through the web server
`INCUS_EDK2_PATH` | Path to EDK2 firmware build including `*_CODE.fd` and `*_VARS.fd`
`INCUS_EXEC_PATH` | Full path to the Incus binary (used when forking subcommands)
`INCUS_IDMAPPED_MOUNTS_DISABLE` | Disable idmapped mounts support (useful when testing traditional UID shifting)
`INCUS_LXC_TEMPLATE_CONFIG` | Path to the LXC template configuration directory
`INCUS_EDK2_PATH` | Path to EDK2 firmware build including `*_CODE.fd` and `*_VARS.fd`
`INCUS_SECURITY_APPARMOR` | If set to `false`, forces AppArmor off
`INCUS_SKIP_INSTANCE_TYPES` | If set to `true`, skip downloading instance type definitions
`INCUS_UI` | Path to the web UI to serve through the web server
`INCUS_USBIDS_PATH` | Path to the hwdata `usb.ids` file