Skip to content

Commit 32b413d

Browse files
jpinsonneaujotak
andauthored
NETOBSERV-2534: Have a way to pause Network Observability functions (#2362)
* hold flag implementation * skip SCC * Use FlowCollector OnHold instead of CSV * Delete agent SA on hold --------- Co-authored-by: Joel Takvorian <jtakvori@redhat.com>
1 parent 38c7006 commit 32b413d

19 files changed

+499
-132
lines changed

api/flowcollector/v1beta2/flowcollector_types.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ type FlowCollectorSpec struct {
9191

9292
// `networkPolicy` defines network policy settings for NetObserv components isolation.
9393
NetworkPolicy NetworkPolicy `json:"networkPolicy,omitempty"`
94+
95+
// `execution` defines configuration related to the execution of the flow collection process.
96+
Execution FlowCollectorExecution `json:"execution,omitempty"`
9497
}
9598

9699
type NetworkPolicy struct {
@@ -1542,6 +1545,25 @@ type FlowCollectorExporter struct {
15421545
OpenTelemetry FlowCollectorOpenTelemetry `json:"openTelemetry,omitempty"`
15431546
}
15441547

1548+
type ExecutionMode string
1549+
1550+
const (
1551+
Running ExecutionMode = "Running"
1552+
OnHold ExecutionMode = "OnHold"
1553+
)
1554+
1555+
// `FlowCollectorExecution` defines the flow collection process execution desired state.
1556+
type FlowCollectorExecution struct {
1557+
// `mode` is the flow collection process execution desired mode: `Running` or `OnHold`.
1558+
// When `OnHold`, the operator deletes all managed services and workloads, with the exception
1559+
// of the static console plugin, and the operator itself.
1560+
// It allows to use minimal cluster resources without losing configuration.
1561+
// +kubebuilder:validation:Enum:="";"Running";"OnHold"
1562+
// +kubebuilder:default:=Running
1563+
// +optional
1564+
Mode ExecutionMode `json:"mode"`
1565+
}
1566+
15451567
// `FlowCollectorStatus` defines the observed state of FlowCollector
15461568
type FlowCollectorStatus struct {
15471569
// Important: Run "make" to regenerate code after modifying this file

api/flowcollector/v1beta2/helper.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ func (spec *FlowCollectorSpec) GetNamespace() string {
1313
return constants.DefaultOperatorNamespace
1414
}
1515

16+
func (spec *FlowCollectorSpec) OnHold() bool {
17+
return spec.Execution.Mode == OnHold
18+
}
19+
1620
func (spec *FlowCollectorSpec) GetSampling() int {
1721
if spec.Agent.EBPF.Sampling == nil {
1822
return 50

api/flowcollector/v1beta2/zz_generated.deepcopy.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/manifests/flows.netobserv.io_flowcollectors.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3245,6 +3245,23 @@ spec:
32453245
- Direct
32463246
- Kafka
32473247
type: string
3248+
execution:
3249+
description: '`execution` defines configuration related to the execution
3250+
of the flow collection process.'
3251+
properties:
3252+
mode:
3253+
default: Running
3254+
description: |-
3255+
`mode` is the flow collection process execution desired mode: `Running` or `OnHold`.
3256+
When `OnHold`, the operator deletes all managed services and workloads, with the exception
3257+
of the static console plugin, and the operator itself.
3258+
It allows to use minimal cluster resources without losing configuration.
3259+
enum:
3260+
- ""
3261+
- Running
3262+
- OnHold
3263+
type: string
3264+
type: object
32483265
exporters:
32493266
description: '`exporters` defines additional optional exporters for
32503267
custom consumption or storage.'

bundle/manifests/netobserv-operator.clusterserviceversion.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,10 @@ spec:
410410
path: consolePlugin.standalone
411411
- displayName: Unmanaged replicas
412412
path: consolePlugin.unmanagedReplicas
413+
- displayName: Execution
414+
path: execution
415+
- displayName: Mode
416+
path: execution.mode
413417
- displayName: Address
414418
path: kafka.address
415419
- displayName: Topic

config/crd/bases/flows.netobserv.io_flowcollectors.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,6 +3040,22 @@ spec:
30403040
- Direct
30413041
- Kafka
30423042
type: string
3043+
execution:
3044+
description: '`execution` defines configuration related to the execution of the flow collection process.'
3045+
properties:
3046+
mode:
3047+
default: Running
3048+
description: |-
3049+
`mode` is the flow collection process execution desired mode: `Running` or `OnHold`.
3050+
When `OnHold`, the operator deletes all managed services and workloads, with the exception
3051+
of the static console plugin, and the operator itself.
3052+
It allows to use minimal cluster resources without losing configuration.
3053+
enum:
3054+
- ""
3055+
- Running
3056+
- OnHold
3057+
type: string
3058+
type: object
30433059
exporters:
30443060
description: '`exporters` defines additional optional exporters for custom consumption or storage.'
30453061
items:

docs/FlowCollector.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ Kafka can provide better scalability, resiliency, and high availability (for mor
122122
<i>Default</i>: Service<br/>
123123
</td>
124124
<td>false</td>
125+
</tr><tr>
126+
<td><b><a href="#flowcollectorspecexecution">execution</a></b></td>
127+
<td>object</td>
128+
<td>
129+
`execution` defines configuration related to the execution of the flow collection process.<br/>
130+
</td>
131+
<td>false</td>
125132
</tr><tr>
126133
<td><b><a href="#flowcollectorspecexportersindex">exporters</a></b></td>
127134
<td>[]object</td>
@@ -6008,6 +6015,39 @@ only the result of this request.<br/>
60086015
</table>
60096016

60106017

6018+
### FlowCollector.spec.execution
6019+
<sup><sup>[↩ Parent](#flowcollectorspec)</sup></sup>
6020+
6021+
6022+
6023+
`execution` defines configuration related to the execution of the flow collection process.
6024+
6025+
<table>
6026+
<thead>
6027+
<tr>
6028+
<th>Name</th>
6029+
<th>Type</th>
6030+
<th>Description</th>
6031+
<th>Required</th>
6032+
</tr>
6033+
</thead>
6034+
<tbody><tr>
6035+
<td><b>mode</b></td>
6036+
<td>enum</td>
6037+
<td>
6038+
`mode` is the flow collection process execution desired mode: `Running` or `OnHold`.
6039+
When `OnHold`, the operator deletes all managed services and workloads, with the exception
6040+
of the static console plugin, and the operator itself.
6041+
It allows to use minimal cluster resources without losing configuration.<br/>
6042+
<br/>
6043+
<i>Enum</i>: , Running, OnHold<br/>
6044+
<i>Default</i>: Running<br/>
6045+
</td>
6046+
<td>false</td>
6047+
</tr></tbody>
6048+
</table>
6049+
6050+
60116051
### FlowCollector.spec.exporters[index]
60126052
<sup><sup>[↩ Parent](#flowcollectorspec)</sup></sup>
60136053

helm/crds/flows.netobserv.io_flowcollectors.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3044,6 +3044,22 @@ spec:
30443044
- Direct
30453045
- Kafka
30463046
type: string
3047+
execution:
3048+
description: '`execution` defines configuration related to the execution of the flow collection process.'
3049+
properties:
3050+
mode:
3051+
default: Running
3052+
description: |-
3053+
`mode` is the flow collection process execution desired mode: `Running` or `OnHold`.
3054+
When `OnHold`, the operator deletes all managed services and workloads, with the exception
3055+
of the static console plugin, and the operator itself.
3056+
It allows to use minimal cluster resources without losing configuration.
3057+
enum:
3058+
- ""
3059+
- Running
3060+
- OnHold
3061+
type: string
3062+
type: object
30473063
exporters:
30483064
description: '`exporters` defines additional optional exporters for custom consumption or storage.'
30493065
items:

internal/controller/consoleplugin/consoleplugin_reconciler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (r *CPReconciler) Reconcile(ctx context.Context, desired *flowslatest.FlowC
7070
}
7171
}
7272

73-
if desired.Spec.UseConsolePlugin() && (r.ClusterInfo.HasConsolePlugin() || desired.Spec.ConsolePlugin.Standalone) {
73+
if desired.Spec.UseConsolePlugin() && (r.ClusterInfo.HasConsolePlugin() || desired.Spec.ConsolePlugin.Standalone) && !desired.Spec.OnHold() {
7474
// Create object builder
7575
builder := newBuilder(r.Instance, &desired.Spec, constants.PluginName)
7676

internal/controller/ebpf/agent_controller.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,24 @@ func (c *AgentController) Reconcile(ctx context.Context, target *flowslatest.Flo
145145
return err
146146
}
147147

148-
if err := c.permissions.Reconcile(ctx, &target.Spec.Agent.EBPF); err != nil {
148+
if err := c.permissions.Reconcile(ctx, target); err != nil {
149149
return fmt.Errorf("reconciling permissions: %w", err)
150150
}
151151

152+
if target.Spec.OnHold() {
153+
c.Status.SetUnused("FlowCollector is on hold")
154+
rlog.Info("action: delete agent")
155+
err = c.DeleteIfOwned(ctx, current)
156+
if err != nil {
157+
return err
158+
}
159+
err = c.DeleteIfOwned(ctx, c.promSvc)
160+
if err != nil {
161+
return err
162+
}
163+
return nil
164+
}
165+
152166
err = c.reconcileMetricsService(ctx, &target.Spec.Agent.EBPF)
153167
if err != nil {
154168
return fmt.Errorf("reconciling prometheus service: %w", err)

0 commit comments

Comments
 (0)