@@ -62,8 +62,6 @@ type Manager struct {
6262//
6363// The labels parameter defines what client labels the client should
6464// report to the server.
65- // TODO(b/297019580): Consider defining and consuming a more specific `ConfigManagerCollector`
66- // interface here, containing only the methods that Manager actually cares about.
6765func StartManager (cfg * config.Configuration , configChanges chan <- * fspb.ClientInfoData , c stats.ConfigManagerCollector ) (* Manager , error ) {
6866 if cfg == nil {
6967 return nil , errors .New ("configuration must be provided" )
@@ -107,7 +105,7 @@ func StartManager(cfg *config.Configuration, configChanges chan<- *fspb.ClientIn
107105 r .AddRevokedSerials (r .state .RevokedCertSerials )
108106 r .AddRevokedSerials (cfg .RevokedCertSerials )
109107
110- if r .state .ClientKey == nil {
108+ if len ( r .state .GetClientKey ()) == 0 {
111109 if err := r .Rekey (); err != nil {
112110 return nil , fmt .Errorf ("no key present, and %v" , err )
113111 }
@@ -120,6 +118,7 @@ func StartManager(cfg *config.Configuration, configChanges chan<- *fspb.ClientIn
120118 if err != nil {
121119 return nil , fmt .Errorf ("unable to create clientID: %v" , err )
122120 }
121+ r .stats .AfterKeyLoaded (r .id , false , nil )
123122 log .Infof ("Using client id: %v" , r .id )
124123 }
125124
@@ -143,8 +142,9 @@ func StartManager(cfg *config.Configuration, configChanges chan<- *fspb.ClientIn
143142
144143// Rekey creates a new private key and identity for the client.
145144func (m * Manager ) Rekey () (err error ) {
145+ var id common.ClientID
146146 defer func () {
147- m .stats .AfterRekey ( err )
147+ m .stats .AfterKeyLoaded ( id , true , err )
148148 }()
149149
150150 k , err := ecdsa .GenerateKey (elliptic .P256 (), rand .Reader )
@@ -155,7 +155,7 @@ func (m *Manager) Rekey() (err error) {
155155 if err != nil {
156156 return fmt .Errorf ("unable to marshal new key: %v" , err )
157157 }
158- id , err : = common .MakeClientID (k .Public ())
158+ id , err = common .MakeClientID (k .Public ())
159159 if err != nil {
160160 return fmt .Errorf ("unable to create client id: %v" , err )
161161 }
@@ -220,7 +220,7 @@ func (m *Manager) AddRevokedSerials(revoked [][]byte) {
220220 }
221221}
222222
223- // Stop shuts down the Manager, in particular it will stop sychronizing to the
223+ // Stop shuts down the Manager, in particular it will stop synchronizing to the
224224// writeback file.
225225func (m * Manager ) Stop () {
226226 if m .syncTicker != nil {
@@ -250,7 +250,7 @@ func (m *Manager) ClientID() common.ClientID {
250250// RecordRunningService adds name to the list of services which this client is
251251// currently running. This list will be included when sending a ClientInfo
252252// record to the server. The optional parameter sig should be set when the
253- // configuration was signed to emake it clear to the server which instance of
253+ // configuration was signed to make it clear to the server which instance of
254254// the service is running.
255255func (m * Manager ) RecordRunningService (name string , sig []byte ) {
256256 m .lock .Lock ()
0 commit comments