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: use specific terminal #3019

Merged
merged 8 commits into from
Sep 6, 2022
Merged

Conversation

jLopezbarb
Copy link
Contributor

Signed-off-by: Javier López Barba javier@okteto.com

Fixes #2592 #2820

Proposed changes

  • Use the same terminal as the one executing the main okteto command

Concerns

Since this is running remote and local I want to make sure it doesn't have any other implications.

I have been testing in Windows on different terminals and it returns the correct user and we don't have the problem of absolute paths anymore.
Captura de pantalla 2022-08-19 125148

I have also tested on Linux machines and there seems to be no problem, but as this is a change that affects one of the main okteto commands I would like to know your opinion regarding this change.

Signed-off-by: Javier López Barba <javier@okteto.com>
@jLopezbarb jLopezbarb requested a review from a team August 19, 2022 10:59
@jLopezbarb jLopezbarb linked an issue Aug 19, 2022 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Aug 19, 2022

Codecov Report

Merging #3019 (a495f5a) into master (09fd1d6) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #3019      +/-   ##
==========================================
- Coverage   32.73%   32.73%   -0.01%     
==========================================
  Files         188      188              
  Lines       19748    19750       +2     
==========================================
  Hits         6465     6465              
- Misses      12518    12520       +2     
  Partials      765      765              
Impacted Files Coverage Δ
cmd/deploy/deploy.go 27.24% <0.00%> (-0.08%) ⬇️
cmd/destroy/destroy.go 42.05% <0.00%> (-0.20%) ⬇️
cmd/manifest/init-v2.go 0.00% <0.00%> (ø)
cmd/up/up.go 10.71% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@AgustinRamiroDiaz
Copy link
Contributor

I guess this is how it should've been from the start, but I'm also concerned if the wrapping around bash -c could have been due to some case we wanted to handle. Do the e2e tests run in different OS? That's something that will add more certainty

Also, I don't know if someone was using this as a kind of a "feature". i.e. using another terminal like fish and then putting bash commands in their okteto.yml to be compatible with the rest of their team. I think this is a rare case though and I'm in favor of the consistency of running the commands in the corresponding terminal.

@jLopezbarb
Copy link
Contributor Author

I guess this is how it should've been from the start, but I'm also concerned if the wrapping around bash -c could have been due to some case we wanted to handle. Do the e2e tests run in different OS? That's something that will add more certainty

The e2e tests run on both Windows and Linux, the tests will catch some errors, but because the cases are common (deploy with helm, kubectl, or stack) I don't think we can get any errors from them.

Also, I don't know if someone was using this as a "feature". i.e. using another terminal like fish and then putting bash commands in their okteto.yml to be compatible with the rest of their team. I think this is a rare case though and I'm in favor of the consistency of running the commands in the corresponding terminal.

I don't think people used it as a feature since it changed both the OS and the working directory from which the command was launched.

