@@ -653,33 +653,38 @@ func (b *Bridge) modifySettings(req *request) (err error) {
653653 return nil
654654
655655 case guestresource .ResourceTypeCWCOWCombinedLayers :
656-
657- if modifyGuestSettingsRequest .RequestType == guestrequest .RequestTypeRemove {
658- return fmt .Errorf ("not implemented" )
659- }
660-
661656 settings := modifyGuestSettingsRequest .Settings .(* guestresource.CWCOWCombinedLayers )
662- containerID := settings .ContainerID
663- log .G (ctx ).Tracef ("CWCOWCombinedLayers:: ContainerID: %v, ContainerRootPath: %v, Layers: %v, ScratchPath: %v" ,
664- containerID , settings .CombinedLayers .ContainerRootPath , settings .CombinedLayers .Layers , settings .CombinedLayers .ScratchPath )
657+ switch modifyGuestSettingsRequest .RequestType {
658+ case guestrequest .RequestTypeAdd :
659+ containerID := settings .ContainerID
660+ log .G (ctx ).Tracef ("CWCOWCombinedLayers:: ContainerID: %v, ContainerRootPath: %v, Layers: %v, ScratchPath: %v" ,
661+ containerID , settings .CombinedLayers .ContainerRootPath , settings .CombinedLayers .Layers , settings .CombinedLayers .ScratchPath )
662+
663+ //Since unencrypted scratch is not an option, always pass true
664+ if err := b .hostState .securityPolicyEnforcer .EnforceScratchMountPolicy (ctx , settings .CombinedLayers .ContainerRootPath , true ); err != nil {
665+ return fmt .Errorf ("scratch mounting denied by policy: %w" , err )
666+ }
667+ // The following two folders are expected to be present in the scratch.
668+ // But since we have just formatted the scratch we would need to
669+ // create them manually.
670+ sandboxStateDirectory := filepath .Join (settings .CombinedLayers .ContainerRootPath , sandboxStateDirName )
671+ err = os .Mkdir (sandboxStateDirectory , 0777 )
672+ if err != nil {
673+ return fmt .Errorf ("failed to create sandboxStateDirectory: %w" , err )
674+ }
665675
666- //Since unencrypted scratch is not an option, always pass true
667- if err := b .hostState .securityPolicyEnforcer .EnforceScratchMountPolicy (ctx , settings .CombinedLayers .ContainerRootPath , true ); err != nil {
668- return fmt .Errorf ("scratch mounting denied by policy: %w" , err )
669- }
670- // The following two folders are expected to be present in the scratch.
671- // But since we have just formatted the scratch we would need to
672- // create them manually.
673- sandboxStateDirectory := filepath .Join (settings .CombinedLayers .ContainerRootPath , sandboxStateDirName )
674- err = os .Mkdir (sandboxStateDirectory , 0777 )
675- if err != nil {
676- return fmt .Errorf ("failed to create sandboxStateDirectory: %w" , err )
677- }
676+ hivesDirectory := filepath .Join (settings .CombinedLayers .ContainerRootPath , hivesDirName )
677+ err = os .Mkdir (hivesDirectory , 0777 )
678+ if err != nil {
679+ return fmt .Errorf ("failed to create hivesDirectory: %w" , err )
680+ }
681+
682+ case guestrequest .RequestTypeRemove :
683+ log .G (ctx ).Tracef ("CWCOWCombinedLayers: Remove" )
684+ if err := b .hostState .securityPolicyEnforcer .EnforceScratchUnmountPolicy (ctx , settings .CombinedLayers .ContainerRootPath ); err != nil {
685+ return fmt .Errorf ("scratch unmounting denied by policy: %w" , err )
686+ }
678687
679- hivesDirectory := filepath .Join (settings .CombinedLayers .ContainerRootPath , hivesDirName )
680- err = os .Mkdir (hivesDirectory , 0777 )
681- if err != nil {
682- return fmt .Errorf ("failed to create hivesDirectory: %w" , err )
683688 }
684689
685690 // Reconstruct WCOWCombinedLayers{} req before forwarding to GCS
0 commit comments