Skip to content

Commit 96676e1

Browse files
committed
Suppresses heartbeat related start-actual-lrp log messages to save log volume
Adds configuration to allow this feature to be enabled/disabled
1 parent 4e01df8 commit 96676e1

22 files changed

+287
-166
lines changed

cmd/bbs/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type BBSConfig struct {
3838
ConvergenceWorkers int `json:"convergence_workers,omitempty"`
3939
DatabaseConnectionString string `json:"database_connection_string"`
4040
DatabaseDriver string `json:"database_driver,omitempty"`
41+
DebugLRPStartHeartbeats bool `json:"debug_lrp_start_heartbeats,omitempty"`
4142
DesiredLRPCreationTimeout durationjson.Duration `json:"desired_lrp_creation_timeout,omitempty"`
4243
ExpireCompletedTaskDuration durationjson.Duration `json:"expire_completed_task_duration,omitempty"`
4344
ExpirePendingTaskDuration durationjson.Duration `json:"expire_pending_task_duration,omitempty"`

cmd/bbs/config/config_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var _ = Describe("BBSConfig", func() {
4040
"database_connection_string": "",
4141
"database_driver": "postgres",
4242
"debug_address": "127.0.0.1:17017",
43+
"debug_lrp_start_heartbeats":true,
4344
"desired_lrp_creation_timeout": "1m0s",
4445
"encryption_keys": {"label": "key"},
4546
"expire_completed_task_duration": "2m0s",
@@ -137,6 +138,7 @@ var _ = Describe("BBSConfig", func() {
137138
DebugServerConfig: debugserver.DebugServerConfig{
138139
DebugAddress: "127.0.0.1:17017",
139140
},
141+
DebugLRPStartHeartbeats: true,
140142
DesiredLRPCreationTimeout: durationjson.Duration(1 * time.Minute),
141143
EncryptionConfig: encryption.EncryptionConfig{
142144
ActiveKeyLabel: "label",

cmd/bbs/lrp_convergence_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ var _ = Describe("Convergence API", func() {
111111
clock.NewClock(),
112112
sqlRunner.DriverName(),
113113
metronClient,
114+
false,
114115
)
115116

116117
Eventually(func() models.ActualLRP_Presence {
@@ -176,6 +177,7 @@ var _ = Describe("Convergence API", func() {
176177
map[string]string{},
177178
false,
178179
"",
180+
false,
179181
)
180182
Expect(err).NotTo(HaveOccurred())
181183
})

cmd/bbs/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ func main() {
137137
clock,
138138
bbsConfig.DatabaseDriver,
139139
metronClient,
140+
bbsConfig.DebugLRPStartHeartbeats,
140141
)
141142
err = sqlDB.CreateConfigurationsTable(context.Background(), logger)
142143
if err != nil {

controllers/actual_lrp_lifecycle_controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,11 @@ func (h *ActualLRPLifecycleController) StartActualLRP(ctx context.Context,
132132
return nil
133133
}
134134

135+
isCurrentlyRunning := lrp != nil && lrp.State == models.ActualLRPStateRunning
136+
135137
// creates ordinary running actual LRP if it doesn't exist, otherwise updates
136138
// the existing ordinary actual LRP to running state
137-
before, after, err := h.db.StartActualLRP(ctx, logger, actualLRPKey, actualLRPInstanceKey, actualLRPNetInfo, actualLRPInternalRoutes, actualLRPMetricTags, routable, availabilityZone)
139+
before, after, err := h.db.StartActualLRP(ctx, logger, actualLRPKey, actualLRPInstanceKey, actualLRPNetInfo, actualLRPInternalRoutes, actualLRPMetricTags, routable, availabilityZone, isCurrentlyRunning)
138140
if err != nil {
139141
return err
140142
}

controllers/actual_lrp_lifecycle_controller_test.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ var _ = Describe("ActualLRP Lifecycle Controller", func() {
421421
Expect(fakeActualLRPDB.StartActualLRPCallCount()).To(Equal(1))
422422
Expect(fakeActualLRPDB.ActualLRPsCallCount()).To(Equal(1))
423423

424-
_, _, _, _, _, internalRoutesArgument, metricTagsArgument, routableArgument, availabilityZoneArgument := fakeActualLRPDB.StartActualLRPArgsForCall(0)
424+
_, _, _, _, _, internalRoutesArgument, metricTagsArgument, routableArgument, availabilityZoneArgument, _ := fakeActualLRPDB.StartActualLRPArgsForCall(0)
425425

426426
Expect(err).NotTo(HaveOccurred())
427427
Expect(internalRoutesArgument).To(Equal(internalRoutes))
@@ -532,11 +532,23 @@ var _ = Describe("ActualLRP Lifecycle Controller", func() {
532532
createdEvent := event.(*models.ActualLRPInstanceCreatedEvent)
533533
Expect(createdEvent.ActualLrp).To(Equal(afterActualLRP))
534534
})
535+
It("tells the db that a previous instance didn't exist", func() {
536+
err = controller.StartActualLRP(ctx, logger, &actualLRPKey, &afterInstanceKey, &netInfo, internalRoutes, metricTags, routable, availabilityZone)
537+
Expect(err).NotTo(HaveOccurred())
538+
539+
Expect(fakeActualLRPDB.StartActualLRPCallCount()).To(Equal(1))
540+
_, _, _, _, _, _, _, _, _, isRunning := fakeActualLRPDB.StartActualLRPArgsForCall(0)
541+
Expect(isRunning).To(BeFalse())
542+
})
535543
})
536544

537545
Context("when the actual lrp was updated", func() {
546+
JustBeforeEach(func() {
547+
actualLRP.State = models.ActualLRPStateRunning
548+
fakeActualLRPDB.ActualLRPsReturns([]*models.ActualLRP{actualLRP}, nil)
549+
})
538550
It("emits a change event to the hub", func() {
539-
err = controller.StartActualLRP(ctx, logger, &actualLRPKey, &afterInstanceKey, &netInfo, internalRoutes, metricTags, routable, availabilityZone)
551+
err = controller.StartActualLRP(ctx, logger, &actualLRPKey, &beforeInstanceKey, &netInfo, internalRoutes, metricTags, routable, availabilityZone)
540552
Eventually(actualHub.EmitCallCount).Should(Equal(1))
541553
event := actualHub.EmitArgsForCall(0)
542554
//lint:ignore SA1019 - calling deprecated model while unit testing deprecated method
@@ -547,6 +559,14 @@ var _ = Describe("ActualLRP Lifecycle Controller", func() {
547559
//lint:ignore SA1019 - still need to emit these events until the ActaulLRPGroup api is deleted
548560
Expect(changedEvent.After).To(Equal(afterActualLRP.ToActualLRPGroup()))
549561
})
562+
It("tells the db that a previous instance exists", func() {
563+
err = controller.StartActualLRP(ctx, logger, &actualLRPKey, &afterInstanceKey, &netInfo, internalRoutes, metricTags, routable, availabilityZone)
564+
Expect(err).NotTo(HaveOccurred())
565+
566+
Expect(fakeActualLRPDB.StartActualLRPCallCount()).To(Equal(1))
567+
_, _, _, _, _, _, _, _, _, isRunning := fakeActualLRPDB.StartActualLRPArgsForCall(0)
568+
Expect(isRunning).To(BeTrue())
569+
})
550570
})
551571

552572
Context("when Routable was updated", func() {

db/actual_lrp_db.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type ActualLRPDB interface {
2424
metricTags map[string]string,
2525
routable bool,
2626
availabilityZone string,
27+
isCurrentlyRunning bool,
2728
) (before *models.ActualLRP, after *models.ActualLRP, err error)
2829
CrashActualLRP(ctx context.Context, logger lager.Logger, key *models.ActualLRPKey, instanceKey *models.ActualLRPInstanceKey, crashReason string) (before *models.ActualLRP, after *models.ActualLRP, shouldRestart bool, err error)
2930
FailActualLRP(ctx context.Context, logger lager.Logger, key *models.ActualLRPKey, placementError string) (before *models.ActualLRP, after *models.ActualLRP, err error)

db/dbfakes/fake_actual_lrpdb.go

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

db/dbfakes/fake_db.go

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

0 commit comments

Comments
 (0)