bot_scaling: Add lookback_hours for BotPolicy

Add a field to set the lookback number of hours for querying Swarming
stats.  This will allow the ability to set the size of the lookback
window when determining the start time for tasks.  Swarming querying
will only return tasks that have started within the lookback window,
therefore we need to support longer windows than the currently default
24 hours.

Bug: chromium:1027593
Change-Id: I631384d840bd88ea81bc1a15c1142ca4c1838d3c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/infra/proto/+/2146094
Commit-Queue: Mike Nichols <mikenichols@chromium.org>
Tested-by: Mike Nichols <mikenichols@chromium.org>
Reviewed-by: David Burger <dburger@chromium.org>
Reviewed-by: Sean Abraham <seanabraham@chromium.org>
diff --git a/go/chromiumos/bot_scaling.pb.go b/go/chromiumos/bot_scaling.pb.go
index 732d972..83edba9 100644
--- a/go/chromiumos/bot_scaling.pb.go
+++ b/go/chromiumos/bot_scaling.pb.go
@@ -193,10 +193,12 @@
 	// A set of dimensions used to validate current Swarming allocations.
 	SwarmingDimensions []*SwarmingDimension `protobuf:"bytes,5,rep,name=swarming_dimensions,json=swarmingDimensions,proto3" json:"swarming_dimensions,omitempty"`
 	// Set whether a bot group should be configured or only monitored.
-	PolicyMode           BotPolicy_Mode `protobuf:"varint,6,opt,name=policy_mode,json=policyMode,proto3,enum=chromiumos.BotPolicy_Mode" json:"policy_mode,omitempty"`
-	XXX_NoUnkeyedLiteral struct{}       `json:"-"`
-	XXX_unrecognized     []byte         `json:"-"`
-	XXX_sizecache        int32          `json:"-"`
+	PolicyMode BotPolicy_Mode `protobuf:"varint,6,opt,name=policy_mode,json=policyMode,proto3,enum=chromiumos.BotPolicy_Mode" json:"policy_mode,omitempty"`
+	// Number of hours to lookback for Swarming stats.
+	LookbackHours        int32    `protobuf:"zigzag32,7,opt,name=lookback_hours,json=lookbackHours,proto3" json:"lookback_hours,omitempty"`
+	XXX_NoUnkeyedLiteral struct{} `json:"-"`
+	XXX_unrecognized     []byte   `json:"-"`
+	XXX_sizecache        int32    `json:"-"`
 }
 
 func (m *BotPolicy) Reset()         { *m = BotPolicy{} }
@@ -266,6 +268,13 @@
 	return BotPolicy_UNKNOWN_MODE
 }
 
+func (m *BotPolicy) GetLookbackHours() int32 {
+	if m != nil {
+		return m.LookbackHours
+	}
+	return 0
+}
+
 // Scaling restriction specifies the limits on how the group can be
 // expanded or reduced.
 type BotPolicy_ScalingRestriction struct {
@@ -642,51 +651,53 @@
 func init() { proto.RegisterFile("chromiumos/bot_scaling.proto", fileDescriptor_dbe70eabfd64e7ef) }
 
 var fileDescriptor_dbe70eabfd64e7ef = []byte{
-	// 733 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x5d, 0x6f, 0xeb, 0x44,
-	0x10, 0xbd, 0xce, 0x27, 0x99, 0x34, 0x69, 0xee, 0x06, 0x90, 0x6f, 0x00, 0x11, 0x2c, 0x10, 0x79,
-	0x72, 0xa4, 0x80, 0x00, 0x09, 0xf1, 0x70, 0xf3, 0xd1, 0xdb, 0x08, 0xd5, 0x89, 0x36, 0xad, 0xa0,
-	0xf0, 0x60, 0xd9, 0xc9, 0xc6, 0x5d, 0x61, 0x7b, 0xcd, 0xae, 0x43, 0x69, 0xff, 0x13, 0xcf, 0xfc,
-	0x1d, 0x7e, 0x0a, 0xda, 0x8f, 0x34, 0x49, 0x93, 0x3e, 0x20, 0xf1, 0xe6, 0x39, 0x3b, 0x73, 0x76,
-	0x66, 0xce, 0xb1, 0x0d, 0x1f, 0x2f, 0xef, 0x38, 0x4b, 0xe8, 0x26, 0x61, 0xa2, 0x1f, 0xb2, 0xdc,
-	0x17, 0xcb, 0x20, 0xa6, 0x69, 0xe4, 0x66, 0x9c, 0xe5, 0x0c, 0xc1, 0xee, 0xd4, 0xb9, 0x84, 0xea,
-	0x90, 0xe5, 0xd7, 0x0f, 0x19, 0x41, 0x6f, 0xe0, 0x3d, 0x95, 0x4b, 0x1f, 0x89, 0x6d, 0x75, 0xad,
-	0x5e, 0x0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0xc6, 0x47,
+	0xe7, 0x50, 0xbf, 0xf5, 0x16, 0xf3, 0xc9, 0x68, 0x7a, 0x39, 0x9d, 0x8c, 0x5b, 0x2f, 0x50, 0x15,
+	0x8a, 0x6f, 0x26, 0x8b, 0x96, 0x85, 0x2a, 0x50, 0xf0, 0x66, 0xad, 0x82, 0x73, 0x03, 0x4d, 0xcc,
+	0x42, 0x36, 0xe2, 0x2c, 0x33, 0xc4, 0x86, 0x70, 0xbe, 0xfd, 0x13, 0xdb, 0x8e, 0xaf, 0x8d, 0xf0,
+	0xf2, 0xd9, 0xf1, 0x71, 0x53, 0xec, 0x87, 0x62, 0xf8, 0xdd, 0x6f, 0xdf, 0x46, 0xec, 0x31, 0xdd,
+	0x65, 0x3c, 0xea, 0xef, 0x7d, 0x28, 0x68, 0xba, 0xe6, 0x41, 0x5f, 0x7d, 0x22, 0xfa, 0x11, 0xdb,
+	0x3b, 0x09, 0x2b, 0x0a, 0xfc, 0xe6, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xed, 0xb0, 0x4f, 0x03,
+	0x57, 0x06, 0x00, 0x00,
 }
diff --git a/src/chromiumos/bot_scaling.proto b/src/chromiumos/bot_scaling.proto
index 848d264..99a340f 100644
--- a/src/chromiumos/bot_scaling.proto
+++ b/src/chromiumos/bot_scaling.proto
@@ -76,6 +76,8 @@
 
   // Set whether a bot group should be configured or only monitored.
   Mode policy_mode = 6;
+  // Number of hours to lookback for Swarming stats.
+  sint32 lookback_hours = 7;
 }
 
 // Configures the root message.