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

Bundle is not removed after removing GitRepo configured with multiple paths #2586

Closed
1 task done
sbulage opened this issue Jul 3, 2024 · 3 comments
Closed
1 task done
Assignees
Labels
Milestone

Comments

@sbulage
Copy link
Contributor

sbulage commented Jul 3, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

After deleting GitRepo pointing to multiple paths(Service and ConfigMap), configmap getting removed but service is not being removed instead it is re-created.
Also, observed that bundle not removed after deleting GitRepo, may causing this issue. Same service app is created under Apps which is being re-created again and again.

Expected Behavior

Once GitRepo removed no leftover should be present.

Steps To Reproduce

  1. Create a GitRepo which is pointing to multiple paths. (I used: https://github.com/rancher/fleet-test-data and paths: multiple-paths)
  2. Wait for applications to deployed on each cluster (if there are more than one)
  3. Now delete GitRepo
  4. Check the applications are removed correctly or not.
  5. Check the bundle it is still there and didn't get removed.

Environment

- Architecture:
- Fleet Version:fleet:v0.10.0-rc.18
- Cluster:
  - Provider:k3s
  - Options:
  - Kubernetes Version:

Logs

GitJob Logs
{"level":"info","ts":"2024-07-03T09:57:14Z","logger":"git-latest-commit-poll-watch","msg":"new commit found","gitrepo":{"kind":"GitRepo","apiVersion":"fleet.cattle.io/v1alpha1","metadata":{"name":"correct-drift-service-test","namespace":"fleet-default","uid":"a424abd2-32f3-4c3e-a623-45f76e1c95c2","resourceVersion":"16236","generation":1,"creationTimestamp":"2024-07-03T09:57:14Z","managedFields":[{"manager":"rancher","operation":"Update","apiVersion":"fleet.cattle.io/v1alpha1","time":"2024-07-03T09:57:14Z","fieldsType":"FieldsV1","fieldsV1":{"f:spec":{".":{},"f:branch":{},"f:correctDrift":{".":{},"f:enabled":{}},"f:insecureSkipTLSVerify":{},"f:paths":{},"f:repo":{},"f:targets":{}}}}]},"spec":{"repo":"https://github.com/rancher/fleet-test-data","branch":"master","paths":["multiple-paths"],"targets":[{"clusterSelector":{"matchExpressions":[{"key":"provider.cattle.io","operator":"NotIn","values":["harvester"]}]}}],"imageScanCommit":{"authorName":"","authorEmail":""},"correctDrift":{}},"status":{"observedGeneration":0,"readyClusters":0,"desiredReadyClusters":0,"summary":{"ready":0,"desiredReady":0},"display":{},"resourceCounts":{"ready":0,"desiredReady":0,"waitApplied":0,"modified":0,"orphaned":0,"missing":0,"unknown":0,"notReady":0},"lastSyncedImageScanTime":null}},"commit":"4766e074c36c2820ea792420ad35ec1c3931c0e3"}
{"level":"info","ts":"2024-07-03T09:57:14Z","logger":"gitjob","msg":"job deletion triggered because of generation change","controller":"gitrepo","controllerGroup":"fleet.cattle.io","controllerKind":"GitRepo","GitRepo":{"name":"correct-drift-service-test","namespace":"fleet-default"},"namespace":"fleet-default","name":"correct-drift-service-test","reconcileID":"78d3c2e4-95d4-4181-add4-3f630d3342b9","generation":2,"commit":"4766e074c36c2820ea792420ad35ec1c3931c0e3"}
{"level":"info","ts":"2024-07-03T09:57:27Z","logger":"gitjob","msg":"job deletion triggered because of generation change","controller":"gitrepo","controllerGroup":"fleet.cattle.io","controllerKind":"GitRepo","GitRepo":{"name":"correct-drift-service-test","namespace":"fleet-default"},"namespace":"fleet-default","name":"correct-drift-service-test","reconcileID":"bf995b4b-ef0c-4851-882f-abb07b827905","generation":3,"commit":"4766e074c36c2820ea792420ad35ec1c3931c0e3"}
{"level":"info","ts":"2024-07-03T09:57:27Z","logger":"gitjob","msg":"job deletion triggered because of generation change","controller":"gitrepo","controllerGroup":"fleet.cattle.io","controllerKind":"GitRepo","GitRepo":{"name":"correct-drift-service-test","namespace":"fleet-default"},"namespace":"fleet-default","name":"correct-drift-service-test","reconcileID":"a51440a3-c576-4b62-a734-ce7a1538592a","generation":4,"commit":"4766e074c36c2820ea792420ad35ec1c3931c0e3"}
{"level":"info","ts":"2024-07-03T09:57:42Z","logger":"KubeAPIWarningLogger","msg":"unknown field \"status.resources[5].perClusterState[0].patch.spec\""}

Anything else?

In my GitRepo, ConfigMaps gets removed but Service remains as it is and re-created when try to delete it. Also, there is created for the same Service which cannot be removed.

@manno manno added this to the v2.9.0 milestone Jul 3, 2024
@0xavi0 0xavi0 self-assigned this Jul 3, 2024
0xavi0 added a commit to 0xavi0/fleet that referenced this issue Jul 3, 2024
When testing rancher#2586 the `Bundle` reconciler found
that the `Bundle` was gone as was trying to delete the same `BundleDeployments` in parallel.

Deleting the `Bundle` after deleting all its `BundleDeployments` seems to help to prevent that race condition
between both reconcilers

Refers to: rancher#2586

Signed-off-by: Xavi Garcia <[email protected]>
0xavi0 added a commit that referenced this issue Jul 3, 2024
When testing #2586 the `Bundle` reconciler found
that the `Bundle` was gone as was trying to delete the same `BundleDeployments` in parallel.

Deleting the `Bundle` after deleting all its `BundleDeployments` seems to help to prevent that race condition
between both reconcilers

Refers to: #2586

Signed-off-by: Xavi Garcia <[email protected]>
@0xavi0
Copy link
Contributor

0xavi0 commented Jul 3, 2024

I managed to recreate this one, but it was not happening all the time.

Adding here my resources just in case they're useful for QA.

I tested with the following GitRepo

apiVersion: fleet.cattle.io/v1alpha1
kind: GitRepo
metadata:
  name: sample
  namespace: fleet-local
spec:
  repo: "https://github.com/rancher/fleet-test-data"
  branch: master
  paths:
  - multiple-paths

and the following bash script:

#!/bin/bash

i=1

while true
do
  echo "---------------------------"
  kubectl apply -f test-2586.yaml

  OUT=""
  while [ "$OUT" != "2" ];
  do
   OUT=`kubectl get gitrepo sample -n fleet-local -o jsonpath='{.status.summary.ready}'`
  done

  kubectl delete gitrepo sample -n fleet-local
  kubectl wait --for=delete gitrepo/sample --timeout=60s -n fleet-local

  kubectl get bundles -A
  BUNDLES_LEFT=`kubectl get bundles -A | grep sample | wc -l`

  if [ "$BUNDLES_LEFT" == "       0" ];
  then
    echo "ALL GOOD attempt number: ${i}"
    echo "---------------------------"
    i=$(($i+1))
  else
    echo "FAILED"
    echo "---------------------------"
    exit 1
  fi
done

It fails repeatedly with the version without the fix:

---------------------------
gitrepo.fleet.cattle.io/sample created
gitrepo.fleet.cattle.io "sample" deleted
NAMESPACE     NAME                BUNDLEDEPLOYMENTS-READY   STATUS
fleet-local   fleet-agent-local   1/1
ALL GOOD attempt number: 8
---------------------------
---------------------------
gitrepo.fleet.cattle.io/sample created
gitrepo.fleet.cattle.io "sample" deleted
NAMESPACE     NAME                            BUNDLEDEPLOYMENTS-READY   STATUS
fleet-local   fleet-agent-local               1/1
fleet-local   sample-multiple-paths-service   1/1
FAILED
---------------------------
---------------------------
gitrepo.fleet.cattle.io/sample created
gitrepo.fleet.cattle.io "sample" deleted
NAMESPACE     NAME                BUNDLEDEPLOYMENTS-READY   STATUS
fleet-local   fleet-agent-local   1/1
ALL GOOD attempt number: 15
---------------------------
---------------------------
gitrepo.fleet.cattle.io/sample created
gitrepo.fleet.cattle.io "sample" deleted
NAMESPACE     NAME                            BUNDLEDEPLOYMENTS-READY   STATUS
fleet-local   fleet-agent-local               1/1
fleet-local   sample-multiple-paths-service   1/1
FAILED
---------------------------

and I was able to run the test 210 times and it did not fail just with the change in #2591

---------------------------
gitrepo.fleet.cattle.io/sample created
gitrepo.fleet.cattle.io "sample" deleted
NAMESPACE     NAME                BUNDLEDEPLOYMENTS-READY   STATUS
fleet-local   fleet-agent-local   1/1
ALL GOOD attempt number: 210
---------------------------

0xavi0 added a commit to 0xavi0/fleet that referenced this issue Jul 4, 2024
As we are using finalizers for Bundles we can let the Bundle reconciler deal
with its BundleDeployments and just delete the Bundle in the gitopts reconciler.

That way we avoid having race conditions between both reconcilers trying to
delete the same BundleDeployments

Related to: rancher#2586

Signed-off-by: Xavi Garcia <[email protected]>
0xavi0 added a commit that referenced this issue Jul 5, 2024
)

As we are using finalizers for Bundles we can let the Bundle reconciler deal
with its BundleDeployments and just delete the Bundle in the gitopts reconciler.

That way we avoid having race conditions between both reconcilers trying to
delete the same BundleDeployments

Related to: #2586

Signed-off-by: Xavi Garcia <[email protected]>
@sbulage
Copy link
Contributor Author

sbulage commented Jul 12, 2024

Thank You @0xavi0 for the script. It helped me to create and delete GitRepo quickly and observe the changes in the cluster.

@sbulage
Copy link
Contributor Author

sbulage commented Jul 12, 2024

System Information Version
Rancher 2.9.0-alpha7
Fleet 0.10.0-rc.20

Steps Performed:

  1. Executed steps from the description.
  2. After 10-15 iterations (manual execution and @0xavi0's script), found that after deleting GitRepo, Service and ConfigMap also gets deleted.
  3. Also, respective bundle gets deleted without any issue.

@sbulage sbulage closed this as completed Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

3 participants