Skip to content

Commit

Permalink
fix/POD 1050 upgrade existing pro worksapces (#1379)
Browse files Browse the repository at this point in the history
* chore(ui): hide new providers in open source UI

* chore(ui): remove console.log

* fix(cli): resolve provider options after auto-upgrade in pro
  • Loading branch information
pascalbreuninger authored Nov 13, 2024
1 parent 2da861e commit 3098f52
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
6 changes: 6 additions & 0 deletions cmd/pro/update_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/loft-sh/devpod/cmd/pro/flags"
providercmd "github.com/loft-sh/devpod/cmd/provider"
"github.com/loft-sh/devpod/pkg/config"
"github.com/loft-sh/devpod/pkg/platform"
"github.com/loft-sh/devpod/pkg/workspace"
Expand Down Expand Up @@ -73,5 +74,10 @@ func (cmd *UpdateProviderCmd) Run(ctx context.Context, args []string) error {
return fmt.Errorf("update provider %s: %w", provider.Name, err)
}

err = providercmd.ConfigureProvider(ctx, provider, devPodConfig.DefaultContext, []string{}, false, false, nil, log.Discard)
if err != nil {
return fmt.Errorf("configure provider, please retry with 'devpod provider use %s --reconfigure': %w", provider.Name, err)
}

return nil
}
2 changes: 1 addition & 1 deletion cmd/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ func checkProviderUpdate(devPodConfig *config.Config, proInstance *provider2.Pro
if v1.Compare(v2) == 0 {
return nil
}
log.Infof("New provider version available, attempting to update %s", proInstance.Provider)
log.Infof("New provider version available, attempting to update %s from %s to %s", proInstance.Provider, p.Config.Version, newVersion)

providerSource, err := workspace2.ResolveProviderSource(devPodConfig, proInstance.Provider, log)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions desktop/src/components/Layout/ProSwitcher.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { client } from "@/client"
import { useProInstances, useProviders, useSettings } from "@/contexts"
import { CheckCircle, CircleWithArrow, DevPodProBadge, ExclamationTriangle, Plus } from "@/icons"
import { exists, useLoginProModal, useReLoginProModal } from "@/lib"
import { canHealthCheck, exists, useLoginProModal, useReLoginProModal } from "@/lib"
import { Routes } from "@/routes"
import { TProID, TProInstance, TProInstances, TProviderConfig } from "@/types"
import { useDeleteProviderModal } from "@/views/Providers/useDeleteProviderModal"
Expand Down Expand Up @@ -128,7 +128,7 @@ function ProPopoverContent({

return acc
}
if (!curr.providerConfig.exec?.proxy?.["health"]) {
if (!canHealthCheck(curr.providerConfig)) {
acc.legacyProInstances.push(curr)

return acc
Expand All @@ -148,7 +148,6 @@ function ProPopoverContent({
}
)
}, [proInstances, providers])
// TODO: Filter pro instances by the ones that support health check

return (
<>
Expand Down
6 changes: 5 additions & 1 deletion desktop/src/lib/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TIDE, TLogOutput } from "../types"
import { TIDE, TLogOutput, TProvider } from "../types"
import { ChildProcess } from "@tauri-apps/plugin-shell"
import { Err, Failed, Return } from "./result"
import { TActionObj } from "../contexts"
Expand Down Expand Up @@ -164,3 +164,7 @@ export function deepCopy<T>(obj: T): T | undefined {

return JSON.parse(JSON.stringify(obj))
}

export function canHealthCheck(providerConfig: TProvider["config"]): boolean {
return !!providerConfig?.exec?.proxy?.["health"]
}
1 change: 0 additions & 1 deletion desktop/src/lib/pro/useConnectionStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export function useConnectionStatus(): TConnectionStatus {
queryFn: async () => {
try {
const res = await client.checkHealth()
console.log(res)
let state: TConnectionStatus["state"] = "disconnected"
if (res.err) {
return { state }
Expand Down
4 changes: 2 additions & 2 deletions desktop/src/views/Providers/ListProviders.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, Text, VStack, Wrap, WrapItem } from "@chakra-ui/react"
import { useMemo } from "react"
import { useProviders } from "../../contexts"
import { exists } from "../../lib"
import { canHealthCheck, exists } from "../../lib"
import { TProvider, TProviderID } from "../../types"
import { useSetupProviderModal } from "../Providers/useSetupProviderModal"
import { ProviderCard } from "./ProviderCard"
Expand All @@ -16,7 +16,7 @@ export function ListProviders() {
}

return Object.entries(providers)
.filter(([, details]) => details.state?.initialized)
.filter(([, details]) => details.state?.initialized && !canHealthCheck(details.config))
.map(([id, data]) => {
return { id, data }
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { RECOMMENDED_PROVIDER_SOURCES, SIDEBAR_WIDTH } from "../../../constants"
import { useProvider, useProviders, useWorkspace, useWorkspaces } from "../../../contexts"
import { Plus } from "../../../icons"
import { CommunitySvg, ProviderPlaceholderSvg } from "../../../images"
import { exists, getKeys, isEmpty, useFormErrors } from "../../../lib"
import { canHealthCheck, exists, getKeys, isEmpty, useFormErrors } from "../../../lib"
import { Routes } from "../../../routes"
import { TIDE, TWorkspace, TWorkspaceSourceType } from "../../../types"
import { useIDEs } from "../../../useIDEs"
Expand Down Expand Up @@ -112,7 +112,7 @@ export function CreateWorkspace() {
}

const installed = Object.entries(providers)
.filter(([, p]) => !!p.state?.initialized)
.filter(([, p]) => !!p.state?.initialized && !canHealthCheck(p.config))
.map(([key, value]) => ({ name: key, ...value }))

return {
Expand Down

0 comments on commit 3098f52

Please sign in to comment.