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

Multiple requires seem to influence each other? #495

Open
Ma27 opened this issue Jan 30, 2025 · 0 comments
Open

Multiple requires seem to influence each other? #495

Ma27 opened this issue Jan 30, 2025 · 0 comments

Comments

@Ma27
Copy link
Member

Ma27 commented Jan 30, 2025

While trying to build a reproducer for an issue I had in a customer deployment, I stumbled upon this:

# environments/test/environment.cfg
[environment]
host_domain = fcio.net
service_user = s-myservice
platform = nixos
update_method = rsync
branch = master
jobs = 3

[host:test42]
components =
  service
  wordpresscron
  anothercomponent

[host:test68]
components =
  maintenancepage
# components/repro/component.py
from batou.component import Component
import batou


class Service(Component):
    def configure(self):
        self.provide("service", self)
        batou.output.annotate("Service component")


class WordpressCron(Component):
    def configure(self):
        self.provide("wordpress:cron", self)
        batou.output.annotate("WP cron")
        self.require_one("service", host=self.host)


class AnotherComponent(Component):
    def configure(self):
        self.require("wordpress:cron")
        batou.output.annotate("placeholder")


class MaintenancePage(Component):
    def configure(self):
        self.require("wordpress:cron", reverse=True, strict=False, host=self.host)

With batou 2.5.2 I now get the following error:

$ ./batou deploy -P test
batou/2.5.2 (cpython 3.11.9-final0, Darwin 24.2.0 arm64)
============================================================= Preparing =============================================================
main: Loading environment `test`...
main: Verifying repository ...
You are using rsync. This is a non-verifying repository -- continuing on your own risk!
main: Loading secrets ...
============================================ Connecting hosts and configuring model ... =============================================
test42: Connecting via ssh (1/2)
test68: Connecting via ssh (2/2)
Service component
WP cron
placeholder
placeholder
Service component
WP cron
placeholder
placeholder


ERROR: Unsatisfied resource requirements
    Resource "wordpress:cron" on "test68" required by anothercomponent

ERROR: 1 remaining unconfigured component(s): anothercomponent
================================================== 2 ERRORS - CONFIGURATION FAILED ==================================================
=========================================== DEPLOYMENT PREDICTION FAILED (during connect) ===========================================

I don't see anything that's obviously wrong with the code above.
Now, after doing

diff --git a/components/repro/component.py b/components/repro/component.py
index e4cf9bd..7997793 100644
--- a/components/repro/component.py
+++ b/components/repro/component.py
@@ -23,4 +23,5 @@ class AnotherComponent(Component):

 class MaintenancePage(Component):
     def configure(self):
-        self.require("wordpress:cron", reverse=True, strict=False, host=self.host)
+        #self.require("wordpress:cron", reverse=True, strict=False, host=self.host)
+        pass

The error disappeared, the prediction is passing.

Am I holding it wrong? I don't expect a requirement with strict=False to fail the requirement in another component.

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

No branches or pull requests

1 participant