policymanager: remove support for dual-implementation logging agent
Remove fluentd/fluent-bit selection infrastructure: fluentd is removed
from the image altogether and fluent-bit is the only supported logging
agent.
BUG=b/319168965
TEST=presubmit
RELEASE_NOTE=None
Change-Id: I2c66dfc0f59215f1abc435f14a0fb05c882c6fe7
diff --git a/cmd/monitor/monitor.go b/cmd/monitor/monitor.go
index 5d6fcba..e941abf 100644
--- a/cmd/monitor/monitor.go
+++ b/cmd/monitor/monitor.go
@@ -61,11 +61,10 @@
)
var serviceMonitor = map[string]string{
- "loggingService": "logging-agent.target",
- "loggingServiceFluentBit": "logging-agent-fluentbit.target",
- "monitoringService": "node-problem-detector.service",
- "metricsService": "crash-reporter.service",
- "updateService": "update-engine.service",
+ "loggingService": "logging-agent.target",
+ "monitoringService": "node-problem-detector.service",
+ "metricsService": "crash-reporter.service",
+ "updateService": "update-engine.service",
}
// resolveEnforcementConfig sets enforcement related fields in userConfig to
@@ -82,7 +81,6 @@
if userConfig.HealthMonitorConfig == nil {
userConfig.HealthMonitorConfig = new(protos.HealthMonitorConfig)
}
-
userConfig.HealthMonitorConfig.Enforced = proto.Bool(false)
// Set HealthMonitorConfig.Enforced to true if either logging or monitoring is enabled and return.
@@ -124,10 +122,9 @@
MetricsEnabled: proto.Bool(false),
UpdateStrategy: proto.String(""),
HealthMonitorConfig: &protos.HealthMonitorConfig{
- Enforced: proto.Bool(false),
- LoggingEnabled: proto.Bool(false),
- LoggingFluentBitEnabled: proto.Bool(true),
- MonitoringEnabled: proto.Bool(false),
+ Enforced: proto.Bool(false),
+ LoggingEnabled: proto.Bool(false),
+ MonitoringEnabled: proto.Bool(false),
},
}
diff --git a/pkg/configfetcher/configfetcher.go b/pkg/configfetcher/configfetcher.go
index c119eee..6c8fc71 100644
--- a/pkg/configfetcher/configfetcher.go
+++ b/pkg/configfetcher/configfetcher.go
@@ -47,9 +47,8 @@
cosKeyMetricsEnabled = "cos-metrics-enabled"
// Metadata keys for GCP-related features.
- keyGoogleLoggingEnabled = "google-logging-enabled"
- keyGoogleLoggingUseFluentBit = "google-logging-use-fluentbit"
- keyGoogleMonitoringEnabled = "google-monitoring-enabled"
+ keyGoogleLoggingEnabled = "google-logging-enabled"
+ keyGoogleMonitoringEnabled = "google-monitoring-enabled"
// Note that there are 2 types of metadata entries: endpoint and
// directory. Endpoint maps to a single value, while directory contains
@@ -271,12 +270,6 @@
}
}
- if configStr, ok := getCOSGCIConfigSetting(keyGoogleLoggingUseFluentBit, "", instanceMetadata, projectMetadata); ok {
- if boolean, err = strconv.ParseBool(configStr); err == nil {
- userConfig.HealthMonitorConfig.LoggingFluentBitEnabled = proto.Bool(boolean)
- }
- }
-
if configStr, ok := getCOSGCIConfigSetting(keyGoogleMonitoringEnabled, "", instanceMetadata, projectMetadata); ok {
if boolean, err = strconv.ParseBool(configStr); err == nil {
userConfig.HealthMonitorConfig.MonitoringEnabled = proto.Bool(boolean)
diff --git a/pkg/configfetcher/configfetcher_test.go b/pkg/configfetcher/configfetcher_test.go
index 75b8784..86ba097 100644
--- a/pkg/configfetcher/configfetcher_test.go
+++ b/pkg/configfetcher/configfetcher_test.go
@@ -151,51 +151,6 @@
},
},
},
- {
- "LoggingAndFluentBit",
- map[string]string{
- keyGoogleLoggingEnabled: "true",
- },
- map[string]string{
- keyGoogleLoggingUseFluentBit: "true",
- },
- &protos.InstanceConfig{
- HealthMonitorConfig: &protos.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(true),
- LoggingFluentBitEnabled: proto.Bool(true),
- },
- },
- },
- {
- "FluentBitTrueAndFalse",
- map[string]string{
- keyGoogleLoggingEnabled: "true",
- keyGoogleLoggingUseFluentBit: "false",
- },
- map[string]string{
- keyGoogleLoggingUseFluentBit: "true",
- },
- &protos.InstanceConfig{
- HealthMonitorConfig: &protos.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(true),
- LoggingFluentBitEnabled: proto.Bool(false),
- },
- },
- },
- {
- "FluentBitWithoutLoggingEnabled",
- map[string]string{
- keyGoogleLoggingUseFluentBit: "true",
- },
- map[string]string{},
- &protos.InstanceConfig{
- HealthMonitorConfig: &protos.HealthMonitorConfig{
- LoggingFluentBitEnabled: proto.Bool(true),
- },
- },
- },
}
for _, test := range tests {
diff --git a/pkg/devicepolicy/manager.go b/pkg/devicepolicy/manager.go
index 838de66..1f5254f 100644
--- a/pkg/devicepolicy/manager.go
+++ b/pkg/devicepolicy/manager.go
@@ -158,10 +158,9 @@
MetricsEnabled: proto.Bool(false),
UpdateStrategy: proto.String(""),
HealthMonitorConfig: &pmpb.HealthMonitorConfig{
- Enforced: proto.Bool(false),
- LoggingEnabled: proto.Bool(false),
- LoggingFluentBitEnabled: proto.Bool(true),
- MonitoringEnabled: proto.Bool(false),
+ Enforced: proto.Bool(false),
+ LoggingEnabled: proto.Bool(false),
+ MonitoringEnabled: proto.Bool(false),
},
}
diff --git a/pkg/devicepolicy/manager_test.go b/pkg/devicepolicy/manager_test.go
index c34b9b6..cc38148 100644
--- a/pkg/devicepolicy/manager_test.go
+++ b/pkg/devicepolicy/manager_test.go
@@ -32,10 +32,9 @@
MetricsEnabled: proto.Bool(true),
UpdateStrategy: proto.String(""),
HealthMonitorConfig: &pb.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(true),
- LoggingFluentBitEnabled: proto.Bool(false),
- MonitoringEnabled: proto.Bool(false),
+ Enforced: proto.Bool(true),
+ LoggingEnabled: proto.Bool(true),
+ MonitoringEnabled: proto.Bool(false),
},
}
@@ -500,10 +499,9 @@
MetricsEnabled: proto.Bool(false),
UpdateStrategy: proto.String(""),
HealthMonitorConfig: &pb.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(true),
- LoggingFluentBitEnabled: proto.Bool(true),
- MonitoringEnabled: proto.Bool(false),
+ Enforced: proto.Bool(true),
+ LoggingEnabled: proto.Bool(true),
+ MonitoringEnabled: proto.Bool(false),
},
}
expectedInstanceConfigBytes := generateFakePolicyBytes(t, expectedInstanceConfig)
@@ -541,10 +539,9 @@
MetricsEnabled: proto.Bool(false),
UpdateStrategy: proto.String(""),
HealthMonitorConfig: &pb.HealthMonitorConfig{
- Enforced: proto.Bool(false),
- LoggingEnabled: proto.Bool(false),
- LoggingFluentBitEnabled: proto.Bool(true),
- MonitoringEnabled: proto.Bool(false),
+ Enforced: proto.Bool(false),
+ LoggingEnabled: proto.Bool(false),
+ MonitoringEnabled: proto.Bool(false),
},
}
@@ -574,10 +571,9 @@
MetricsEnabled: proto.Bool(true),
UpdateStrategy: proto.String(""),
HealthMonitorConfig: &pb.HealthMonitorConfig{
- Enforced: proto.Bool(false),
- LoggingEnabled: proto.Bool(false),
- LoggingFluentBitEnabled: proto.Bool(true),
- MonitoringEnabled: proto.Bool(false),
+ Enforced: proto.Bool(false),
+ LoggingEnabled: proto.Bool(false),
+ MonitoringEnabled: proto.Bool(false),
},
},
},
@@ -590,10 +586,9 @@
MetricsEnabled: proto.Bool(false),
UpdateStrategy: proto.String(""),
HealthMonitorConfig: &pb.HealthMonitorConfig{
- Enforced: proto.Bool(false),
- LoggingEnabled: proto.Bool(false),
- LoggingFluentBitEnabled: proto.Bool(true),
- MonitoringEnabled: proto.Bool(false),
+ Enforced: proto.Bool(false),
+ LoggingEnabled: proto.Bool(false),
+ MonitoringEnabled: proto.Bool(false),
},
},
},
@@ -607,10 +602,9 @@
MetricsEnabled: proto.Bool(true),
UpdateStrategy: proto.String(""),
HealthMonitorConfig: &pb.HealthMonitorConfig{
- Enforced: proto.Bool(false),
- LoggingEnabled: proto.Bool(false),
- LoggingFluentBitEnabled: proto.Bool(true),
- MonitoringEnabled: proto.Bool(false),
+ Enforced: proto.Bool(false),
+ LoggingEnabled: proto.Bool(false),
+ MonitoringEnabled: proto.Bool(false),
},
},
},
@@ -627,31 +621,9 @@
MetricsEnabled: proto.Bool(false),
UpdateStrategy: proto.String(""),
HealthMonitorConfig: &pb.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(true),
- LoggingFluentBitEnabled: proto.Bool(true),
- MonitoringEnabled: proto.Bool(false),
- },
- },
- },
- {
- "BaseConfigEnablingLoggingFluentBitMissingMonitoring",
- &pb.InstanceConfig{
- UpdateStrategy: proto.String(""),
- HealthMonitorConfig: &pb.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(true),
- LoggingFluentBitEnabled: proto.Bool(true),
- },
- },
- &pb.InstanceConfig{
- MetricsEnabled: proto.Bool(false),
- UpdateStrategy: proto.String(""),
- HealthMonitorConfig: &pb.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(true),
- LoggingFluentBitEnabled: proto.Bool(true),
- MonitoringEnabled: proto.Bool(false),
+ Enforced: proto.Bool(true),
+ LoggingEnabled: proto.Bool(true),
+ MonitoringEnabled: proto.Bool(false),
},
},
},
@@ -668,10 +640,9 @@
MetricsEnabled: proto.Bool(false),
UpdateStrategy: proto.String(""),
HealthMonitorConfig: &pb.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(false),
- LoggingFluentBitEnabled: proto.Bool(true),
- MonitoringEnabled: proto.Bool(false),
+ Enforced: proto.Bool(true),
+ LoggingEnabled: proto.Bool(false),
+ MonitoringEnabled: proto.Bool(false),
},
},
},
@@ -688,52 +659,9 @@
MetricsEnabled: proto.Bool(false),
UpdateStrategy: proto.String(""),
HealthMonitorConfig: &pb.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(true),
- LoggingFluentBitEnabled: proto.Bool(true),
- MonitoringEnabled: proto.Bool(true),
- },
- },
- },
- {
- "BaseConfigEnableLoggingFluentBitAndMonitoring",
- &pb.InstanceConfig{
- HealthMonitorConfig: &pb.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(true),
- LoggingFluentBitEnabled: proto.Bool(true),
- MonitoringEnabled: proto.Bool(true),
- },
- },
- &pb.InstanceConfig{
- MetricsEnabled: proto.Bool(false),
- UpdateStrategy: proto.String(""),
- HealthMonitorConfig: &pb.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(true),
- LoggingFluentBitEnabled: proto.Bool(true),
- MonitoringEnabled: proto.Bool(true),
- },
- },
- },
- {
- "BaseConfigEnableLoggingFluentBitNoLogging",
- &pb.InstanceConfig{
- HealthMonitorConfig: &pb.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(false),
- LoggingFluentBitEnabled: proto.Bool(true),
- MonitoringEnabled: proto.Bool(true),
- },
- },
- &pb.InstanceConfig{
- MetricsEnabled: proto.Bool(false),
- UpdateStrategy: proto.String(""),
- HealthMonitorConfig: &pb.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(false),
- LoggingFluentBitEnabled: proto.Bool(true),
- MonitoringEnabled: proto.Bool(true),
+ Enforced: proto.Bool(true),
+ LoggingEnabled: proto.Bool(true),
+ MonitoringEnabled: proto.Bool(true),
},
},
},
diff --git a/pkg/devicepolicy/policy_util_test.go b/pkg/devicepolicy/policy_util_test.go
index 308e4d3..f1ae737 100644
--- a/pkg/devicepolicy/policy_util_test.go
+++ b/pkg/devicepolicy/policy_util_test.go
@@ -44,10 +44,9 @@
UpdateStrategy: instanceConfig.UpdateStrategy,
MetricsEnabled: instanceConfig.MetricsEnabled,
HealthMonitorConfig: &pmpb.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(true),
- LoggingFluentBitEnabled: proto.Bool(false),
- MonitoringEnabled: proto.Bool(false),
+ Enforced: proto.Bool(true),
+ LoggingEnabled: proto.Bool(true),
+ MonitoringEnabled: proto.Bool(false),
},
},
},
@@ -59,10 +58,9 @@
UpdateStrategy: instanceConfig.UpdateStrategy,
MetricsEnabled: instanceConfig.MetricsEnabled,
HealthMonitorConfig: &pmpb.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(true),
- LoggingFluentBitEnabled: proto.Bool(false),
- MonitoringEnabled: proto.Bool(false),
+ Enforced: proto.Bool(true),
+ LoggingEnabled: proto.Bool(true),
+ MonitoringEnabled: proto.Bool(false),
},
},
},
@@ -278,10 +276,9 @@
UpdateStrategy: instanceConfig.UpdateStrategy,
MetricsEnabled: instanceConfig.MetricsEnabled,
HealthMonitorConfig: &pmpb.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(true),
- LoggingFluentBitEnabled: proto.Bool(false),
- MonitoringEnabled: proto.Bool(false),
+ Enforced: proto.Bool(true),
+ LoggingEnabled: proto.Bool(true),
+ MonitoringEnabled: proto.Bool(false),
},
}
if !proto.Equal(fakePolicy.instanceConfig, expectInstanceConfig) {
diff --git a/pkg/policyenforcer/policy_enforcer.go b/pkg/policyenforcer/policy_enforcer.go
index 2c8dd64..4cfbc15 100644
--- a/pkg/policyenforcer/policy_enforcer.go
+++ b/pkg/policyenforcer/policy_enforcer.go
@@ -16,7 +16,6 @@
import (
"errors"
- "runtime"
"policy-manager/pkg/devicepolicy"
"policy-manager/pkg/systemd"
@@ -93,34 +92,11 @@
}
}
- // This logic is only here for the transition period where we support both stackdriver and
- // fluent-bit.
- // TODO(b/263142613): Remove this logic when stackdriver is no longer supported
- if runtime.GOARCH == "amd64" {
- shouldLoggingFluentBitEnabled := config.HealthMonitorConfig.GetLoggingEnabled() && config.HealthMonitorConfig.GetLoggingFluentBitEnabled()
- if serviceStatus.GetLoggingFluentBit() != shouldLoggingFluentBitEnabled {
- if err := startOrStopUnit(client.systemdClient,
- serviceMonitor["loggingServiceFluentBit"], shouldLoggingFluentBitEnabled); err != nil {
- glog.Error(err)
- updateStateErr = true
- }
- }
-
- shouldLegacyLoggingEnabled := config.HealthMonitorConfig.GetLoggingEnabled() && !config.HealthMonitorConfig.GetLoggingFluentBitEnabled()
- if serviceStatus.GetLogging() != shouldLegacyLoggingEnabled {
- if err := startOrStopUnit(client.systemdClient,
- serviceMonitor["loggingService"], shouldLegacyLoggingEnabled); err != nil {
- glog.Error(err)
- updateStateErr = true
- }
- }
- } else {
- if serviceStatus.GetLogging() != config.HealthMonitorConfig.GetLoggingEnabled() {
- if err := startOrStopUnit(client.systemdClient,
- serviceMonitor["loggingService"], config.HealthMonitorConfig.GetLoggingEnabled()); err != nil {
- glog.Error(err)
- updateStateErr = true
- }
+ if serviceStatus.GetLogging() != config.HealthMonitorConfig.GetLoggingEnabled() {
+ if err := startOrStopUnit(client.systemdClient,
+ serviceMonitor["loggingService"], config.HealthMonitorConfig.GetLoggingEnabled()); err != nil {
+ glog.Error(err)
+ updateStateErr = true
}
}
@@ -175,14 +151,6 @@
ServiceStatus.Logging = proto.Bool(isRunning)
}
- isRunning, err = client.systemdClient.IsUnitActiveRunning(serviceMonitor["loggingServiceFluentBit"])
- if err != nil {
- glog.Error(err)
- statusErr = true
- } else {
- ServiceStatus.LoggingFluentBit = proto.Bool(isRunning)
- }
-
isRunning, err = client.systemdClient.IsUnitActiveRunning(serviceMonitor["monitoringService"])
if err != nil {
glog.Error(err)
diff --git a/pkg/policyenforcer/policy_enforcer_test.go b/pkg/policyenforcer/policy_enforcer_test.go
index d892366..b5da283 100644
--- a/pkg/policyenforcer/policy_enforcer_test.go
+++ b/pkg/policyenforcer/policy_enforcer_test.go
@@ -50,42 +50,38 @@
return cosDevicePolicyBytes
}
-// TestUpdateServiceState checks the update made to the services. It
+// TestUpdateServiceState cheecks the update made to the services. It
// updates the status of the desired services.
func TestUpdateServiceState(t *testing.T) {
tests := []struct {
- name string
- onDiskConfig *protos.InstanceConfig
- getConfigErr error
- getStatusErr error
- isMetricsEnabled bool
- isUpdateEnabled bool
- isLogging bool
- isLoggingFluentBit bool
- isMonitoring bool
- expectChangeMetricsErr error
- expectChangeUpdateStrategyErr error
- expectChangeLoggingErr error
- expectChangeLoggingFluentBitErr error
- expectChangeMonitoringErr error
- expectErr bool
+ name string
+ onDiskConfig *protos.InstanceConfig
+ getConfigErr error
+ getStatusErr error
+ isMetricsEnabled bool
+ isUpdateEnabled bool
+ isLogging bool
+ isMonitoring bool
+ expectChangeMetricsErr error
+ expectChangeUpdateStrategyErr error
+ expectChangeLoggingErr error
+ expectChangeMonitoringErr error
+ expectErr bool
}{
{
- name: "NoEnforcement",
- onDiskConfig: &protos.InstanceConfig{},
- getConfigErr: nil,
- getStatusErr: nil,
- isMetricsEnabled: true,
- isUpdateEnabled: true,
- isLogging: true,
- isLoggingFluentBit: false,
- isMonitoring: true,
- expectChangeMetricsErr: nil,
- expectChangeUpdateStrategyErr: nil,
- expectChangeLoggingErr: nil,
- expectChangeLoggingFluentBitErr: nil,
- expectChangeMonitoringErr: nil,
- expectErr: false,
+ name: "NoEnforcement",
+ onDiskConfig: &protos.InstanceConfig{},
+ getConfigErr: nil,
+ getStatusErr: nil,
+ isMetricsEnabled: true,
+ isUpdateEnabled: true,
+ isLogging: true,
+ isMonitoring: true,
+ expectChangeMetricsErr: nil,
+ expectChangeUpdateStrategyErr: nil,
+ expectChangeLoggingErr: nil,
+ expectChangeMonitoringErr: nil,
+ expectErr: false,
},
{
name: "TurnOnLogging",
@@ -95,61 +91,34 @@
LoggingEnabled: proto.Bool(true),
},
},
- getConfigErr: nil,
- getStatusErr: nil,
- isMetricsEnabled: false,
- isUpdateEnabled: false,
- isLogging: false,
- isLoggingFluentBit: false,
- isMonitoring: false,
- expectChangeMetricsErr: nil,
- expectChangeUpdateStrategyErr: nil,
- expectChangeLoggingErr: nil,
- expectChangeLoggingFluentBitErr: nil,
- expectChangeMonitoringErr: nil,
- expectErr: false,
- },
- {
- name: "TurnOnLoggingWithFluentBit",
- onDiskConfig: &protos.InstanceConfig{
- HealthMonitorConfig: &protos.HealthMonitorConfig{
- Enforced: proto.Bool(true),
- LoggingEnabled: proto.Bool(true),
- LoggingFluentBitEnabled: proto.Bool(true),
- },
- },
- getConfigErr: nil,
- getStatusErr: nil,
- isMetricsEnabled: false,
- isUpdateEnabled: false,
- isLogging: false,
- isLoggingFluentBit: false,
- isMonitoring: false,
- expectChangeMetricsErr: nil,
- expectChangeUpdateStrategyErr: nil,
- expectChangeLoggingErr: nil,
- expectChangeLoggingFluentBitErr: nil,
- expectChangeMonitoringErr: nil,
- expectErr: false,
+ getConfigErr: nil,
+ getStatusErr: nil,
+ isMetricsEnabled: false,
+ isUpdateEnabled: false,
+ isLogging: false,
+ isMonitoring: false,
+ expectChangeMetricsErr: nil,
+ expectChangeUpdateStrategyErr: nil,
+ expectChangeLoggingErr: nil,
+ expectChangeMonitoringErr: nil,
+ expectErr: false,
},
{
name: "TurnOffUpdate",
onDiskConfig: &protos.InstanceConfig{
UpdateStrategy: proto.String("update_disabled"),
},
- getConfigErr: nil,
- getStatusErr: nil,
- isMetricsEnabled: false,
- isUpdateEnabled: true,
- isLogging: false,
- isLoggingFluentBit: false,
- isMonitoring: false,
- expectChangeMetricsErr: nil,
- expectChangeUpdateStrategyErr: nil,
- expectChangeLoggingErr: nil,
- expectChangeLoggingFluentBitErr: nil,
- expectChangeMonitoringErr: nil,
- expectErr: false,
+ getConfigErr: nil,
+ getStatusErr: nil,
+ isMetricsEnabled: false,
+ isUpdateEnabled: true,
+ isLogging: false,
+ isMonitoring: false,
+ expectChangeMetricsErr: nil,
+ expectChangeUpdateStrategyErr: nil,
+ expectChangeLoggingErr: nil,
+ expectChangeMonitoringErr: nil,
+ expectErr: false,
},
{
name: "TurnOnMonitoringTurnOffLoggingTurnOffMetrics",
@@ -159,19 +128,17 @@
MonitoringEnabled: proto.Bool(true),
},
},
- getConfigErr: nil,
- getStatusErr: nil,
- isMetricsEnabled: true,
- isUpdateEnabled: false,
- isLogging: true,
- isLoggingFluentBit: false,
- isMonitoring: false,
- expectChangeMetricsErr: nil,
- expectChangeUpdateStrategyErr: nil,
- expectChangeLoggingErr: nil,
- expectChangeLoggingFluentBitErr: nil,
- expectChangeMonitoringErr: nil,
- expectErr: false,
+ getConfigErr: nil,
+ getStatusErr: nil,
+ isMetricsEnabled: true,
+ isUpdateEnabled: false,
+ isLogging: true,
+ isMonitoring: false,
+ expectChangeMetricsErr: nil,
+ expectChangeUpdateStrategyErr: nil,
+ expectChangeLoggingErr: nil,
+ expectChangeMonitoringErr: nil,
+ expectErr: false,
},
{
name: "TurnOnMetricsAndUpdate",
@@ -179,36 +146,32 @@
MetricsEnabled: proto.Bool(true),
UpdateStrategy: proto.String(""),
},
- getConfigErr: nil,
- getStatusErr: nil,
- isMetricsEnabled: false,
- isUpdateEnabled: true,
- isLogging: false,
- isLoggingFluentBit: false,
- isMonitoring: false,
- expectChangeMetricsErr: nil,
- expectChangeUpdateStrategyErr: nil,
- expectChangeLoggingErr: nil,
- expectChangeLoggingFluentBitErr: nil,
- expectChangeMonitoringErr: nil,
- expectErr: false,
+ getConfigErr: nil,
+ getStatusErr: nil,
+ isMetricsEnabled: false,
+ isUpdateEnabled: true,
+ isLogging: false,
+ isMonitoring: false,
+ expectChangeMetricsErr: nil,
+ expectChangeUpdateStrategyErr: nil,
+ expectChangeLoggingErr: nil,
+ expectChangeMonitoringErr: nil,
+ expectErr: false,
},
{
- name: "NoDiskConfig",
- onDiskConfig: nil,
- getConfigErr: errors.New("error"),
- getStatusErr: nil,
- isMetricsEnabled: false,
- isUpdateEnabled: false,
- isLogging: false,
- isLoggingFluentBit: false,
- isMonitoring: false,
- expectChangeMetricsErr: nil,
- expectChangeUpdateStrategyErr: nil,
- expectChangeLoggingErr: nil,
- expectChangeLoggingFluentBitErr: nil,
- expectChangeMonitoringErr: nil,
- expectErr: true,
+ name: "NoDiskConfig",
+ onDiskConfig: nil,
+ getConfigErr: errors.New("error"),
+ getStatusErr: nil,
+ isMetricsEnabled: false,
+ isUpdateEnabled: false,
+ isLogging: false,
+ isMonitoring: false,
+ expectChangeMetricsErr: nil,
+ expectChangeUpdateStrategyErr: nil,
+ expectChangeLoggingErr: nil,
+ expectChangeMonitoringErr: nil,
+ expectErr: true,
},
{
name: "ErrorWhenTurnOnMetricsFails",
@@ -220,19 +183,17 @@
MonitoringEnabled: proto.Bool(true),
},
},
- getConfigErr: nil,
- getStatusErr: nil,
- isMetricsEnabled: false,
- isUpdateEnabled: false,
- isLogging: false,
- isLoggingFluentBit: false,
- isMonitoring: false,
- expectChangeMetricsErr: errors.New("error"),
- expectChangeUpdateStrategyErr: nil,
- expectChangeLoggingErr: nil,
- expectChangeLoggingFluentBitErr: nil,
- expectChangeMonitoringErr: nil,
- expectErr: true,
+ getConfigErr: nil,
+ getStatusErr: nil,
+ isMetricsEnabled: false,
+ isUpdateEnabled: false,
+ isLogging: false,
+ isMonitoring: false,
+ expectChangeMetricsErr: errors.New("error"),
+ expectChangeUpdateStrategyErr: nil,
+ expectChangeLoggingErr: nil,
+ expectChangeMonitoringErr: nil,
+ expectErr: true,
},
{
name: "ErrorWhenTurnOnLoggingWontAffectMonitoring",
@@ -243,19 +204,17 @@
MonitoringEnabled: proto.Bool(true),
},
},
- getConfigErr: nil,
- getStatusErr: nil,
- isMetricsEnabled: true,
- isUpdateEnabled: false,
- isLogging: false,
- isLoggingFluentBit: false,
- isMonitoring: false,
- expectChangeMetricsErr: nil,
- expectChangeUpdateStrategyErr: nil,
- expectChangeLoggingErr: errors.New("error"),
- expectChangeLoggingFluentBitErr: nil,
- expectChangeMonitoringErr: nil,
- expectErr: true,
+ getConfigErr: nil,
+ getStatusErr: nil,
+ isMetricsEnabled: true,
+ isUpdateEnabled: false,
+ isLogging: false,
+ isMonitoring: false,
+ expectChangeMetricsErr: nil,
+ expectChangeUpdateStrategyErr: nil,
+ expectChangeLoggingErr: errors.New("error"),
+ expectChangeMonitoringErr: nil,
+ expectErr: true,
},
}
for _, test := range tests {
@@ -271,11 +230,10 @@
defer os.RemoveAll(tmpCosDevicePolicyFile)
serviceMonitor := map[string]string{
- "loggingService": fmt.Sprintf("%s,%t,%v", "logging.service", test.isLogging, test.expectChangeLoggingErr),
- "loggingServiceFluentBit": fmt.Sprintf("%s,%t,%v", "logging-fluentbit.service", test.isLoggingFluentBit, test.expectChangeLoggingFluentBitErr),
- "monitoringService": fmt.Sprintf("%s,%t,%v", "monitoring.service", test.isMonitoring, test.expectChangeMonitoringErr),
- "metricsService": fmt.Sprintf("%s,%t,%v", "metrics.service", test.isMetricsEnabled, test.expectChangeMetricsErr),
- "updateService": fmt.Sprintf("%s,%t,%v", "update.service", test.isUpdateEnabled, test.expectChangeUpdateStrategyErr),
+ "loggingService": fmt.Sprintf("%s,%t,%v", "logging.service", test.isLogging, test.expectChangeLoggingErr),
+ "monitoringService": fmt.Sprintf("%s,%t,%v", "monitoring.service", test.isMonitoring, test.expectChangeMonitoringErr),
+ "metricsService": fmt.Sprintf("%s,%t,%v", "metrics.service", test.isMetricsEnabled, test.expectChangeMetricsErr),
+ "updateService": fmt.Sprintf("%s,%t,%v", "update.service", test.isUpdateEnabled, test.expectChangeUpdateStrategyErr),
}
client := NewPolicyEnforcer(*fakeSystemdClient)
@@ -306,8 +264,6 @@
checkUpdateDisabledError error
isLogging bool
checkLoggingErr error
- isLoggingFluentBit bool
- checkLoggingFluentBitErr error
isMonitoring bool
checkMonitoringErr error
expectedStatus *protos.ServiceStatus
@@ -321,16 +277,13 @@
checkUpdateDisabledError: nil,
isLogging: false,
checkLoggingErr: nil,
- isLoggingFluentBit: false,
- checkLoggingFluentBitErr: nil,
isMonitoring: false,
checkMonitoringErr: nil,
expectedStatus: &protos.ServiceStatus{
- UpdateEngine: proto.String("update_disabled"),
- Metrics: proto.Bool(false),
- Logging: proto.Bool(false),
- LoggingFluentBit: proto.Bool(false),
- Monitoring: proto.Bool(false),
+ UpdateEngine: proto.String("update_disabled"),
+ Metrics: proto.Bool(false),
+ Logging: proto.Bool(false),
+ Monitoring: proto.Bool(false),
},
expectErr: false,
},
@@ -342,16 +295,13 @@
checkUpdateDisabledError: nil,
isLogging: true,
checkLoggingErr: nil,
- isLoggingFluentBit: false,
- checkLoggingFluentBitErr: nil,
isMonitoring: true,
checkMonitoringErr: nil,
expectedStatus: &protos.ServiceStatus{
- UpdateEngine: proto.String(""),
- Metrics: proto.Bool(true),
- Logging: proto.Bool(true),
- LoggingFluentBit: proto.Bool(false),
- Monitoring: proto.Bool(true),
+ UpdateEngine: proto.String(""),
+ Metrics: proto.Bool(true),
+ Logging: proto.Bool(true),
+ Monitoring: proto.Bool(true),
},
expectErr: false,
},
@@ -363,15 +313,12 @@
checkUpdateDisabledError: nil,
isLogging: true,
checkLoggingErr: nil,
- isLoggingFluentBit: false,
- checkLoggingFluentBitErr: nil,
isMonitoring: false,
checkMonitoringErr: nil,
expectedStatus: &protos.ServiceStatus{
- UpdateEngine: proto.String(""),
- Logging: proto.Bool(true),
- LoggingFluentBit: proto.Bool(false),
- Monitoring: proto.Bool(false),
+ UpdateEngine: proto.String(""),
+ Logging: proto.Bool(true),
+ Monitoring: proto.Bool(false),
},
expectErr: true,
},
@@ -383,15 +330,12 @@
checkUpdateDisabledError: errors.New("error"),
isLogging: true,
checkLoggingErr: nil,
- isLoggingFluentBit: false,
- checkLoggingFluentBitErr: nil,
isMonitoring: false,
checkMonitoringErr: nil,
expectedStatus: &protos.ServiceStatus{
- Metrics: proto.Bool(true),
- Logging: proto.Bool(true),
- LoggingFluentBit: proto.Bool(false),
- Monitoring: proto.Bool(false),
+ Metrics: proto.Bool(true),
+ Logging: proto.Bool(true),
+ Monitoring: proto.Bool(false),
},
expectErr: true,
},
@@ -403,102 +347,16 @@
checkUpdateDisabledError: nil,
isLogging: false,
checkLoggingErr: errors.New("error"),
- isLoggingFluentBit: false,
- checkLoggingFluentBitErr: nil,
- isMonitoring: true,
- checkMonitoringErr: nil,
- expectedStatus: &protos.ServiceStatus{
- UpdateEngine: proto.String(""),
- Metrics: proto.Bool(true),
- LoggingFluentBit: proto.Bool(false),
- Monitoring: proto.Bool(true),
- },
- expectErr: true,
- },
- {
- name: "CheckFluentBitLoggingServiceFailed",
- isMetricsEnabled: true,
- checkMetricsErr: nil,
- isUpdateDisabled: true,
- checkUpdateDisabledError: nil,
- isLogging: false,
- checkLoggingErr: nil,
- isLoggingFluentBit: false,
- checkLoggingFluentBitErr: errors.New("error"),
isMonitoring: true,
checkMonitoringErr: nil,
expectedStatus: &protos.ServiceStatus{
UpdateEngine: proto.String(""),
Metrics: proto.Bool(true),
- Logging: proto.Bool(false),
Monitoring: proto.Bool(true),
},
expectErr: true,
},
{
- name: "CheckFluentBitEnabledLoggingEnabled",
- isMetricsEnabled: true,
- checkMetricsErr: nil,
- isUpdateDisabled: true,
- checkUpdateDisabledError: nil,
- isLogging: true,
- checkLoggingErr: nil,
- isLoggingFluentBit: true,
- checkLoggingFluentBitErr: nil,
- isMonitoring: true,
- checkMonitoringErr: nil,
- expectedStatus: &protos.ServiceStatus{
- UpdateEngine: proto.String(""),
- Metrics: proto.Bool(true),
- Logging: proto.Bool(true),
- LoggingFluentBit: proto.Bool(true),
- Monitoring: proto.Bool(true),
- },
- expectErr: false,
- },
- {
- name: "CheckFluentBitEnabledLoggingDisabled",
- isMetricsEnabled: true,
- checkMetricsErr: nil,
- isUpdateDisabled: true,
- checkUpdateDisabledError: nil,
- isLogging: false,
- checkLoggingErr: nil,
- isLoggingFluentBit: true,
- checkLoggingFluentBitErr: nil,
- isMonitoring: true,
- checkMonitoringErr: nil,
- expectedStatus: &protos.ServiceStatus{
- UpdateEngine: proto.String(""),
- Metrics: proto.Bool(true),
- Logging: proto.Bool(false),
- LoggingFluentBit: proto.Bool(true),
- Monitoring: proto.Bool(true),
- },
- expectErr: false,
- },
- {
- name: "CheckFluentBitDisabledLoggingDisabled",
- isMetricsEnabled: true,
- checkMetricsErr: nil,
- isUpdateDisabled: true,
- checkUpdateDisabledError: nil,
- isLogging: false,
- checkLoggingErr: nil,
- isLoggingFluentBit: false,
- checkLoggingFluentBitErr: nil,
- isMonitoring: true,
- checkMonitoringErr: nil,
- expectedStatus: &protos.ServiceStatus{
- UpdateEngine: proto.String(""),
- Metrics: proto.Bool(true),
- Logging: proto.Bool(false),
- LoggingFluentBit: proto.Bool(false),
- Monitoring: proto.Bool(true),
- },
- expectErr: false,
- },
- {
name: "CheckMonitoringServiceFailed",
isMetricsEnabled: true,
checkMetricsErr: nil,
@@ -506,15 +364,12 @@
checkUpdateDisabledError: nil,
isLogging: true,
checkLoggingErr: nil,
- isLoggingFluentBit: false,
- checkLoggingFluentBitErr: nil,
isMonitoring: false,
checkMonitoringErr: errors.New("error"),
expectedStatus: &protos.ServiceStatus{
- UpdateEngine: proto.String(""),
- Metrics: proto.Bool(true),
- Logging: proto.Bool(true),
- LoggingFluentBit: proto.Bool(false),
+ UpdateEngine: proto.String(""),
+ Metrics: proto.Bool(true),
+ Logging: proto.Bool(true),
},
expectErr: true,
},
@@ -526,11 +381,10 @@
fakeSystemdClient := systemd.NewSystemdClient(systemctlCmd)
serviceMonitor := map[string]string{
- "loggingService": fmt.Sprintf("%s,%t,%v", "logging.service", test.isLogging, test.checkLoggingErr),
- "loggingServiceFluentBit": fmt.Sprintf("%s,%t,%v", "logging-fluent-bit.service", test.isLoggingFluentBit, test.checkLoggingFluentBitErr),
- "monitoringService": fmt.Sprintf("%s,%t,%v", "monitoring.service", test.isMonitoring, test.checkMonitoringErr),
- "metricsService": fmt.Sprintf("%s,%t,%v", "metrics.service", test.isMetricsEnabled, test.checkMetricsErr),
- "updateService": fmt.Sprintf("%s,%t,%v", "update.service", test.isUpdateDisabled, test.checkUpdateDisabledError),
+ "loggingService": fmt.Sprintf("%s,%t,%v", "logging.service", test.isLogging, test.checkLoggingErr),
+ "monitoringService": fmt.Sprintf("%s,%t,%v", "monitoring.service", test.isMonitoring, test.checkMonitoringErr),
+ "metricsService": fmt.Sprintf("%s,%t,%v", "metrics.service", test.isMetricsEnabled, test.checkMetricsErr),
+ "updateService": fmt.Sprintf("%s,%t,%v", "update.service", test.isUpdateDisabled, test.checkUpdateDisabledError),
}
client := NewPolicyEnforcer(*fakeSystemdClient)
diff --git a/protos/instance_config.proto b/protos/instance_config.proto
index 56c582b..78cb8d7 100644
--- a/protos/instance_config.proto
+++ b/protos/instance_config.proto
@@ -23,6 +23,9 @@
// HealthMonitorConfig contains all the necessary fields for policy manager to store any
// information related to the configuration of HealthMonitor logging/monitoring.
message HealthMonitorConfig {
+ reserved 4;
+ reserved "logging_fluent_bit_enabled";
+
// enforced is set to true if policy manager should enforce the HealthMonitoring logging and
// monitoring to the instance.
optional bool enforced = 1;
@@ -34,9 +37,6 @@
// monitoring_enabled is set to true if the instance should report
// monitoring statistics to google cloud monitoring backend.
optional bool monitoring_enabled = 3;
-
- // used to enable fluent_bit as the logging agent instead of stackdriver
- optional bool logging_fluent_bit_enabled = 4;
}
// InstanceConfig contains the details necessary for configuring the instance.
diff --git a/protos/service_status.proto b/protos/service_status.proto
index 0dcac02..5e8af07 100644
--- a/protos/service_status.proto
+++ b/protos/service_status.proto
@@ -21,6 +21,9 @@
// ServiceStatus contains all the fields related to the current status of the
// instance.
message ServiceStatus {
+ reserved 7;
+ reserved "logging_fluent_bit";
+
// GCE instance ID.
optional uint64 instance_id = 1;
@@ -45,9 +48,5 @@
// are undefined.
optional string error = 6;
- // logging_fluent_bit is set to true if the fluent-bit systemd service
- // is active and running.
- optional bool logging_fluent_bit = 7;
-
// Next number: 8
}