From 57dc4075c7e6d9dca9869df3ae965522768796d0 Mon Sep 17 00:00:00 2001 From: Ying Li Date: Wed, 2 Aug 2017 16:27:02 -0700 Subject: [PATCH] In the CA server, ensure we always have a cluster ID and just watch for changes of the only cluster we care about. Signed-off-by: Ying Li --- ca/server.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ca/server.go b/ca/server.go index a5feb179ce..1f3eb89f4f 100644 --- a/ca/server.go +++ b/ca/server.go @@ -87,7 +87,7 @@ func NewServer(store *store.MemoryStore, securityConfig *SecurityConfig) *Server started: make(chan struct{}), reconciliationRetryInterval: defaultReconciliationRetryInterval, rootReconciliationRetryInterval: defaultRootReconciliationInterval, - // clusterID will be set on every call to Run + clusterID: securityConfig.ClientTLSCreds.Organization(), } } @@ -440,29 +440,28 @@ func (s *Server) Run(ctx context.Context) error { var ( nodes []*api.Node cluster *api.Cluster + err error ) updates, cancel, err := store.ViewAndWatch( s.store, func(readTx store.ReadTx) error { - clusters, err := store.FindClusters(readTx, store.ByName(store.DefaultClusterName)) - if err != nil { - return err - } - if len(clusters) != 1 { + cluster = store.GetCluster(readTx, s.clusterID) + if cluster == nil { return errors.New("could not find cluster object") } - cluster = clusters[0] nodes, err = store.FindNodes(readTx, store.All) return err }, api.EventCreateNode{}, api.EventUpdateNode{}, api.EventDeleteNode{}, - api.EventUpdateCluster{}, + api.EventUpdateCluster{ + Cluster: &api.Cluster{ID: s.clusterID}, + Checks: []api.ClusterCheckFunc{api.ClusterCheckID}, + }, ) // call once to ensure that the join tokens and local/external CA signer are always set - s.clusterID = cluster.ID rootReconciler := &rootRotationReconciler{ ctx: log.WithField(ctx, "method", "(*Server).rootRotationReconciler"), clusterID: s.clusterID,