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

Error out when roles or host filters don't match anything #595

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

mdkent
Copy link
Member

@mdkent mdkent commented Nov 25, 2023

Raise an error when either the filtered hosts or roles are empty.

Keeps us from confusingly running things on the primary_host when nothing matches.

eg: given

servers:
  web:
    traefik: true
    hosts:
    - 1.1.1.1
    - 1.1.1.2

  jobs:
    hosts:
    - 1.1.1.3
    - 1.1.1.4

These should fail

$ bin/kamal lock release -d staging -r intentional_miss
  INFO [0f6fb993] Running /usr/bin/env mkdir -p .kamal on 1.1.1.1

$ bin/kamal lock release -d staging -h intentional_miss
  INFO [68394a4b] Running /usr/bin/env mkdir -p .kamal on 1.1.1.1

but they run anyway.

The deploy is worse though, instead of failing when nothing matches the filter, it'll just run a normal deploy to all hosts, really the opposite of what we want. eg:

$ bin/kamal deploy -d staging -r intentional_miss -H
Acquiring the deploy lock...
Log into image registry...
  INFO [b51e6587] Running docker login -u [REDACTED] -p [REDACTED] as mkent@localhost
  INFO [b51e6587] Finished in 1.396 seconds with exit status 0 (successful).
Build and push app image...
  INFO [2d95b1ab] Running docker --version && docker buildx version as mkent@localhost
  INFO [2d95b1ab] Finished in 0.095 seconds with exit status 0 (successful).
The following paths have uncommitted changes:
 M bin/kamal
 M config/deploy.staging.yml
  INFO [717fd98f] Running docker buildx build --push --platform linux/amd64 --builder kamal-foo-native-remote -t basecamp/foo-rails:e45b4e8301b55ef3cd16f539f5d124d1744114ab_uncommitted_be9bf8640bf84276 <redacted> . as mkent@localhost
 DEBUG [717fd98f] Command: docker buildx build --push --platform linux/amd64 --builder kamal-foo-native-remote -t basecamp/foo-rails:e45b4e8301b55ef3cd16f539f5d124d1744114ab_uncommitted_be9bf8640bf84276 <redacted> .
 DEBUG [717fd98f] 	#0 building with "kamal-foo-native-remote" instance using docker-container driver
<snip>

Keeps us confusingly running things on the primary_host when nothing
matches.
@mdkent mdkent requested a review from djmb November 25, 2023 21:12
@djmb djmb merged commit 0e067fb into match-primary-role-in-filters Nov 27, 2023
6 checks passed
@djmb djmb deleted the error-on-filter-miss branch November 27, 2023 08:08
@djmb djmb restored the error-on-filter-miss branch November 27, 2023 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants