-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add memory monitor measurement logics #408
Add memory monitor measurement logics #408
Conversation
15808b4
to
cdd35d8
Compare
launcher/container_runner.go
Outdated
} | ||
|
||
var memoryMonitoringEnabledBit uint8 | ||
if status == "active" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also including "activating" status here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
launcher/container_runner.go
Outdated
// measureMemoryMonitor will measure the current memory monitoring state into the COS | ||
// eventlog in the AttestationAgent. | ||
func (r *ContainerRunner) measureMemoryMonitor(ctx context.Context) error { | ||
s, err := systemctl.New() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably don't need to create a new systemctl client here, you can try to pass it in as a parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, try to get the MemoryMonitor status outside of this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline, we should measure the memory monitoring decision made by container launcher.
Done.
cdd35d8
to
bfba9f6
Compare
abe77fe
to
4bf5512
Compare
EventType: cel.LaunchSeparatorType, | ||
EventContent: nil, // Success | ||
} | ||
return r.attestAgent.MeasureEvent(separator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily related to this PR, but we need a unit test to ensure the separator always gets measured. Since you moved this around, can you add one for measureCELEvents? Perhaps also ensure we get the workload digest and ID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we have a test for different launchspec inputs if that doesn't exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, created a fake container and fake container image to "fake" dependencies that measureCELEvents
need. Added a unit test to container_runnter_test.go
for different launchspec inputs.
@@ -42,6 +43,19 @@ func (s *Systemctl) Stop(unit string) error { | |||
return runSystemdCmd(s.dbus.StopUnitContext, "stop", unit) | |||
} | |||
|
|||
// GetStatus is the equivalent of `systemctl is-active $unit`. | |||
// The status can be "active", "activating", "deactivating", "inactive" or "failed". | |||
func (s *Systemctl) GetStatus(ctx context.Context, unit string) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this should be called IsActive
so that it matches the systemctl API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
6d816fb
to
f5c6251
Compare
f5c6251
to
1c542f2
Compare
launcher/container_runner_test.go
Outdated
} | ||
|
||
for _, wantEvent := range tc.wantCELEvents { | ||
if !slices.Contains(gotEvents, cel.CosType(wantEvent)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order matters here, at least for the separator which should be last. Use cmp.Equal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
launcher/container_runner.go
Outdated
if err := r.measureCELEvents(ctx); err != nil { | ||
return fmt.Errorf("failed to measure CEL events: %v", err) | ||
} | ||
|
||
if err := r.fetchAndWriteToken(ctx); err != nil { | ||
return fmt.Errorf("failed to fetch and write OIDC token: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Measurements should happen before experiments turn on and potentially introduce side effects. So please move this back to the beginning of Run
. We should measure first, and it's okay to enable memory monitoring after, even if it fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
launcher/container_runner_test.go
Outdated
}, | ||
{ | ||
name: "measure memory monitoring event and launch separator event", | ||
wantCELEvents: []cel.CosType{cel.LaunchSeparatorType, cel.MemoryMonitorType}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wantCELEvents
should have the separator last.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
34f61ae
to
07ce3e5
Compare
/gcbrun |
New Features: [launcher] Add TEE server IPC implementation google#367 [launcher] Enable memory monitoring in CS google#391 Use TDX quote provider to attest and verify google#405 Integrate nonce verification as part of the TDX quote validation procedure. google#395 Add RISC V support google#407 [launcher] Use resizable integrity-fs with in-memory tags google#412 Bug Fixes: [launcher] Fix launcher exit code google#384 [launcher] Handle exit code checking during deferral evaluation google#392 [cmd] Skip tests that call setGCEAKTemplate google#402 [launcher] Fix teeserver context reset issue & add container signature cache google#397 Set all unused parameters as _ to fix CI lint failure google#411 [launcher] Make customtoken test sleep to mitigate clock skew google#413 Other Changes: Add eventlog parse logics for memory monitoring google#404 [launcher]: Add memory monitor measurement logics google#408 Update go-tdx-guest version to v0.3.1 google#414 New Contributors: @KeithMoyer in google#392 @vbalain in google#405 @aimixsaka in google#407
New Features: [launcher] Add TEE server IPC implementation #367 [launcher] Enable memory monitoring in CS #391 Use TDX quote provider to attest and verify #405 Integrate nonce verification as part of the TDX quote validation procedure. #395 Add RISC V support #407 [launcher] Use resizable integrity-fs with in-memory tags #412 Bug Fixes: [launcher] Fix launcher exit code #384 [launcher] Handle exit code checking during deferral evaluation #392 [cmd] Skip tests that call setGCEAKTemplate #402 [launcher] Fix teeserver context reset issue & add container signature cache #397 Set all unused parameters as _ to fix CI lint failure #411 [launcher] Make customtoken test sleep to mitigate clock skew #413 Other Changes: Add eventlog parse logics for memory monitoring #404 [launcher]: Add memory monitor measurement logics #408 Update go-tdx-guest version to v0.3.1 #414 New Contributors: @KeithMoyer in #392 @vbalain in #405 @aimixsaka in #407
New Features: [launcher] Add TEE server IPC implementation google#367 [launcher] Enable memory monitoring in CS google#391 Use TDX quote provider to attest and verify google#405 Integrate nonce verification as part of the TDX quote validation procedure. google#395 Add RISC V support google#407 [launcher] Use resizable integrity-fs with in-memory tags google#412 Bug Fixes: [launcher] Fix launcher exit code google#384 [launcher] Handle exit code checking during deferral evaluation google#392 [cmd] Skip tests that call setGCEAKTemplate google#402 [launcher] Fix teeserver context reset issue & add container signature cache google#397 Set all unused parameters as _ to fix CI lint failure google#411 [launcher] Make customtoken test sleep to mitigate clock skew google#413 Other Changes: Add eventlog parse logics for memory monitoring google#404 [launcher]: Add memory monitor measurement logics google#408 Update go-tdx-guest version to v0.3.1 google#414 New Contributors: @KeithMoyer in google#392 @vbalain in google#405 @aimixsaka in google#407
This PR removes the existing experiment flag
EnableMemoryMonitoring
and add a new experiment flagEnableMeasureMemoryMonitor
to gate the memory monitoring measurement logics.