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

Delete app fails with cherry-pick error #6350

Closed
1 of 2 tasks
tdcox opened this issue Dec 16, 2019 · 8 comments · Fixed by #6479
Closed
1 of 2 tasks

Delete app fails with cherry-pick error #6350

tdcox opened this issue Dec 16, 2019 · 8 comments · Fixed by #6479

Comments

@tdcox
Copy link
Contributor

tdcox commented Dec 16, 2019

Summary

Attempting to delete an App using jx delete app fails under some circumstances due to a cherry pick error.

Steps to reproduce the behavior

➜ jx delete app jx-app-fossa
Attempting to cherry pick commits that were on master but not yet pushed
error: couldn't pull the environment repository from dev: Unable to cherry-pick a155412b72bd8ca8123a8e3b0993a5bd49ca577d: git output: error: commit a155412b72bd8ca8123a8e3b0993a5bd49ca577d is a merge but no -m option was given.
fatal: cherry-pick failed: failed to run 'git cherry-pick a155412b72bd8ca8123a8e3b0993a5bd49ca577d' command in directory '/Users/terry/.jx/environments', output: 'error: commit a155412b72bd8ca8123a8e3b0993a5bd49ca577d is a merge but no -m option was given.
fatal: cherry-pick failed'

Jx version

The output of jx version is:

jx                 2.0.1011
Kubernetes cluster v1.13.11-gke.14
kubectl            v1.16.2
helm client        Client: v2.14.0+g05811b8
git                2.21.0
Operating System   Mac OS X 10.14.6 build 18G1012

Jenkins type

  • Serverless Jenkins X Pipelines (Tekton + Prow)
  • Classic Jenkins
@seanpianka
Copy link

seanpianka commented Dec 17, 2019

Under ~/.jx/environments, there seems to be local changes made to this repository, and the cherry-pick for merging these commits with remote is failing.

Specifically, there's this part of the error message:

failed to run 'git cherry-pick a155412b72bd8ca8123a8e3b0993a5bd49ca577d' command in directory '/Users/terry/.jx/environments', output: 'error: commit a155412b72bd8ca8123a8e3b0993a5bd49ca577d is a merge but no -m option was given.

I'm running into this issue due to untracked directories within ~/.jx/environments.

See these lines under pkg/gits/helpers.go.

@hferentschik
Copy link

Caused by the same issue as #5772

@tdcox
Copy link
Contributor Author

tdcox commented Jan 9, 2020

Looking at the commits referenced in a recent repeat of this problem, it appears that the system is trying to refresh ~/.jx/environments with a commit that is already in ~/.jx/environments/dev and git is refusing to create the ensuing Inception nesting.

@abayer
Copy link
Contributor

abayer commented Jan 9, 2020

Ok, just verified that if you have a fresh boot cluster with gitops enabled and run jx add app ..., it will create ~/.jx/environments (that may already exist, not 100% sure, but if it does, it's empty at this point) and then clone the dev env into ~/.jx/environments/dev. But then if you run jx delete app ... afterwards, it ends up cloning the dev env again into ~/.jx/environments directly - well, technically it runs git init .; git fetch ...; git checkout ... in ~/.jx/environments. Not sure yet if that's specific to running jx delete app ... or would happen for jx add app ... after the first call, and not sure yet why it's happening.

@abayer
Copy link
Contributor

abayer commented Jan 9, 2020

Verified that it is specifically running jx delete app ..., and that it's not an ordering thing. jx delete app ... just does...weird things. Working on it.

abayer added a commit to abayer/jx that referenced this issue Jan 9, 2020
Also adds `--auto-merge` to `jx delete app`

fixes jenkins-x#6350

Signed-off-by: Andrew Bayer <[email protected]>
abayer added a commit to abayer/jx that referenced this issue Jan 9, 2020
Also adds `--auto-merge` to `jx delete app`

fixes jenkins-x#6350

Signed-off-by: Andrew Bayer <[email protected]>
@abayer
Copy link
Contributor

abayer commented Jan 9, 2020

Ah-ha, it's actually the logic behind jx get apps to blame - it's always using ~/.jx/environments and initing/fetching to that directory, and that logic gets called as part of jx delete app.

@abayer
Copy link
Contributor

abayer commented Jan 9, 2020

Actually, why the heck is jx get apps doing a ForkAndPullRepo in the first place?!?

abayer added a commit to abayer/jx that referenced this issue Jan 9, 2020
…te in JX_HOME

Until this, `jx delete app`, `jx add app`, and `jx get apps` all did
weird things with/under `~/.jx/environments`. All of them used
`ForkAndPullRepo` to clone under there - `jx get apps` directly into
`~/.jx/environments`, and `jx add app` and `jx delete app` into
`~/.jx/environments/dev`. Literally none of this made sense. =)

