Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: Shreyas Rao <[email protected]>
Signed-off-by: Swapnil Mhamane <[email protected]>
  • Loading branch information
Swapnil Mhamane and shreyas-s-rao committed Aug 8, 2019
1 parent 818e2ac commit 1cf5915
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func NewInitializeCommand(stopCh <-chan struct{}) *cobra.Command {
initializeEtcdFlags(initializeCmd)
initializeSnapstoreFlags(initializeCmd)
initializeValidatorFlags(initializeCmd)
initializeCmd.Flags().Int64Var(&failBelowRevision, "experimental-fail-below-revision", 0, "revision below which validation fails")
initializeCmd.Flags().Int64Var(&failBelowRevision, "experimental-fail-below-revision", 0, "minimum required etcd revision, below which validation fails")
return initializeCmd
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ func NewServerCommand(stopCh <-chan struct{}) *cobra.Command {

// startHTTPServer creates and starts the HTTP handler
// with status 503 (Service Unavailable)
func startHTTPServer(etcdInitializer *initializer.EtcdInitializer, ssr *snapshotter.Snapshotter) *server.HTTPHandler {
func startHTTPServer(initializer initializer.Initializer, ssr *snapshotter.Snapshotter) *server.HTTPHandler {
// Start http handler with Error state and wait till snapshotter is up
// and running before setting the status to OK.
handler := &server.HTTPHandler{
Port: port,
EtcdInitializer: *etcdInitializer,
Initializer: initializer,
Snapshotter: ssr,
Logger: logger,
Status: http.StatusServiceUnavailable,
Expand Down
2 changes: 1 addition & 1 deletion pkg/initializer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ type EtcdInitializer struct {

// Initializer is the interface for etcd initialization actions.
type Initializer interface {
Initialize(validator.Mode) error
Initialize(validator.Mode, int64) error
}
2 changes: 1 addition & 1 deletion pkg/initializer/validator/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
DataDirectoryError
// RevisionConsistencyError indicates current etcd revision is inconsistent with latest snapshot revision.
RevisionConsistencyError
//FailBelowRevisionConsistencyError indicate the current etcd revision is inconsistent with failBelowRevison.
//FailBelowRevisionConsistencyError indicates the current etcd revision is inconsistent with failBelowRevision.
FailBelowRevisionConsistencyError
)

Expand Down
6 changes: 3 additions & 3 deletions pkg/server/httpAPI.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const (

// HTTPHandler is implementation to handle HTTP API exposed by server
type HTTPHandler struct {
EtcdInitializer initializer.EtcdInitializer
Initializer initializer.Initializer
Snapshotter *snapshotter.Snapshotter
Port int
server *http.Server
Expand Down Expand Up @@ -174,15 +174,15 @@ func (h *HTTPHandler) serveInitialize(rw http.ResponseWriter, req *http.Request)
mode = validator.Full
}
h.Logger.Infof("Validation mode: %s", mode)
err := h.EtcdInitializer.Initialize(mode, failBelowRevision)
err := h.Initializer.Initialize(mode, failBelowRevision)
h.initializationStatusMutex.Lock()
defer h.initializationStatusMutex.Unlock()
if err != nil {
h.Logger.Errorf("Failed initialization: %v", err)
h.initializationStatus = initializationStatusFailed
return
}
h.Logger.Infof("Successfully initialized data directory \"%s\" for etcd.", h.EtcdInitializer.Validator.Config.DataDir)
h.Logger.Info("Successfully initialized data directory for etcd.")
h.initializationStatus = initializationStatusSuccessful
}()
}
Expand Down

0 comments on commit 1cf5915

Please sign in to comment.