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

Session Command #134

Open
petersutter opened this issue Mar 9, 2022 · 2 comments
Open

Session Command #134

petersutter opened this issue Mar 9, 2022 · 2 comments
Labels
component/gardenctl Gardener CLI kind/enhancement Enhancement, improvement, extension lifecycle/rotten Nobody worked on this for 12 months (final aging stage)

Comments

@petersutter
Copy link
Member

What would you like to be added:
It should be possible to manage sessions (attach, clone, list, cleanup)

Why is this needed:

@petersutter petersutter added component/gardenctl Gardener CLI kind/enhancement Enhancement, improvement, extension labels Mar 9, 2022
@gardener-robot gardener-robot added the lifecycle/stale Nobody worked on this for 6 months (will further age) label Sep 6, 2022
@tedteng
Copy link
Contributor

tedteng commented Oct 28, 2022

the history command gardenctl target xxxxx generated a history file, after the history PR merge.
proposals extend history command feature load last one entry from the local history file. then create a new alias aaa='eval $(gardenctl xxxx-env zsh)'. This solution is more kind of target session stickiness

usage:

  • if the user wants to session stickiness automatically in new terminal windows then 'eval $(gardenctl xxxx-env zsh)' set in ~/.zshrc, one drawback is normal operation with new terminal windows open will trigger the target feature as well.
  • use alias aaa to attach the last target history in new terminal widows instead of automatically triggering in new terminal windows

in the end, The gardenctl v2 is already multi-session supported in different terminal windows simultaneously. Is the purpose of session management a kind of duplicate with fuzzy search target history?

@petersutter
Copy link
Member Author

A gardenctl session is defined as following:

The state of gardenctl is bound to a shell session and is not shared across windows, tabs or panes. A shell session is defined by the environment variable GCTL_SESSION_ID. If this is not defined, the value of the TERM_SESSION_ID environment variable is used instead. If both are not defined, this leads to an error and gardenctl cannot be executed. The target.yaml and temporary kubeconfig.*.yaml files are store in the following directory ${TMPDIR}/garden/${GCTL_SESSION_ID}.

So "simply" speaking this would mean:

  • Attach to session xyz (with side effects)
    • set GCTL_SESSION_ID to xyz to bind to an existing shell session
    • now you have more than one session with the same session ID. As these sessions point to to the same directory ${TMPDIR}/garden/${GCTL_SESSION_ID}, changes e.g. to the kubeconfig file, like changing the context will affect all sessions with this ID
      To be clarified:
      • should the current target be restored?
      • What about the provider-env or currently running ssh sessions?
  • Clone session xyz (no side effects)
    • copy ${TMPDIR}/garden/${GCTL_SESSION_ID} to new session folder. Attach to newly created session
      To be clarified:
      • should the current target be restored?
      • should the user be able to choose from the target history of that particular session? What about the provider-env, ssh history? target history feature #162 currently only implements a global history
  • List sessions
    • to be able to attach or clone to a session the existing sessions should be printed to the user, ideally with more context information about each session so that the user can easily identity the session
  • Cleanup session(s):
    • there should be a command that basically removes the session folders
    • the idea was that a user could put the following command in his shell rc file gardenctl session clean --after=7d (just an example) to remove sessions that are older than duration x.

I haven't thought about it in detail and there are probably other things to consider

@gardener-robot gardener-robot added lifecycle/rotten Nobody worked on this for 12 months (final aging stage) and removed lifecycle/stale Nobody worked on this for 6 months (will further age) labels Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/gardenctl Gardener CLI kind/enhancement Enhancement, improvement, extension lifecycle/rotten Nobody worked on this for 12 months (final aging stage)
Projects
None yet
Development

No branches or pull requests

3 participants