This changes `jx add app` and `jx delete app` to perform more standard
PR creation via `ForkAndPullRepo`, using a temporary directory for the
clone, and changes `jx get apps` to just clone (currently
deleting/recloning each time it's called to make sure nothing has gone
weird with the remotes) into `~/.jx/environments/dev`.

Also adds `--auto-merge` to `jx delete app`

fixes jenkins-x#6350

Signed-off-by: Andrew Bayer <[email protected]>
@abayer
Copy link
Contributor

abayer commented Jan 9, 2020

Sooooo yeah. jx add app and jx delete app use ~/.jx/environments/dev with ForkAndPullRepo, which makes no sense. And jx get apps is using ForkAndPullRepo to clone to ~/.jx/environments but not to create a PR or anything. This is goofy. Reworking.

abayer added a commit to abayer/jx that referenced this issue Jan 9, 2020
…te in JX_HOME

Until this, `jx delete app`, `jx add app`, and `jx get apps` all did
weird things with/under `~/.jx/environments`. All of them used
`ForkAndPullRepo` to clone under there - `jx get apps` directly into
`~/.jx/environments`, and `jx add app` and `jx delete app` into
`~/.jx/environments/dev`. Literally none of this made sense. =)

This changes `jx add app` and `jx delete app` to perform more standard
PR creation via `ForkAndPullRepo`, using a temporary directory for the
clone, and changes `jx get apps` to just clone to a temporary
directory. This all just applies when gitops is enabled.

Also adds `--auto-merge` to `jx delete app`

fixes jenkins-x#6350

Signed-off-by: Andrew Bayer <[email protected]>
abayer added a commit to abayer/jx that referenced this issue Jan 9, 2020
…te in JX_HOME

Until this, `jx delete app`, `jx add app`, and `jx get apps` all did
weird things with/under `~/.jx/environments`. All of them used
`ForkAndPullRepo` to clone under there - `jx get apps` directly into
`~/.jx/environments`, and `jx add app` and `jx delete app` into
`~/.jx/environments/dev`. Literally none of this made sense. =)

This changes `jx add app` and `jx delete app` to perform more standard
PR creation via `ForkAndPullRepo`, using a temporary directory for the
clone, and changes `jx get apps` to just clone to a temporary
directory. This all just applies when gitops is enabled.

Also adds `--auto-merge` to `jx delete app`

fixes jenkins-x#6350

Signed-off-by: Andrew Bayer <[email protected]>
@abayer abayer self-assigned this Jan 9, 2020
@abayer abayer added this to the Sprint 0 2020 milestone Jan 9, 2020
abayer added a commit to abayer/jx that referenced this issue Jan 9, 2020
…te in JX_HOME

Until this, `jx delete app`, `jx add app`, and `jx get apps` all did
weird things with/under `~/.jx/environments`. All of them used
`ForkAndPullRepo` to clone under there - `jx get apps` directly into
`~/.jx/environments`, and `jx add app` and `jx delete app` into
`~/.jx/environments/dev`. Literally none of this made sense. =)

This changes `jx add app` and `jx delete app` to perform more standard
PR creation via `ForkAndPullRepo`, using a temporary directory for the
clone, and changes `jx get apps` to just clone to a temporary
directory. This all just applies when gitops is enabled.

Also adds `--auto-merge` to `jx delete app`

fixes jenkins-x#6350

Signed-off-by: Andrew Bayer <[email protected]>
abayer added a commit to abayer/jx that referenced this issue Jan 10, 2020
…te in JX_HOME

Until this, `jx delete app`, `jx add app`, and `jx get apps` all did
weird things with/under `~/.jx/environments`. All of them used
`ForkAndPullRepo` to clone under there - `jx get apps` directly into
`~/.jx/environments`, and `jx add app` and `jx delete app` into
`~/.jx/environments/dev`. Literally none of this made sense. =)

This changes `jx add app` and `jx delete app` to perform more standard
PR creation via `ForkAndPullRepo`, using a temporary directory for the
clone, and changes `jx get apps` to just clone to a temporary
directory. This all just applies when gitops is enabled.

Also adds `--auto-merge` to `jx delete app`

fixes jenkins-x#6350

Signed-off-by: Andrew Bayer <[email protected]>
abayer added a commit to abayer/jx that referenced this issue Jan 10, 2020
Until this, `jx delete app`, `jx add app`, and `jx get apps` all did
weird things with/under `~/.jx/environments`. All of them used
`ForkAndPullRepo` to clone under there - `jx get apps` directly into
`~/.jx/environments`, and `jx add app` and `jx delete app` into
`~/.jx/environments/dev`. Literally none of this made sense. =)

