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

Custom Docker image not rebuild correctly after merging #19352

Open
2 tasks
JuJup opened this issue Jan 25, 2024 · 15 comments
Open
2 tasks

Custom Docker image not rebuild correctly after merging #19352

JuJup opened this issue Jan 25, 2024 · 15 comments
Labels
team: team-engine type: bug Something isn't working

Comments

@JuJup
Copy link

JuJup commented Jan 25, 2024

Bug description

We have a very strange behavior with our Gitpod Setup using a custom Dockerfile.
We have a main branch A and a feature branch B. In B we're testing some new things so the Dockerfile differs slightly but is mainly equal to A. From time to time, we merge the main branch A into the feature branch B to keep it up to date.
In this case, the Docker Image is rebuild for B, but with the Dockerfile from A.
Sounds confusing? Yes it is :lau

I described the steps using a minimal example to show the problem:

Steps to reproduce

  1. Create a project with these two files (main):
# .gitpod.Dockerfile
FROM gitpod/workspace-base:latest

RUN touch main-branch.info
# .gitpod.yml

image:
  file: .gitpod.Dockerfile
  1. Start a Gitpod workspace for main
    -> ls ~ should show only main-branch.info

  2. Create a Feature Branch (test-branch) and change the Dockerfile to:

# .gitpod.Dockerfile
FROM gitpod/workspace-base:latest

RUN touch main-branch.info

RUN touch test-branch.info
  1. Start a Gitpod workspace for test-branch
    -> ls ~ should show main-branch.info and test-branch.info
    -> So far everything is fine

  2. Make a change to Dockerfile in main:

# .gitpod.Dockerfile
FROM gitpod/workspace-base:latest

RUN touch main-branch-refactored.info
  1. Start a Gitpod workspace for main
    -> ls ~ should show only main-branch-refactored.info

  2. Merge main into test-branch:

  3. Start a Gitpod workspace for test-branch
    -> ls ~ shows main-branch-refactored.info but not test-branch.info ⚠️

That's already confusing, as the code now doesn't represent the state anymore. So I tried rebuilding the image explicitely:

  1. Open https://gitpod.io/#imagebuild/https://gitlab.com/<group>/<project>/-/tree/test-branch
    -> Image is rebuild (you can see the logs, but you can see it's the wrong Dockerfile from main)
    -> ls ~ shows main-branch-refactored.info but not test-branch.info ⚠️

The only thing that helps now is changing some line in the Dockerfile in test-branch. But this can't be the solution honestly.

Workspace affected

No response

Expected behavior

  • When the Dockerfile changes (no matter if directly in the branch or through a merge from main branch), the Image should be rebuild correctly from the branch's Dockerfile
  • When I use https://gitpod.io/#imagebuild/, I expect the rebuild to be base on the branch's Dockerfile

Example repository

No response

Anything else?

No response

@JuJup JuJup added the type: bug Something isn't working label Jan 25, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the meta: stale This issue/PR is stale and will be closed soon label May 23, 2024
@JuJup
Copy link
Author

JuJup commented May 29, 2024

Did anybody had a chance to take a look at that?

@github-actions github-actions bot removed the meta: stale This issue/PR is stale and will be closed soon label May 30, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the meta: stale This issue/PR is stale and will be closed soon label Aug 29, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 9, 2024
@shintonik
Copy link

@JuJup Thanks for bringing up the issue. We are dealing with the same problem.

Every time we merge the main branch into a feature branch it often breaks our Gitpod workspaces which then needs a manual fix. The workaround is basically making a commit with a pseudo change to gitpod.Dockerfile to break the cache and trigger a prebuild. But this is really tedious. We would really appreciate if someone could look into this bug.

Thank in advance.

@axonasif
Copy link
Member

Hi @shintonik, are you using prebuilds?

@shintonik
Copy link

Yes, we use prebuilds.

@JuJup
Copy link
Author

JuJup commented Oct 21, 2024

Hey @axonasif,
can you reopen the issue?

@axonasif axonasif reopened this Oct 21, 2024
@axonasif
Copy link
Member

Hi @JuJup

Done

@axonasif
Copy link
Member

@github-actions github-actions bot removed the meta: stale This issue/PR is stale and will be closed soon label Oct 21, 2024
@JuJup
Copy link
Author

JuJup commented Oct 21, 2024

@axonasif, see step 9. in my Steps to reproduce - at least when I created the ticket that was what surprised me most.

I have an assumption what might be the problem..
When I check the docs it says:

When a workspace is started, Gitpod will search the last 100 ancestor commits for a successful prebuild to use as a base for that workspace.

In relation to my example above:
When main is merged into test-branch (Step 7), and we open a new workspace, Gitpod checks for ancestor commits and finds a prebuild image in the main branch, which is a true ancestor. However, that the Dockerfile in test-branch might differ from main, is not considered at that point.
Not completely sure about this theory, but might be a starting point for further bug analysis?

@axonasif
Copy link
Member

@JuJup, sorry, I missed it.

@JuJup
Copy link
Author

JuJup commented Oct 22, 2024

No worries :)

@filiptronicek
Copy link
Member

Hey there @JuJup 👋, I've tried reproducing according to your steps in https://github.com/filiptronicek/gitpod-test-image-builds and was not able to: when starting a new workspace on my feature branch, I see both feature-branch.info and main-branch-updated.info under /home/gitpod/. To that end, I should note that I handled the merge conflict so that it resulted in the following Dockerfile:

FROM gitpod/workspace-base:latest

RUN touch main-branch-updated.info
RUN touch feature-branch.info

Any ideas on what I'm doing wrong in my approach?

@JuJup
Copy link
Author

JuJup commented Oct 23, 2024

Hey @filiptronicek,
thanks for checking on the issue. I also tried to reproduce things with the given steps, as it's some time ago I wrote it :D
The result was quite surprising. First, the result were equivalent to what I wrote in the reproduction steps when I tried it again in Gitlab, as I did before. So i tried the same on Github as you did - there I have the same behaviour as you (the "desired" behaviour).

Therefore, I assume this might be a platform depending issue?

@filiptronicek
Copy link
Member

@JuJup Therefore, I assume this might be a platform depending issue?

It totally could be. I will try reproducing with GitLab when I find some time. For now, it's helpful to know that it works fine for GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team: team-engine type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants