Skip to content

Commit

Permalink
Trident liveness probe should check for ACP only if it is enabled
Browse files Browse the repository at this point in the history
The purpose of this change is to ensure Trident's liveness probe does not spam logs if ACP is not enabled.
  • Loading branch information
rohit-arora-dev authored Dec 13, 2023
1 parent c921c8b commit d7aa500
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
10 changes: 7 additions & 3 deletions acp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ func newClient(restAPI REST, acpEnabled bool) TridentACP {
return &client{restAPI, acpEnabled}
}

func (c *client) Enabled() bool {
return c.acpEnabled
}

func (c *client) GetVersion(ctx context.Context) (*version.Version, error) {
Logc(ctx).Debug("Getting Trident-ACP version.")

if !c.acpEnabled {
if !c.Enabled() {
Logc(ctx).Debug("ACP is not enabled.")
return nil, errors.UnsupportedError("ACP is not enabled")
}
Expand All @@ -83,7 +87,7 @@ func (c *client) GetVersionWithBackoff(ctx context.Context) (*version.Version, e
var v *version.Version
var err error

if !c.acpEnabled {
if !c.Enabled() {
Logc(ctx).Debug("ACP is not enabled.")
return nil, errors.UnsupportedError("ACP is not enabled")
}
Expand Down Expand Up @@ -123,7 +127,7 @@ func (c *client) IsFeatureEnabled(ctx context.Context, feature string) error {
fields := LogFields{"feature": feature}
Logc(ctx).WithFields(fields).Debug("Checking if feature is enabled.")

if !c.acpEnabled {
if !c.Enabled() {
Logc(ctx).WithFields(fields).Warning("Feature requires Trident-ACP to be enabled.")
return errors.UnsupportedConfigError("acp is not enabled")
}
Expand Down
1 change: 1 addition & 0 deletions acp/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

// TridentACP is a set of methods for exposing Trident-ACP REST APIs to Trident.
type TridentACP interface {
Enabled() bool
GetVersion(context.Context) (*version.Version, error)
GetVersionWithBackoff(context.Context) (*version.Version, error)
IsFeatureEnabled(context.Context, string) error
Expand Down
4 changes: 4 additions & 0 deletions frontend/rest/controller_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ func GetVersion(w http.ResponseWriter, r *http.Request) {
}

func GetACPVersion(ctx context.Context) string {
if !acp.API().Enabled() {
return ""
}

version, err := acp.API().GetVersion(ctx)
if err != nil {
if !errors.IsUnsupportedError(err) {
Expand Down
14 changes: 14 additions & 0 deletions mocks/mock_acp/mock_acp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d7aa500

Please sign in to comment.