Skip to content

Don't build images on deploy command if the calculation of images to build is an empty list #4739

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

Merged
merged 2 commits into from
Jul 10, 2025

Conversation

ifbyol
Copy link
Member

@ifbyol ifbyol commented Jul 9, 2025

Proposed changes

On deploy command, we are calculating which images have to be built. It might happen that there are not images to build e.g. no build section defined, or deploying just a subset of services from a compose with using public images. In that case, internal logic within the build function was considering that all the images had to be built. In most of the cases that wouldn't generate issues, but in other cases it would generate unnecessary builds.

For example, having a compose file like this:

services:
  foo:
    image: nginx
    volumes:
    - ./foo:/data
  bar:
    image: nginx
  baz:
    image: nginx

and the following okteto manifest:

deploy:
  compose:
    file: file.yml
    services: [bar, baz]

The Okteto manifest is considering to deploy 2 services that directly use a public image and there is no need to build.

If you deploy that manifest, you will see how the foo image is being built even if it is not necessary.

How to validate

Using the scenario described above, execute okteto deploy and see that foo image is not being build. Add that service within deploy.compose.services, execute it, and see how the image is now build. (it is expected that the build of foo fails because the folder foo doesn't exist

Without these changes, the first deploy would have triggered the deploy, and it shouldn't

…t rebuild all the images

Signed-off-by: Nacho Fuertes <nacho@okteto.com>
@ifbyol ifbyol requested a review from a team as a code owner July 9, 2025 13:22
@ifbyol ifbyol added release/bug-fix run-e2e When used on a PR run windows & unix e2e labels Jul 9, 2025
@jLopezbarb
Copy link
Contributor

Unit test are failing. @ifbyol can you check it?

Signed-off-by: Nacho Fuertes <nacho@okteto.com>
@ifbyol
Copy link
Member Author

ifbyol commented Jul 9, 2025

Unit test are failing. @ifbyol can you check it?

Yes, I just checked it, it was for adding the mock and I didn't modify the previous test. They should pass now

Copy link

codecov bot commented Jul 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.89%. Comparing base (5362ff5) to head (e6bd1d5).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4739      +/-   ##
==========================================
- Coverage   48.91%   48.89%   -0.02%     
==========================================
  Files         356      356              
  Lines       29807    29809       +2     
==========================================
- Hits        14580    14576       -4     
- Misses      14066    14070       +4     
- Partials     1161     1163       +2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ifbyol ifbyol merged commit d7395da into master Jul 10, 2025
24 checks passed
@ifbyol ifbyol deleted the ifbyol/fix-build-images-when-selected-services branch July 10, 2025 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release/bug-fix run-e2e When used on a PR run windows & unix e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants