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

[supervisor] Persist bash history across workspace restarts PRD-59 #17612

Merged
merged 3 commits into from
May 15, 2023

Conversation

iQQBot
Copy link
Contributor

@iQQBot iQQBot commented May 15, 2023

Description

Related Issue(s)

Relates PRD-59

How to test

  1. start a workspace in your preview environment
  2. execute some command in this workspace
  3. restart this workspace
  4. use up arrow key to check if history still in there

repeat these step in different ide, i.e. Jetbrains, ssh, vscode desktop

Documentation

Preview status

Gitpod was successfully deployed to your preview environment.

Build Options:

  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish Options
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer Options
  • analytics=segment
  • with-dedicated-emulation
  • with-ws-manager-mk2
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated

Preview Environment Options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh

/hold

@iQQBot iQQBot changed the title [supervisor] persistence bash command history [supervisor] persistence bash command history PRD-59 May 15, 2023
@roboquat roboquat added size/S and removed size/XS labels May 15, 2023
@iQQBot iQQBot marked this pull request as ready for review May 15, 2023 09:25
@iQQBot iQQBot requested a review from a team May 15, 2023 09:25
@@ -1006,6 +1006,9 @@ func buildChildProcEnv(cfg *Config, envvars []string, runGP bool) []string {
envs["JAVA_TOOL_OPTIONS"] += fmt.Sprintf(" -Xmx%sm", mem)
}

envs["HISTFILE"] = "/workspace/.gitpod/.bash_history"
Copy link
Member

Choose a reason for hiding this comment

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

maybe check if SHELL is not specified or bash?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's not need, only bash respect this env

I try with zsh, it's just not work

Copy link
Member

@akosyakov akosyakov May 15, 2023

Choose a reason for hiding this comment

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

or maybe we just rename it to .shell_history? not sure

it seems zsh is using the same env var?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or maybe we just rename it to .shell_history? not sure

ok

@@ -1006,6 +1006,9 @@ func buildChildProcEnv(cfg *Config, envvars []string, runGP bool) []string {
envs["JAVA_TOOL_OPTIONS"] += fmt.Sprintf(" -Xmx%sm", mem)
}

envs["HISTFILE"] = "/workspace/.gitpod/.bash_history"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check if this two env already exists?

@akosyakov
Copy link
Member

I'm not sure it is actually fixing PRD-59. It is definitely an improvement, but as far as I remember the original issue was about preserving history for some context, not only workspace. See #9019 (comment) for instance. cc @loujaybee

I think we should merge it though.

@akosyakov
Copy link
Member

@iQQBot fyi prebuilds output is relying on HISTFILE env var: https://github.com/gitpod-io/gitpod/blob/7b75c00dd36d3a6286349379a87bc34703c31a07/components/supervisor/pkg/supervisor/tasks.go#LL413C11-L413C19 please make sure to test that we don't cause regressions in this area 🙏

@iQQBot
Copy link
Contributor Author

iQQBot commented May 15, 2023

@iQQBot fyi prebuilds output is relying on HISTFILE env var: https://github.com/gitpod-io/gitpod/blob/7b75c00dd36d3a6286349379a87bc34703c31a07/components/supervisor/pkg/supervisor/tasks.go#LL413C11-L413C19 please make sure to test that we don't cause regressions in this area 🙏

yeah, but prebuild can overwrite the env, it use XXX=YYY before command, since it priority is highest.

I will double check

@laushinka
Copy link
Contributor

I'm not sure it is actually fixing PRD-59. It is definitely an improvement, but as far as I remember the original issue was about preserving history for some context, not only workspace.

Exactly, so I updated the description to Relates. @loujaybee will update the scope in PRD-59.

💯 that this is definitely an improvement. Thanks for getting on this very quickly, @iQQBot!

@iQQBot
Copy link
Contributor Author

iQQBot commented May 15, 2023

image

checked, prebuild still work

@filiptronicek
Copy link
Member

@iQQBot would a title like "Persist bash history across workspace restarts" work better? Not sure if the title is too important, but just throwing it out there.

@iQQBot iQQBot changed the title [supervisor] persistence bash command history PRD-59 [supervisor] Persist bash history across workspace restarts PRD-59 May 15, 2023
Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

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

I have not tried but look sensible.

please unhold when you are ready

/hold

@iQQBot
Copy link
Contributor Author

iQQBot commented May 15, 2023

/unhold

If something wrong, we can revert this.

@roboquat roboquat merged commit 744eb49 into main May 15, 2023
@roboquat roboquat deleted the pd/bash-history branch May 15, 2023 14:39
@roboquat roboquat added the deployed: IDE IDE change is running in production label May 16, 2023
@roboquat roboquat added the deployed Change is completely running in production label May 16, 2023
@mgenereu mgenereu mentioned this pull request Sep 19, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: IDE IDE change is running in production deployed Change is completely running in production size/S team: IDE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants