forked from spiffe/spire
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log partial selectors from workload attestation on context cancellati…
…on (spiffe#4846) * Log partial selectors from workload attestation on context cancellation In the case when a client hangs up a connection to SPIRE Agent during workload attestation (e.g. timeout, process dies, etc.) while the agent is still discovering selectors from workload attestation plugins, it can be helpful to log whatever selectors the agent could find for debugging purposes. Today, only the pid is captured in logs in this case, which is often not enough information to trace back the caller since: - The caller process may have already died (e.g. crashlooping on startup) - pid alone is only useful if you can query the state of running processes on the host around the time of workload attestation (often not practical) Logging the partial set of selectors fetched by the agent before the caller hung up can help diagnose affected workloads in case a workload attestation plugin is misbehaving or a downstream dependency required by the plugin is down/not responding with accurate information. Signed-off-by: Ryan Turner <turner@uber.com>
- Loading branch information
Showing
6 changed files
with
133 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package fakeworkloadattestor | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
workloadattestorv1 "github.com/spiffe/spire-plugin-sdk/proto/spire/plugin/agent/workloadattestor/v1" | ||
"github.com/spiffe/spire/pkg/agent/plugin/workloadattestor" | ||
"github.com/spiffe/spire/pkg/common/catalog" | ||
"github.com/spiffe/spire/test/plugintest" | ||
) | ||
|
||
func NewTimeoutAttestor(t *testing.T, name string, c chan struct{}) workloadattestor.WorkloadAttestor { | ||
server := workloadattestorv1.WorkloadAttestorPluginServer(&timeoutWorkloadAttestor{ | ||
c: c, | ||
}) | ||
wa := new(workloadattestor.V1) | ||
plugintest.Load(t, catalog.MakeBuiltIn(name, server), wa) | ||
return wa | ||
} | ||
|
||
type timeoutWorkloadAttestor struct { | ||
workloadattestorv1.UnimplementedWorkloadAttestorServer | ||
|
||
c chan struct{} | ||
} | ||
|
||
func (twa *timeoutWorkloadAttestor) Attest(_ context.Context, _ *workloadattestorv1.AttestRequest) (*workloadattestorv1.AttestResponse, error) { | ||
// Block on channel until test sends signal | ||
<-twa.c | ||
return &workloadattestorv1.AttestResponse{}, nil | ||
} |