Skip to content

Commit 439143b

Browse files
authored
Merge pull request #394 from gianlucam76/classifier-reports
Advance sveltos-agent image
2 parents b4a36a3 + d610b03 commit 439143b

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

controllers/classifier_report_collection.go

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,33 @@ func removeClusterClassifierReports(ctx context.Context, c client.Client, cluste
137137
return nil
138138
}
139139

140+
// ClassifierReports are collected from managed cluster to the management cluster.
141+
// When an ClassifierReport is collected from a managed cluster and created in the
142+
// management cluster, the label classifier.projectsveltos.io/cluster-name
143+
// is added. All ClassifierReport found in the management cluster with this
144+
// labels should be ignored as collected from other managed clusters.
145+
func shouldIgnore(cr *libsveltosv1beta1.ClassifierReport, isPullMode bool) bool {
146+
if isPullMode {
147+
// Sveltos-applier copies the EventReports to the management cluster
148+
// and add this label to the EventReport
149+
return false
150+
}
151+
152+
if getAgentInMgmtCluster() {
153+
// If sveltos-agent is in the management cluster, EventReports
154+
// are directly generated by sveltos-agent here. So there is no
155+
// copy to ignore.
156+
return false
157+
}
158+
159+
if cr.Labels == nil {
160+
return false
161+
}
162+
163+
_, ok := cr.Labels[libsveltosv1beta1.ClassifierReportClusterNameLabel]
164+
return ok
165+
}
166+
140167
// Periodically collects ClassifierReports from each cluster.
141168
// If sharding is used, it will collect only from clusters matching shard.
142169
func collectClassifierReports(c client.Client, shardKey, capiOnboardAnnotation, version string, logger logr.Logger) {
@@ -237,10 +264,7 @@ func collectClassifierReportsFromCluster(ctx context.Context, c client.Client,
237264
// ignore deleted ClassifierReport
238265
continue
239266
}
240-
if cr.Spec.ClusterName != "" {
241-
// if ClusterName is set, this is coming from a
242-
// managed cluster. If management cluster is in turn
243-
// managed by another cluster, do not pull those.
267+
if shouldIgnore(cr, isPullMode) {
244268
continue
245269
}
246270
l := logger.WithValues("classifierReport", cr.Name)

pkg/agent/sveltos-agent-in-mgmt-cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ spec:
4747
- --run-mode=do-not-send-reports
4848
command:
4949
- /manager
50-
image: docker.io/projectsveltos/sveltos-agent@sha256:fbd928be1cc5042bd509665defdd16da9d3e6f85b44130b96db754bf7e719779
50+
image: docker.io/projectsveltos/sveltos-agent@sha256:e1338fb576f4af2d1b15567e4f08276fd359b67d6b149e38c88ed457c1894894
5151
livenessProbe:
5252
failureThreshold: 3
5353
httpGet:

pkg/agent/sveltos-agent-in-mgmt-cluster.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ spec:
2929
- --run-mode=do-not-send-reports
3030
command:
3131
- /manager
32-
image: docker.io/projectsveltos/sveltos-agent@sha256:fbd928be1cc5042bd509665defdd16da9d3e6f85b44130b96db754bf7e719779
32+
image: docker.io/projectsveltos/sveltos-agent@sha256:e1338fb576f4af2d1b15567e4f08276fd359b67d6b149e38c88ed457c1894894
3333
livenessProbe:
3434
failureThreshold: 3
3535
httpGet:

pkg/agent/sveltos-agent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ spec:
198198
- --run-mode=do-not-send-reports
199199
command:
200200
- /manager
201-
image: docker.io/projectsveltos/sveltos-agent@sha256:fbd928be1cc5042bd509665defdd16da9d3e6f85b44130b96db754bf7e719779
201+
image: docker.io/projectsveltos/sveltos-agent@sha256:e1338fb576f4af2d1b15567e4f08276fd359b67d6b149e38c88ed457c1894894
202202
livenessProbe:
203203
failureThreshold: 3
204204
httpGet:

pkg/agent/sveltos-agent.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ spec:
180180
- --run-mode=do-not-send-reports
181181
command:
182182
- /manager
183-
image: docker.io/projectsveltos/sveltos-agent@sha256:fbd928be1cc5042bd509665defdd16da9d3e6f85b44130b96db754bf7e719779
183+
image: docker.io/projectsveltos/sveltos-agent@sha256:e1338fb576f4af2d1b15567e4f08276fd359b67d6b149e38c88ed457c1894894
184184
livenessProbe:
185185
failureThreshold: 3
186186
httpGet:

0 commit comments

Comments
 (0)