@@ -61,7 +61,7 @@ func NewExecutor(output string) *Executor {
// Execute executes the specified command adding `env` to the execution environment
func (e *Executor) Execute(cmdInfo model.DeployCommand, env []string) error {

cmd := exec.Command("bash", "-c", cmdInfo.Command)
cmd := exec.Command(cmdInfo.Command)
Copy link
Member

Choose a reason for hiding this comment

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

This is going to change how commands are executed. Could we set this as a flag, announce deprecation, then do the full switch in a version or two? (Or announce it as a breaking change).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rberrelleza what do you mean by setting this as a flag? the new behavior under the flag? If we do that, we'll be throwing a warning every time a user runs okteto deploy/destroy to use a file flag that is going to be deprecated.

If we set the old behavior under the flag, are we going to release a flag that is already deprecated? I prefer this idea and show the users a way of getting back the old behavior(via flag). We should also track how many people are having errors vs previous versions and see if we are having more errors after this change, WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Setting as default the new behavior could break customers' scripts/pipelines which ideally we should try to avoid unless we announce it as a breaking change and update the versions accordingly.

If I understand correctly one of the issues, does this prevent the okteto deploy command to work on Windows? If so, we might enforce the new behavior just when the OS is windows. I mean, if for those cases it's not working, we won't break anything changing the behavior. For the rest of OS we can include a flag defaulting to the old behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ifbyol The problem is that windows bash runs on an auxiliary operating system, which does not run on the same path or with the same user. Being an auxiliary operating system it does not correctly pair absolute paths.

We can activate it only for Windows, although I would like that there is no difference between different operating systems, since it is more difficult to maintain it.

Copy link
Member

Choose a reason for hiding this comment

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

@jLopezbarb I know, but one of our main goals is stability in the CLI, so a breaking change I don't think is a good option right now.

My point is, if in Windows this was never working as expected, doing this breaking change only for Windows would fix the issue. Now, if this wasn't working properly on some situations, then, maybe we have to rethink it because we could be broken other scenarios

Copy link
Contributor

Choose a reason for hiding this comment

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

What if we add a feature flag to remove the bach -c? In this case we wouldn't do a breaking change and we'd also allow for the "correct" behavior with a flag like --execute-without-bash. We could incentivize the use of this flag and postpone it as the default behavior in some future big release

WDYT @ifbyol @jLopezbarb ?

Signed-off-by: Javier López Barba <javier@okteto.com>
Signed-off-by: Javier López Barba <javier@okteto.com>
Signed-off-by: Javier López Barba <javier@okteto.com>
Copy link
Contributor

@AgustinRamiroDiaz AgustinRamiroDiaz left a comment

Choose a reason for hiding this comment

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

I think this is a sweet spot between usability and backwards compatibility. We have to bear in mind we are adding another flag to the cli, which is something we are keeping an eye on since we are aiming for more stability

Signed-off-by: Javier López Barba <javier@okteto.com>
@jLopezbarb
Copy link
Contributor Author

@RinkiyaKeDad @ralamana I don't like the fact of having a flag with a negative preposition --run-without-bash. Do you think that the flag can be renamed so that this negative term is not used?

@rberrelleza
Copy link
Member

@RinkiyaKeDad @ralamana I don't like the fact of having a flag with a negative preposition --run-without-bash. Do you think that the flag can be renamed so that this negative term is not used?

Agree with Javi. This is a very typical problem when running commands, what do other tools or platforms do?

@rberrelleza
Copy link
Member

I guess this is how it should've been from the start, but I'm also concerned if the wrapping around bash -c could have been due to some case we wanted to handle. Do the e2e tests run in different OS? That's something that will add more certainty

Also, I don't know if someone was using this as a kind of a "feature". i.e. using another terminal like fish and then putting bash commands in their okteto.yml to be compatible with the rest of their team. I think this is a rare case though and I'm in favor of the consistency of running the commands in the corresponding terminal.

This is a very good point. I don't recall why it was added, but we didn't have -c from day 1; it was added to fix error conditions (maybe with env var injection?). Has someone gone through the commit history to see if there are any clues?

@AgustinRamiroDiaz
Copy link
Contributor

@RinkiyaKeDad @ralamana I don't like the fact of having a flag with a negative preposition --run-without-bash. Do you think that the flag can be renamed so that this negative term is not used?

What if we rename the flag --run-with-bash and set the default value to true with Cobra?

@AgustinRamiroDiaz
Copy link
Contributor

@rberrelleza "Has someone gone through the commit history to see if there are any clues?" I've tried a bit and didn't find any clue. I used the vscode extension GitLens which helped find the PR, if anyone is interested in looking for something

@RinkiyaKeDad
Copy link
Member

What if we rename the flag --run-with-bash and set the default value to true with Cobra?

+1 for this suggestion. We could also then simplify the name of the flag to just --bash maybe and make it clear in the help section what it does.

@ifbyol
Copy link
Member

ifbyol commented Aug 31, 2022

@rberrelleza @AgustinRamiroDiaz @jLopezbarb I think that the bash -c came when we created the okteto deploy command and we took the code from the backend installer. That code was there and we moved it here.

In the installer, we always had control on the terminal and platform where the command was being run and we didn't consider that when we moved the code to the CLI.

What if we rename the flag --run-with-bash and set the default value to true with Cobra?

That could work, but it would be also interesting to see how other CLI tools do it

@jLopezbarb
Copy link
Contributor Author

jLopezbarb commented Aug 31, 2022

What if we rename the flag --run-with-bash and set the default value to true with Cobra?

+1 for this suggestion. We could also then simplify the name of the flag to just --bash maybe and make it clear in the help section what it does.

I don't like too much the idea of --bash because the user will have to run okteto deploy --bash=false which is not intuitive on boolean flags. I prefer to use something like okteto deploy --use-same-shell although I don't like the name of that flag.

@rberrelleza "Has someone gone through the commit history to see if there are any clues?" I've tried a bit and didn't find any clue. I used the vscode extension GitLens which helped find the PR, if anyone is interested in looking for something

I can see that the bash -c has been there since the start of the pipeline installer. Although, in the tests that I made it did not give errors I do not think that we can remove it and we have to use a flag to change the behavior.

@AgustinRamiroDiaz
Copy link
Contributor

AgustinRamiroDiaz commented Aug 31, 2022

@jLopezbarb @ifbyol regarding the naming, a common convention is to shorten the wording with expressions like --no-bash (like the classic --no-cache flag). It's really short, but I prefer the long, more explicit name since it's a behavior only a few users will need, so typing it out is not a problem

https://github.com/moby/buildkit/blob/9528036502c589626bfb60600af6ce5ee427f479/cmd/buildctl/build.go#L67

@jLopezbarb
Copy link
Contributor Author

@jLopezbarb @ifbyol regarding the naming, a common convention is to shorten the wording with expressions like --no-bash (like the classic --no-cache flag). It's really short, but I prefer the long, more explicit name since it's a behavior only a few users will need, so typing it out is not a problem

https://github.com/moby/buildkit/blob/9528036502c589626bfb60600af6ce5ee427f479/cmd/buildctl/build.go#L67

+1 to --no-bash! Do we have documented that the commands are executed on a bash terminal? If we have that we can refer to the flag and the information about deploy executing from a bash terminal. If not I'll create it before releasing the new CLI version.
If the question/error keeps popping up, we could include a question on FAQ to guide the users.

@AgustinRamiroDiaz
Copy link
Contributor

AgustinRamiroDiaz commented Aug 31, 2022

Do we have documented that the commands are executed on a bash terminal?

I couldn't find any. I think we should do both:

  • document that commands are executed wrapped around bash -c
  • document the new flag to disable that behavior

Signed-off-by: Javier López Barba <javier@okteto.com>
Signed-off-by: Javier López Barba <javier@okteto.com>
Signed-off-by: Javier López Barba <javier@okteto.com>
@jLopezbarb jLopezbarb merged commit 76e9596 into master Sep 6, 2022
@jLopezbarb jLopezbarb deleted the jlopezbarb/fix-windows-executor branch September 6, 2022 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

okteto deploy doesn't accept absolute paths on windows deploy on Windows uses bash
7 participants