Skip to content

Commit

Permalink
remove supervisor_live_git_status (#18921)
Browse files Browse the repository at this point in the history
and deprecated instance.status.repo
  • Loading branch information
akosyakov authored Oct 16, 2023
1 parent 81ff3d1 commit cf7d0e9
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 82 deletions.
7 changes: 0 additions & 7 deletions components/common-go/experiments/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,3 @@ func SupervisorPersistServerAPIChannelWhenStart(ctx context.Context, client Clie
func SupervisorUsePublicAPI(ctx context.Context, client Client, attributes Attributes) bool {
return client.GetBoolValue(ctx, SupervisorUsePublicAPIFlag, false, attributes)
}

func SupervisorLiveGitStatus(ctx context.Context, client Client, attributes Attributes) bool {
if client == nil {
return false
}
return client.GetBoolValue(ctx, "supervisor_live_git_status", false, attributes)
}
11 changes: 2 additions & 9 deletions components/dashboard/src/components/PendingChangesDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@
* See License.AGPL.txt in the project root for license information.
*/

import { WorkspaceInstance, WorkspaceInstanceRepoStatus } from "@gitpod/gitpod-protocol";
import { WorkspaceInstance } from "@gitpod/gitpod-protocol";
import ContextMenu, { ContextMenuEntry } from "./ContextMenu";
import CaretDown from "../icons/CaretDown.svg";
import { useFeatureFlag } from "../data/featureflag-query";

export default function PendingChangesDropdown(props: { workspaceInstance?: WorkspaceInstance }) {
const liveGitStatus = useFeatureFlag("supervisor_live_git_status");
let repo: WorkspaceInstanceRepoStatus | undefined;
if (liveGitStatus) {
repo = props.workspaceInstance?.gitStatus;
} else {
repo = props.workspaceInstance?.status?.repo;
}
const repo = props.workspaceInstance?.gitStatus;
const headingStyle = "text-gray-500 dark:text-gray-400 text-left";
const itemStyle = "text-gray-400 dark:text-gray-500 text-left -mt-5";
const menuEntries: ContextMenuEntry[] = [];
Expand Down
1 change: 0 additions & 1 deletion components/dashboard/src/data/featureflag-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const featureFlags = {
doRetryUserLoader: true,
// Local SSH feature of VS Code Desktop Extension
gitpod_desktop_use_local_ssh_proxy: false,
supervisor_live_git_status: false,
enabledOrbitalDiscoveries: "",
newProjectIncrementalRepoSearchBBS: false,
repositoryFinderSearch: false,
Expand Down
17 changes: 2 additions & 15 deletions components/dashboard/src/workspaces/WorkspaceEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
* See License.AGPL.txt in the project root for license information.
*/

import {
CommitContext,
Workspace,
WorkspaceInfo,
ContextURL,
WorkspaceInstanceRepoStatus,
} from "@gitpod/gitpod-protocol";
import { CommitContext, Workspace, WorkspaceInfo, ContextURL } from "@gitpod/gitpod-protocol";
import { GitpodHostUrl } from "@gitpod/gitpod-protocol/lib/util/gitpod-host-url";
import { FunctionComponent, useMemo, useState } from "react";
import { Item, ItemField, ItemFieldIcon } from "../components/ItemsList";
Expand All @@ -19,7 +13,6 @@ import Tooltip from "../components/Tooltip";
import dayjs from "dayjs";
import { WorkspaceEntryOverflowMenu } from "./WorkspaceOverflowMenu";
import { WorkspaceStatusIndicator } from "./WorkspaceStatusIndicator";
import { useFeatureFlag } from "../data/featureflag-query";

type Props = {
info: WorkspaceInfo;
Expand All @@ -29,13 +22,7 @@ type Props = {
export const WorkspaceEntry: FunctionComponent<Props> = ({ info, shortVersion }) => {
const [menuActive, setMenuActive] = useState(false);

const liveGitStatus = useFeatureFlag("supervisor_live_git_status");
let repo: WorkspaceInstanceRepoStatus | undefined;
if (liveGitStatus) {
repo = info.latestInstance?.gitStatus;
} else {
repo = info.latestInstance?.status.repo;
}
const repo = info.latestInstance?.gitStatus;

const workspace = info.workspace;
const currentBranch = repo?.branch || Workspace.getBranchName(info.workspace) || "<unknown>";
Expand Down
1 change: 0 additions & 1 deletion components/gitpod-protocol/go/gitpod-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1835,7 +1835,6 @@ type WorkspaceInstanceStatus struct {
NodeName string `json:"nodeName,omitempty"`
OwnerToken string `json:"ownerToken,omitempty"`
Phase string `json:"phase,omitempty"`
Repo *WorkspaceInstanceRepoStatus `json:"repo,omitempty"`
Timeout string `json:"timeout,omitempty"`
Version int `json:"version,omitempty"`
}
Expand Down
8 changes: 0 additions & 8 deletions components/gitpod-protocol/src/workspace-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ export interface WorkspaceInstanceStatus {
// exposedPorts is the list of currently exposed ports
exposedPorts?: WorkspaceInstancePort[];

/**
* repo contains information about the Git working copy inside the workspace
* @deprecated use WorkspaceInstance.gitStatus instead if supervisor_live_git_status feature flag is enabled
*
* TODO(ak) remove after migration to live git status
*/
repo?: WorkspaceInstanceRepoStatus;

// timeout is a non-default timeout value configured for a workspace
timeout?: string;

Expand Down
23 changes: 6 additions & 17 deletions components/public-api-server/pkg/apiv1/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ func (s *WorkspaceService) StreamWorkspaceStatus(ctx context.Context, req *conne
}

for update := range ch {
liveGitStatus := experiments.SupervisorLiveGitStatus(ctx, s.expClient, experiments.Attributes{
UserID: workspace.Workspace.OwnerID,
})
instance, err := convertWorkspaceInstance(update, workspace.Workspace.Context, workspace.Workspace.Config, workspace.Workspace.Shareable, liveGitStatus)
instance, err := convertWorkspaceInstance(update, workspace.Workspace.Context, workspace.Workspace.Config, workspace.Workspace.Shareable)
if err != nil {
log.Extract(ctx).WithError(err).Error("Failed to convert workspace instance.")
return proxy.ConvertError(err)
Expand Down Expand Up @@ -407,15 +404,12 @@ func getLimitFromPagination(pagination *v1.Pagination) (int, error) {
}

func (s *WorkspaceService) convertWorkspaceInfo(ctx context.Context, input *protocol.WorkspaceInfo) (*v1.Workspace, error) {
liveGitStatus := experiments.SupervisorLiveGitStatus(ctx, s.expClient, experiments.Attributes{
UserID: input.Workspace.OwnerID,
})
return convertWorkspaceInfo(input, liveGitStatus)
return convertWorkspaceInfo(input)
}

// convertWorkspaceInfo converts a "protocol workspace" to a "public API workspace". Returns gRPC errors if things go wrong.
func convertWorkspaceInfo(input *protocol.WorkspaceInfo, liveGitStatus bool) (*v1.Workspace, error) {
instance, err := convertWorkspaceInstance(input.LatestInstance, input.Workspace.Context, input.Workspace.Config, input.Workspace.Shareable, liveGitStatus)
func convertWorkspaceInfo(input *protocol.WorkspaceInfo) (*v1.Workspace, error) {
instance, err := convertWorkspaceInstance(input.LatestInstance, input.Workspace.Context, input.Workspace.Config, input.Workspace.Shareable)
if err != nil {
return nil, err
}
Expand All @@ -440,7 +434,7 @@ func convertWorkspaceInfo(input *protocol.WorkspaceInfo, liveGitStatus bool) (*v
}, nil
}

func convertWorkspaceInstance(wsi *protocol.WorkspaceInstance, wsCtx *protocol.WorkspaceContext, config *protocol.WorkspaceConfig, shareable bool, liveGitStatus bool) (*v1.WorkspaceInstance, error) {
func convertWorkspaceInstance(wsi *protocol.WorkspaceInstance, wsCtx *protocol.WorkspaceContext, config *protocol.WorkspaceConfig, shareable bool) (*v1.WorkspaceInstance, error) {
if wsi == nil {
return nil, nil
}
Expand Down Expand Up @@ -525,12 +519,7 @@ func convertWorkspaceInstance(wsi *protocol.WorkspaceInstance, wsCtx *protocol.W
}
recentFolders = append(recentFolders, filepath.Join("/workspace", location))

var gitStatus *v1.GitStatus
if liveGitStatus {
gitStatus = convertGitStatus(wsi.GitStatus)
} else {
gitStatus = convertGitStatus(wsi.Status.Repo)
}
gitStatus := convertGitStatus(wsi.GitStatus)

return &v1.WorkspaceInstance{
InstanceId: wsi.ID,
Expand Down
4 changes: 2 additions & 2 deletions components/public-api-server/pkg/apiv1/workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ func TestConvertWorkspaceInfo(t *testing.T) {
act Expectation
err error
)
act.Result, err = convertWorkspaceInfo(&test.Input, false)
act.Result, err = convertWorkspaceInfo(&test.Input)
if err != nil {
act.Error = err.Error()
}
Expand All @@ -792,7 +792,7 @@ func FuzzConvertWorkspaceInfo(f *testing.F) {
}

// we really just care for panics
_, _ = convertWorkspaceInfo(&nfo, false)
_, _ = convertWorkspaceInfo(&nfo)
})
}

Expand Down
6 changes: 0 additions & 6 deletions components/supervisor/pkg/supervisor/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,6 @@ func (s *GitStatusService) Run(ctx context.Context, wg *sync.WaitGroup) {
}

func (s *GitStatusService) update(ctx context.Context, updateContext *gitStatusUpdateContext) {
liveGitStatus := experiments.SupervisorLiveGitStatus(ctx, s.experiments, experiments.Attributes{
UserID: s.cfg.OwnerId,
})
if !liveGitStatus {
return
}
status, err := s.git.Status(ctx)
if err != nil {
log.WithError(err).Error("git: error getting status")
Expand Down
16 changes: 0 additions & 16 deletions components/ws-manager-bridge/src/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,22 +269,6 @@ export class WorkspaceManagerBridge implements Disposable {
instance.status.nodeIp = instance.status.nodeIp || status.runtime?.nodeIp;
instance.status.ownerToken = status.auth!.ownerToken;

if (status.repo) {
const r = status.repo;
const undefinedIfEmpty = <T>(l: T[]) => (l.length > 0 ? l : undefined);

instance.status.repo = {
branch: r.branch,
latestCommit: r.latestCommit,
uncommitedFiles: undefinedIfEmpty(r.uncommitedFilesList),
totalUncommitedFiles: r.totalUncommitedFiles,
unpushedCommits: undefinedIfEmpty(r.unpushedCommitsList),
totalUntrackedFiles: r.totalUntrackedFiles,
untrackedFiles: undefinedIfEmpty(r.untrackedFilesList),
totalUnpushedCommits: r.totalUnpushedCommits,
};
}

let lifecycleHandler: (() => Promise<void>) | undefined;
switch (status.phase) {
case WorkspacePhase.PENDING:
Expand Down

0 comments on commit cf7d0e9

Please sign in to comment.