Skip to content

Commit

Permalink
Revert "add SVID check to agent health check (#5298)" in main branch (#…
Browse files Browse the repository at this point in the history
…5461)

This reverts commit 033d8d6.

Signed-off-by: Agustín Martínez Fayó <[email protected]>
  • Loading branch information
amartinezfayo authored Sep 4, 2024
1 parent bf6725d commit db42b6c
Showing 1 changed file with 10 additions and 29 deletions.
39 changes: 10 additions & 29 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ const (
)

type Agent struct {
c *Config
sto storage.Storage
c *Config
}

// Run the agent
Expand All @@ -57,8 +56,7 @@ func (a *Agent) Run(ctx context.Context) error {
return err
}

var err error
a.sto, err = storage.Open(a.c.DataDir)
sto, err := storage.Open(a.c.DataDir)
if err != nil {
return fmt.Errorf("failed to open storage: %w", err)
}
Expand Down Expand Up @@ -111,7 +109,7 @@ func (a *Agent) Run(ctx context.Context) error {
)

for {
as, err = a.attest(ctx, a.sto, cat, metrics, nodeAttestor)
as, err = a.attest(ctx, sto, cat, metrics, nodeAttestor)
if err == nil {
break
}
Expand All @@ -138,15 +136,15 @@ func (a *Agent) Run(ctx context.Context) error {
}
}
} else {
as, err = a.attest(ctx, a.sto, cat, metrics, nodeAttestor)
as, err = a.attest(ctx, sto, cat, metrics, nodeAttestor)
if err != nil {
return err
}
}

svidStoreCache := a.newSVIDStoreCache()

manager, err := a.newManager(ctx, a.sto, cat, metrics, as, svidStoreCache, nodeAttestor)
manager, err := a.newManager(ctx, sto, cat, metrics, as, svidStoreCache, nodeAttestor)
if err != nil {
return err
}
Expand Down Expand Up @@ -391,14 +389,11 @@ func (a *Agent) waitForTestDial(ctx context.Context) error {

// CheckHealth is used as a top-level health check for the agent.
func (a *Agent) CheckHealth() health.State {
err := errors.Join(
a.checkWorkloadAPI(),
a.checkSVID(),
)

// Both liveness and readiness checks verify that:
// - the workload API endpoint is available
// - the agent has an SVID
err := a.checkWorkloadAPI()

// Both liveness and readiness checks are done by
// agents ability to create new Workload API client
// for the X509SVID service.
// TODO: Better live check for agent.
return health.State{
Ready: err == nil,
Expand All @@ -412,20 +407,6 @@ func (a *Agent) CheckHealth() health.State {
}
}

func (a *Agent) checkSVID() error {
if a.sto == nil {
return errors.New("storage not initialized")
}
svid, _, err := a.sto.LoadSVID()
if err != nil {
return fmt.Errorf("loading SVID: %w", err)
}
if svid == nil {
return errors.New("SVID is nil")
}
return nil
}

func (a *Agent) checkWorkloadAPI() error {
clientOption, err := util.GetWorkloadAPIClientOption(a.c.BindAddress)
if err != nil {
Expand Down

0 comments on commit db42b6c

Please sign in to comment.