Skip to content

Commit 17af8b5

Browse files
author
Jayendra Parsai
committed
feat: Cluster-scoped Rollouts support
Signed-off-by: Jayendra Parsai <[email protected]>
1 parent 2aba8a0 commit 17af8b5

18 files changed

+2252
-250
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ test: manifests generate fmt vet envtest ## Run tests.
109109

110110
.PHONY: test-e2e
111111
test-e2e: ## Run operator e2e tests
112-
go test -v -p=1 -timeout=10m -race -count=1 -coverprofile=coverage.out ./tests/e2e
112+
go test -v -p=1 -timeout=30m -race -count=1 -coverprofile=coverage.out ./tests/e2e
113113

114114
##@ Build
115115

api/v1alpha1/argorollouts_types.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ type RolloutManagerSpec struct {
4040

4141
// Version defines Argo Rollouts controller tag (optional)
4242
Version string `json:"version,omitempty"`
43+
44+
// NamespaceScoped lets you specify if rollouts manager has to watch a namespace or the whole cluster
45+
NamespaceScoped bool `json:"namespaceScoped,omitempty"`
4346
}
4447

4548
// ArgoRolloutsNodePlacementSpec is used to specify NodeSelector and Tolerations for Rollouts workloads
@@ -64,6 +67,9 @@ type RolloutManagerStatus struct {
6467
// Available: All of the resources for the RolloutManager are ready.
6568
// Unknown: The state of the RolloutManager phase could not be obtained.
6669
Phase RolloutControllerPhase `json:"phase,omitempty"`
70+
71+
// Conditions is an array of the RolloutManager's status conditions
72+
Conditions []metav1.Condition `json:"conditions,omitempty"`
6773
}
6874

6975
type RolloutControllerPhase string
@@ -75,6 +81,16 @@ const (
7581
PhaseFailure RolloutControllerPhase = "Failure"
7682
)
7783

84+
const (
85+
RolloutManagerConditionType = "Reconciled"
86+
)
87+
88+
const (
89+
RolloutManagerReasonSuccess = "Success"
90+
RolloutManagerReasonErrorOccurred = "ErrorOccurred"
91+
RolloutManagerReasonMultipleClusterScopedRolloutManager = "MultipleClusterScopedRolloutManager"
92+
)
93+
7894
//+kubebuilder:object:root=true
7995
//+kubebuilder:subresource:status
8096

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/argoproj.io_rolloutmanagers.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ spec:
154154
image:
155155
description: Image defines Argo Rollouts controller image (optional)
156156
type: string
157+
namespaceScoped:
158+
description: NamespaceScoped lets you specify if rollouts manager
159+
has to watch a namespace or the whole cluster
160+
type: boolean
157161
nodePlacement:
158162
description: NodePlacement defines NodeSelectors and Taints for Rollouts
159163
workloads
@@ -214,6 +218,76 @@ spec:
214218
status:
215219
description: RolloutManagerStatus defines the observed state of RolloutManager
216220
properties:
221+
conditions:
222+
description: Conditions is an array of the RolloutManager's status
223+
conditions
224+
items:
225+
description: "Condition contains details for one aspect of the current
226+
state of this API Resource. --- This struct is intended for direct
227+
use as an array at the field path .status.conditions. For example,
228+
\n type FooStatus struct{ // Represents the observations of a
229+
foo's current state. // Known .status.conditions.type are: \"Available\",
230+
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
231+
// +listType=map // +listMapKey=type Conditions []metav1.Condition
232+
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
233+
protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
234+
properties:
235+
lastTransitionTime:
236+
description: lastTransitionTime is the last time the condition
237+
transitioned from one status to another. This should be when
238+
the underlying condition changed. If that is not known, then
239+
using the time when the API field changed is acceptable.
240+
format: date-time
241+
type: string
242+
message:
243+
description: message is a human readable message indicating
244+
details about the transition. This may be an empty string.
245+
maxLength: 32768
246+
type: string
247+
observedGeneration:
248+
description: observedGeneration represents the .metadata.generation
249+
that the condition was set based upon. For instance, if .metadata.generation
250+
is currently 12, but the .status.conditions[x].observedGeneration
251+
is 9, the condition is out of date with respect to the current
252+
state of the instance.
253+
format: int64
254+
minimum: 0
255+
type: integer
256+
reason:
257+
description: reason contains a programmatic identifier indicating
258+
the reason for the condition's last transition. Producers
259+
of specific condition types may define expected values and
260+
meanings for this field, and whether the values are considered
261+
a guaranteed API. The value should be a CamelCase string.
262+
This field may not be empty.
263+
maxLength: 1024
264+
minLength: 1
265+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
266+
type: string
267+
status:
268+
description: status of the condition, one of True, False, Unknown.
269+
enum:
270+
- "True"
271+
- "False"
272+
- Unknown
273+
type: string
274+
type:
275+
description: type of condition in CamelCase or in foo.example.com/CamelCase.
276+
--- Many .condition.type values are consistent across resources
277+
like Available, but because arbitrary conditions can be useful
278+
(see .node.status.conditions), the ability to deconflict is
279+
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
280+
maxLength: 316
281+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
282+
type: string
283+
required:
284+
- lastTransitionTime
285+
- message
286+
- reason
287+
- status
288+
- type
289+
type: object
290+
type: array
217291
phase:
218292
description: 'Phase is a simple, high-level summary of where the RolloutManager
219293
is in its lifecycle. There are three possible phase values: Pending:

controllers/argorollouts_controller.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
corev1 "k8s.io/api/core/v1"
2525
rbacv1 "k8s.io/api/rbac/v1"
2626
"k8s.io/apimachinery/pkg/api/errors"
27+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2728
"k8s.io/apimachinery/pkg/runtime"
2829
ctrl "sigs.k8s.io/controller-runtime"
2930
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -93,8 +94,19 @@ func (r *RolloutManagerReconciler) Reconcile(ctx context.Context, req ctrl.Reque
9394
return reconcile.Result{}, err
9495
}
9596

96-
if err := r.reconcileRolloutsManager(ctx, rollouts); err != nil {
97-
// Error reconciling RolloutManager sub-resources - requeue the request.
97+
condition, err := r.reconcileRolloutsManager(ctx, rollouts)
98+
99+
if err := updateStatusConditionOfRolloutManager(ctx, condition, &rolloutsmanagerv1alpha1.RolloutManager{
100+
ObjectMeta: metav1.ObjectMeta{
101+
Name: req.Name,
102+
Namespace: req.Namespace,
103+
},
104+
}, r.Client, log); err != nil {
105+
log.Error(err, "unable to update status of RolloutManager")
106+
return reconcile.Result{}, err
107+
}
108+
109+
if err != nil {
98110
return reconcile.Result{}, err
99111
}
100112

@@ -122,8 +134,14 @@ func (r *RolloutManagerReconciler) SetupWithManager(mgr ctrl.Manager) error {
122134
// Watch for changes to Role sub-resources owned by RolloutManager.
123135
bld.Owns(&rbacv1.Role{})
124136

137+
// Watch for changes to ClusterRole sub-resources owned by RolloutManager.
138+
bld.Owns(&rbacv1.ClusterRole{})
139+
125140
// Watch for changes to RoleBinding sub-resources owned by RolloutManager.
126141
bld.Owns(&rbacv1.RoleBinding{})
127142

143+
// Watch for changes to ClusterRoleBinding sub-resources owned by RolloutManager.
144+
bld.Owns(&rbacv1.ClusterRoleBinding{})
145+
128146
return bld.Complete(r)
129147
}

0 commit comments

Comments
 (0)