Skip to content

Commit

Permalink
Set unreachable Toleration in Placement
Browse files Browse the repository at this point in the history
Without it, ManagedClusters that are unreachable
are patched with a Taint and aren't returned by the
Placement controller.

ref: https://issues.redhat.com/browse/ACM-9871
Signed-off-by: Dale Haiducek <[email protected]>
  • Loading branch information
dhaiducek authored and openshift-merge-bot[bot] committed Feb 13, 2024
1 parent 60d90e0 commit 60c4103
Show file tree
Hide file tree
Showing 20 changed files with 147 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,12 @@ func (p *Plugin) createPlacement(
},
},
},
"tolerations": []map[string]interface{}{
{
"key": "cluster.open-cluster-management.io/unreachable",
"operator": "Exists",
},
},
},
}
}
Expand Down
48 changes: 48 additions & 0 deletions internal/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down Expand Up @@ -771,6 +774,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
Expand All @@ -782,6 +788,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down Expand Up @@ -1746,6 +1755,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
`
expected = strings.TrimPrefix(expected, "\n")
assertEqual(t, output, expected)
Expand Down Expand Up @@ -1788,6 +1800,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
`
expected = strings.TrimPrefix(expected, "\n")
assertEqual(t, output, expected)
Expand Down Expand Up @@ -1885,6 +1900,9 @@ spec:
operator: In
values:
- pacman
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
`
expected = strings.TrimPrefix(expected, "\n")
assertEqual(t, output, expected)
Expand Down Expand Up @@ -2029,6 +2047,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
`
p, plrPath := plPathHelper(t, plrYAML, true)

Expand Down Expand Up @@ -2137,6 +2158,9 @@ spec:
operator: In
values:
- pacman
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
`
plrYAML = strings.TrimPrefix(plrYAML, "\n")
p, _ := plPathHelper(t, plrYAML, false)
Expand Down Expand Up @@ -2192,6 +2216,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
`
p, plrPath := plPathHelper(t, plrYAML, false)

Expand All @@ -2218,6 +2245,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
`
p, plrPath := plPathHelper(t, plrYAML, false)

Expand Down Expand Up @@ -2245,6 +2275,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
`
p, plrPath := plPathHelper(t, plrYAML, false)

Expand Down Expand Up @@ -2654,6 +2687,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down Expand Up @@ -2786,6 +2822,9 @@ spec:
operator: In
values:
- my-cluster
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down Expand Up @@ -3816,6 +3855,9 @@ spec:
labelSelector:
matchLabels:
cloud: red hat
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
`
expected = strings.TrimPrefix(expected, "\n")
assertEqual(t, output, expected)
Expand Down Expand Up @@ -3866,6 +3908,9 @@ spec:
values:
- red hat
- test
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
`
expected = strings.TrimPrefix(expected, "\n")
assertEqual(t, output, expected)
Expand Down Expand Up @@ -3950,6 +3995,9 @@ spec:
- red hat
matchLabels:
cloud: red hat
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
`
expected = strings.TrimPrefix(expected, "\n")
assertEqual(t, output, expected)
Expand Down
6 changes: 6 additions & 0 deletions internal/testdata/ordering/default-deps-propagated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
Expand All @@ -96,6 +99,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
Expand All @@ -104,6 +107,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
6 changes: 6 additions & 0 deletions internal/testdata/ordering/default-extradeps-override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
Expand All @@ -119,6 +122,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
6 changes: 6 additions & 0 deletions internal/testdata/ordering/default-extradeps-propagated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
Expand All @@ -119,6 +122,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
3 changes: 3 additions & 0 deletions internal/testdata/ordering/dependency-details-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
3 changes: 3 additions & 0 deletions internal/testdata/ordering/extradeps-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
Expand All @@ -103,6 +106,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
Expand All @@ -93,6 +96,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
Expand All @@ -103,6 +106,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
6 changes: 6 additions & 0 deletions internal/testdata/ordering/ignore-pending-propagation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
Expand All @@ -104,6 +107,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
Expand All @@ -106,6 +109,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
6 changes: 6 additions & 0 deletions internal/testdata/ordering/manifest-extradeps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
Expand All @@ -107,6 +110,9 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
Loading

0 comments on commit 60c4103

Please sign in to comment.