This reworks not just the app commands, but all commands that create
PRs (i.e., gitops) against the dev/prod/staging environments to use temporary
directories for the fork/clone/push, with the option, just used in
tests, of specifying an existing directory to use instead, while `jx
get apps` just clones to a temporary directory as well.

Switching all this to temporary directories also really helps users
who manage/work with multiple JX clusters from a single
laptop/desktop/host, since namespacing `~/.jx/environments` by cluster
is basically impossible so far as I can tell.

Also adds `--auto-merge` to `jx delete app` because I was here.

fixes jenkins-x#6350

Signed-off-by: Andrew Bayer <[email protected]>
abayer added a commit to abayer/jx that referenced this issue Jan 10, 2020
Until this, `jx delete app`, `jx add app`, and `jx get apps` all did
weird things with/under `~/.jx/environments`. All of them used
`ForkAndPullRepo` to clone under there - `jx get apps` directly into
`~/.jx/environments`, and `jx add app` and `jx delete app` into
`~/.jx/environments/dev`. Literally none of this made sense. =)

This reworks not just the app commands, but all commands that create
PRs (i.e., gitops) against the dev/prod/staging environments to use temporary
directories for the fork/clone/push, with the option, just used in
tests, of specifying an existing directory to use instead, while `jx
get apps` just clones to a temporary directory as well.

Switching all this to temporary directories also really helps users
who manage/work with multiple JX clusters from a single
laptop/desktop/host, since namespacing `~/.jx/environments` by cluster
is basically impossible so far as I can tell.

Also adds `--auto-merge` to `jx delete app` because I was here.

fixes jenkins-x#6350

Signed-off-by: Andrew Bayer <[email protected]>
abayer added a commit to abayer/jx that referenced this issue Jan 13, 2020
Until this, `jx delete app`, `jx add app`, and `jx get apps` all did
weird things with/under `~/.jx/environments`. All of them used
`ForkAndPullRepo` to clone under there - `jx get apps` directly into
`~/.jx/environments`, and `jx add app` and `jx delete app` into
`~/.jx/environments/dev`. Literally none of this made sense. =)

This reworks not just the app commands, but all commands that create
PRs (i.e., gitops) against the dev/prod/staging environments to use temporary
directories for the fork/clone/push, with the option, just used in
tests, of specifying an existing directory to use instead, while `jx
get apps` just clones to a temporary directory as well.

Switching all this to temporary directories also really helps users
who manage/work with multiple JX clusters from a single
laptop/desktop/host, since namespacing `~/.jx/environments` by cluster
is basically impossible so far as I can tell.

Also adds `--auto-merge` to `jx delete app` because I was here.

fixes jenkins-x#6350

Signed-off-by: Andrew Bayer <[email protected]>
jenkins-x-bot pushed a commit that referenced this issue Jan 13, 2020
Until this, `jx delete app`, `jx add app`, and `jx get apps` all did
weird things with/under `~/.jx/environments`. All of them used
`ForkAndPullRepo` to clone under there - `jx get apps` directly into
`~/.jx/environments`, and `jx add app` and `jx delete app` into
`~/.jx/environments/dev`. Literally none of this made sense. =)

This reworks not just the app commands, but all commands that create
PRs (i.e., gitops) against the dev/prod/staging environments to use temporary
directories for the fork/clone/push, with the option, just used in
tests, of specifying an existing directory to use instead, while `jx
get apps` just clones to a temporary directory as well.

Switching all this to temporary directories also really helps users
who manage/work with multiple JX clusters from a single
laptop/desktop/host, since namespacing `~/.jx/environments` by cluster
is basically impossible so far as I can tell.

Also adds `--auto-merge` to `jx delete app` because I was here.

fixes #6350

Signed-off-by: Andrew Bayer <[email protected]>
daveconde pushed a commit to daveconde/jx that referenced this issue Apr 7, 2020
Until this, `jx delete app`, `jx add app`, and `jx get apps` all did
weird things with/under `~/.jx/environments`. All of them used
`ForkAndPullRepo` to clone under there - `jx get apps` directly into
`~/.jx/environments`, and `jx add app` and `jx delete app` into
`~/.jx/environments/dev`. Literally none of this made sense. =)

This reworks not just the app commands, but all commands that create
PRs (i.e., gitops) against the dev/prod/staging environments to use temporary
directories for the fork/clone/push, with the option, just used in
tests, of specifying an existing directory to use instead, while `jx
get apps` just clones to a temporary directory as well.

Switching all this to temporary directories also really helps users
who manage/work with multiple JX clusters from a single
laptop/desktop/host, since namespacing `~/.jx/environments` by cluster
is basically impossible so far as I can tell.

Also adds `--auto-merge` to `jx delete app` because I was here.

fixes jenkins-x#6350

Signed-off-by: Andrew Bayer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants