Open anupchandak opened 1 year ago
@jberkhahn The thread regarding this issue: https://mail.google.com/mail/u/0/#search/ansible/FMfcgzGrcXtllNJlqSFwVfvsJVrwzQjw
@anupchandak Could you please share your controller pod logs or the project, for us to able to run it locally and check the issue. The selectors should be working as expected by creating predicates, looking at the logs may help us dig into it more.
@varshaprasad96 - I tried creating a sample project using the Memcached example but was not able to reproduce the above issue.
I cannot share my work project for copyright restrictions.
Any pointer on how I can check what is all coming on the operator's watch list when it starts? And selector it is applying.
Any way to know what dependent resource was changed that triggered the operator's reconciliation loop?
The other option is to add additional logs in ansible operator binary and try it out locally to see what is happening. Some pointers are:
watches.yaml
is being parsed as expected. In the sense if the selectors are being parsed and loaded from the watches file, which happens here: https://github.com/operator-framework/operator-sdk/blob/5cbdad9209332043b7c730856b6302edc8996faf/internal/ansible/watches/watches.go#L313You may have to build the binary locally to test it out. The steps are here: https://sdk.operatorframework.io/docs/contribution-guidelines/developer-guide/.
Before all this, I would suggest to increase the log verbosity and check if there is anything suspicious indicating that labels haven't been set up as expected. Hope this helps!
@varshaprasad96 - Thank you so much for your detailed reply above.
Sorry for the late reply but I think I am able to reproduce the issue. I think it's because of the dependent resource CronJob created by the CR.
Please use the attached project and follow the below steps to reproduce the issue.
make install
.ansible-operator run local --zap-devel=true
.apple
namespace. This will create a deployment object and a CronJob in the suspended state.
kubectl create namespace apple
kubectl config set-context --current --namespace=apple
kubectl --namespace apple create -f config/samples/apple_sample.yaml
banana
namespace. This will create a deployment object and a CronJob in the non-suspended state.
kubectl create namespace banana
kubectl config set-context --current --namespace=banana
kubectl --namespace banana create -f config/samples/banana_sample.yaml
watches.yaml
to only select resources from the apple
namespace.
selector:
matchExpressions:
- key: cache.example.com/controller-namespace
operator: In
values: [apple]
ansible-operator run local --zap-devel=true
.banana
namespace is triggered even though the Operator watches selector is configured to watch only resources from the apple
namespace.I have also attached logs from my local execution. Please note that to restrict the logs to only testing namespaces, I had set export WATCH_NAMESPACE=apple,banana
.
memcached-operator.zip reconcile_log.txt
Thank you!
Team - Any comment/update on this issue?
Hi Team - Have you got a chance to look at this issue?
Issues go stale after 90d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle stale
.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen
.
If this issue is safe to close now please do so with /close
.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle rotten
.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen
.
If this issue is safe to close now please do so with /close
.
/lifecycle rotten /remove-lifecycle stale
To control the scope of an operator in a multi-development environment, I have defined a selector at the
watches.yaml
level by referring hereThe selector is defined as something like the below (presented below with equivalent dummy values)
When I start my ansible runner then as expected, I see the following log at the start
and I expect that my Operator will still not worry (watch) about CR defined with the label
mytest.com/controller-namespace=your-test-na
. But it does and reconciles it.It is an ansible based operator and environment details are as below: