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

fix/POD 1050 upgrade existing pro worksapces #1379

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
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)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think it would be nicer to move common functionality to pkg and not have the commands import each other

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 @@ -1216,7 +1216,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
Loading