Skip to content

Commit 953cf7f

Browse files
Google Cloud Agent for Compute Workloads Devcopybara-github
authored andcommitted
Allow openshift metric collection frequency to be configurable
PiperOrigin-RevId: 856428017
1 parent e370e6b commit 953cf7f

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

build/openshift-docker-entrypoint.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ OCP_PASSWORD=$(cat /etc/secrets/ocp-password)
2929

3030
# Non sensitive variables with reasonable defaults
3131
LOG_LEVEL="${LOG_LEVEL:-INFO}"
32-
COLLECTION_FREQUENCY="${COLLECTION_FREQUENCY:-60s}"
32+
COLLECTION_FREQUENCY="${COLLECTION_FREQUENCY:-1800s}"
3333
DATA_WAREHOUSE_ENDPOINT="${DATA_WAREHOUSE_ENDPOINT:-https://workloadmanager-datawarehouse.googleapis.com/}"
3434

3535

@@ -74,11 +74,11 @@ jq -nc \
7474
username: $ocp_username,
7575
password: $ocp_password,
7676
host: $ocp_host,
77-
}
77+
},
78+
collection_frequency: $collection_frequency
7879
},
7980
common_discovery: {
80-
enabled: false,
81-
collection_frequency: $collection_frequency
81+
enabled: false
8282
},
8383
sqlserver_configuration: {
8484
enabled: false

internal/daemon/openshift/openshift.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ import (
3333
)
3434

3535
const (
36-
wlmCollectionFrequency = 30 * time.Minute
37-
payloadVersion = "v0.0.1-pre"
36+
defaultCollectionFrequency = 30 * time.Minute
37+
payloadVersion = "v0.0.1-pre"
3838
)
3939

4040
// Service implements the interfaces for OpenShift workload agent service.
@@ -65,7 +65,7 @@ func (s *Service) Start(ctx context.Context, a any) {
6565
RoutineArg: runMetricCollectionArgs{s},
6666
ErrorCode: usagemetrics.OpenShiftMetricCollectionFailure,
6767
UsageLogger: *usagemetrics.UsageLogger,
68-
ExpectedMinDuration: wlmCollectionFrequency,
68+
ExpectedMinDuration: s.Config.GetOpenshiftConfiguration().GetCollectionFrequency().AsDuration(),
6969
}
7070
metricCollectionRoutine.StartRoutine(mcCtx)
7171
select {
@@ -83,7 +83,14 @@ func runMetricCollection(ctx context.Context, a any) {
8383
log.CtxLogger(ctx).Errorf("failed to parse metric collection args", "args", a)
8484
return
8585
}
86-
ticker := time.NewTicker(wlmCollectionFrequency)
86+
duration := args.s.Config.GetOpenshiftConfiguration().GetCollectionFrequency().AsDuration()
87+
if duration.Seconds() == 0 {
88+
log.CtxLogger(ctx).Debug("Using default collection frequency")
89+
duration = defaultCollectionFrequency
90+
return
91+
}
92+
log.CtxLogger(ctx).Debugw("Using collection frequency", "seconds", duration.Seconds())
93+
ticker := time.NewTicker(duration)
8794
defer ticker.Stop()
8895

8996
for {

protos/configuration/configuration.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ message MySQLConfiguration {
9898
message OpenShiftConfiguration {
9999
optional bool enabled = 1;
100100
ConnectionParameters connection_parameters = 2;
101+
google.protobuf.Duration collection_frequency = 3;
101102
}
102103

103104
message CommonDiscovery {

0 commit comments

Comments
 (0)