Upgrade to the latest protobuf edition
This change has been verified to be behavior preserving both in the generated code and on the wire. The only potential changes are for code that uses syntax-dependent reflection. We've already migrated most of these to safer patterns, and are relying on TAP to catch any uncaught ones.
See go/protobuf-edition-zero-lsc for more information.
#busy-beavers
Tested:
Local presubmit tests failed.
Some test failures are present; the CL author decided to mail
PiperOrigin-RevId: 716229481
Change-Id: I49f8ef26a250515c89c3e8bdfbcd9d1aa94f9f0e
diff --git a/proto/safepower_agent.proto b/proto/safepower_agent.proto
index 3ac1091..fb4a05b 100644
--- a/proto/safepower_agent.proto
+++ b/proto/safepower_agent.proto
@@ -1,17 +1,22 @@
-syntax = "proto3";
+edition = "2023";
package safepower_agent_proto;
import "google/protobuf/timestamp.proto";
+option features.field_presence = IMPLICIT;
+
service SafepowerLocalAgent {
// Get a list of all supported actions
rpc GetSupportedActions(GetSupportedActionsRequest)
returns (GetSupportedActionsResponse) {}
+
// Execute an action when a condition is met
rpc StartAction(StartActionRequest) returns (StartActionResponse) {}
+
// Monitor reaction
rpc MonitorAction(MonitorActionRequest) returns (stream ActionStateLog) {}
+
// Monitor state.
rpc MonitorState(MonitorStateRequest) returns (stream SystemState) {}
}
@@ -25,8 +30,9 @@
// Identifies a component of the system whose state is monitored or acted upon.
message SystemComponent {
- optional string node_entity_tag = 1;
- optional string name = 2;
+ string node_entity_tag = 1 [features.field_presence = EXPLICIT];
+
+ string name = 2 [features.field_presence = EXPLICIT];
}
enum ActionType {
@@ -45,8 +51,10 @@
// LINT.IfChange(ActionFields)
message Action {
- optional ActionType action_type = 1; // Required
- optional ActionSeverity action_severity = 2;
+ ActionType action_type = 1 [features.field_presence = EXPLICIT]; // Required
+
+ ActionSeverity action_severity = 2 [features.field_presence = EXPLICIT];
+
// This may or may not correspond to an entry in SystemStatus reported by
// this node. For example, it is possible that the actuating node is not the
// same as the one that can get this status reliably.
@@ -56,13 +64,13 @@
message StartActionRequest {
// This is an informational string that can be used to identidfy the caller
- optional string caller_cookie = 1; // required
+ string caller_cookie = 1 [features.field_presence = EXPLICIT]; // required
+
// Wait for this condition before running the action. If the matching
// condition(s) specify that they should abort, the action will not be run. If
// unspecified, runs the action immediately.
- optional Condition precondition = 2;
-
- optional Action action = 3; // required
+ Condition precondition = 2;
+ Action action = 3; // required
// Wait until this condition is met. If matching conditions(s) specify that
// they should abort, the result will be an error.
@@ -70,14 +78,13 @@
}
message StartActionResponse {
- optional string response_id = 1;
+ string response_id = 1 [features.field_presence = EXPLICIT];
}
message Condition {
oneof condition_type {
AnyOfCondition any_of = 1;
AllOfCondition all_of = 2;
-
StateMatchedCondition state_condition = 3;
TimeoutCondition timeout = 4;
}
@@ -99,14 +106,17 @@
// This matches the keys in SystemState.node_state then
// NodeState.component_state
SystemComponent system_component = 1;
+
// Determine how to compare ComponentStates. Not all types may be applicable
// to all ComponentState.state types.
- optional ComparisonType comparison_type = 2;
+ ComparisonType comparison_type = 2 [features.field_presence = EXPLICIT];
+
// Ignored if matcher is COMPARISON_TYPE_CHANGED. Otherwise, the current state
// is compared to this state.
ComponentState component_state = 3;
+
// If true, the action will be aborted on match.
- optional bool abort = 4;
+ bool abort = 4 [features.field_presence = EXPLICIT];
}
enum ComparisonType {
@@ -125,21 +135,24 @@
uint64 timeout_ms = 1;
google.protobuf.Timestamp deadline = 2;
}
+
// If true, the action will be aborted on match.
- optional bool abort = 3;
+ bool abort = 3 [features.field_presence = EXPLICIT];
}
message MonitorActionRequest {
// This should be an ID returned in StartActionResponse
- optional string response_id = 1;
+ string response_id = 1 [features.field_presence = EXPLICIT];
}
message ActionStateLog {
// Included in all updates. This is a timestamp that is set at service start.
// This is mostly useful to detect service restarts.
- optional uint64 epoch_ms = 1; // required
+ uint64 epoch_ms = 1 [features.field_presence = EXPLICIT]; // required
+
repeated ActionStateChange history = 2;
- optional ActionState current_state = 3; // required
+ ActionState current_state = 3
+ [features.field_presence = EXPLICIT]; // required
}
enum ActionState {
@@ -153,20 +166,25 @@
}
message ActionStateChange {
- optional ActionState previous_state =
- 1; // Required except for transition to Init
+ ActionState previous_state = 1
+ [features.field_presence =
+ EXPLICIT]; // Required except for transition to Init
+
// Time when the state changed to the next state
google.protobuf.Timestamp changed_at = 2;
+
// Status of the operation that caused the state change
Status status = 3;
+
// Optional conditions that matched resulting in the state change. This is
// only present if the state change was because of a condition match.
repeated Condition matching_conditions = 4;
}
message Status {
- optional int64 code = 1;
- optional string message = 2;
+ int64 code = 1 [features.field_presence = EXPLICIT];
+
+ string message = 2 [features.field_presence = EXPLICIT];
}
message MonitorStateRequest {}
@@ -174,13 +192,15 @@
message SystemState {
// Included in all updates. This is a timestamp that is set at service start.
// This is mostly useful to detect service restarts.
- optional uint64 epoch_ms = 1; // required
+ uint64 epoch_ms = 1 [features.field_presence = EXPLICIT]; // required
+
// The contents are platform and node specific. Keys are node entity tags and
// values are state information for the corresponding node. This includes all
// nodes for which this node can obtain status. For example, an arena
// controller may have power state information for other nodes in the arena.
map<string, NodeState> node_state = 2;
}
+
message NodeState {
// The contents are platform and node specific. Keys are component names
// (service, subsystem, or other property like power state), values are the
@@ -197,13 +217,15 @@
BootState boot_state = 65;
ConnectionState connection_state = 66;
PowerState power_state = 67;
+
// add specific types for component types here
}
}
message DaemonState {
- optional uint32 restart_counter = 1;
- optional bool healthy = 2;
+ uint32 restart_counter = 1 [features.field_presence = EXPLICIT];
+
+ bool healthy = 2 [features.field_presence = EXPLICIT];
}
enum BootStateSpecifier {
@@ -214,13 +236,15 @@
}
message BootState {
- optional uint32 boot_counter = 1;
- optional uint64 uptime_ms = 2;
- optional BootStateSpecifier state = 3;
+ uint32 boot_counter = 1 [features.field_presence = EXPLICIT];
+
+ uint64 uptime_ms = 2 [features.field_presence = EXPLICIT];
+
+ BootStateSpecifier state = 3 [features.field_presence = EXPLICIT];
}
message ConnectionState {
- optional uint32 reconnect_counter = 1;
+ uint32 reconnect_counter = 1 [features.field_presence = EXPLICIT];
}
// Based on Redfish PowerState
@@ -234,7 +258,8 @@
}
message PowerState {
- optional PowerStateSpecifier state = 1;
- optional uint32 power_cycle_counter = 2;
+ PowerStateSpecifier state = 1 [features.field_presence = EXPLICIT];
+
+ uint32 power_cycle_counter = 2 [features.field_presence = EXPLICIT];
}
// LINT.ThenChange(//depot/state_fields.h:ComponentStateFields)
diff --git a/proto/safepower_agent_config.proto b/proto/safepower_agent_config.proto
index ff620ce..1325416 100644
--- a/proto/safepower_agent_config.proto
+++ b/proto/safepower_agent_config.proto
@@ -1,9 +1,11 @@
-syntax = "proto3";
+edition = "2023";
package safepower_agent_config;
import "safepower_agent.proto";
+option features.field_presence = IMPLICIT;
+
// shared configs
message SafePowerAgentConfig {
GpowerdConfig gpowerd_config = 1;
@@ -25,6 +27,7 @@
RedfishInfo redfish = 1;
DbusInfo dbus = 2;
}
+
uint32 collection_interval_ms = 3;
safepower_agent_proto.ComponentState prototype = 4;
}
@@ -44,6 +47,7 @@
message ActionConfig {
string action_name = 1;
safepower_agent_proto.Action action = 2;
+
oneof info {
RedfishAction redfish = 4;
DbusAction dbus = 5;
diff --git a/proto/state_persistence.proto b/proto/state_persistence.proto
index 5ad09c8..164cec2 100644
--- a/proto/state_persistence.proto
+++ b/proto/state_persistence.proto
@@ -1,9 +1,11 @@
-syntax = "proto3";
+edition = "2023";
package safepower_agent_persistence_proto;
import "safepower_agent.proto";
+option features.field_presence = IMPLICIT;
+
message SavedAction {
safepower_agent_proto.StartActionRequest original_request = 1;
safepower_agent_proto.ActionStateLog action_state_log = 2;