fleet icon indicating copy to clipboard operation
fleet copied to clipboard

Resources from gitrepo are reported as existing with `targetCustomizations` and `doNotDeploy: true`

Open thehejik opened this issue 3 months ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

With following fleet.yaml from gitrepo its resources are reported as existing even if these resources are actually not deployed on any cluster. After clicking on the resource name Rancher errors out.

defaultNamespace: fleet-nginx-github
targetCustomizations:
- name: dev
  doNotDeploy: true
  clusterSelector:
    matchLabels:
      env: dev

Sample deployment.yaml used together with fleet.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: fleet-nginx
  name: fleet-nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: fleet-nginx
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: fleet-nginx
    spec:
      containers:r 
      - image: nginx:alpine
        name: nginx
        ports:
        - containerPort: 80

The clusterSelector matches to a cluster (with env: dev label) where the resources are actually not deployed. The target cluster is correctly ignored but non-existing resources are actually reported: image

On attempt to click on the non-existing resource name on cluster dhcp12: image

Rancher errors out: image

The issue was found when validating https://github.com/rancher/fleet/issues/2245 and it is present in Rancher 2.7.7, 2.8.3 and in 2.9-head.

Expected Behavior

Resources that are not deployed on any cluster should not be reported as Ready, esp. for a cluster specified in targetCustomizations and with doNotDeploy: true entry set. Anyway targetCustomizations and doNotDeploy keys are working as expected.

It would be nice if the non-existing resources are not reported as Ready.

Steps To Reproduce

  1. Deploy 2 clusters with k3s, first for local and second for downstream cluster
  2. Install rancher 2.7.7 (or 2.8.3 or 2.9-head) on local cluster
  3. import the second k3s as downstream cluster
  4. Add label env: dev to your downstream cluster
  5. Add a gitrepo in fleet-default namespace with mentioned resources
  6. Observe status of the gitrepo - There are no targets recognized correctly, but resources are reported as Ready
  7. Click on the resource name in gitrepo detail view - there will be error in rancher.

Environment

- Architecture:
- Fleet Version: 0.8, 0.9, 0.10
- Cluster:
  - Provider: k3s
  - Kubernetes Version: any

Logs

No response

Anything else?

No response

thehejik avatar May 06 '24 13:05 thehejik