@@ -646,33 +646,37 @@ func (b *Bridge) modifySettings(req *request) (err error) {
646646 return nil
647647
648648 case guestresource .ResourceTypeCWCOWCombinedLayers :
649-
650- if modifyGuestSettingsRequest .RequestType == guestrequest .RequestTypeRemove {
651- return fmt .Errorf ("not implemented" )
652- }
653-
654649 settings := modifyGuestSettingsRequest .Settings .(* guestresource.CWCOWCombinedLayers )
655- containerID := settings .ContainerID
656- log .G (ctx ).Tracef ("CWCOWCombinedLayers:: ContainerID: %v, ContainerRootPath: %v, Layers: %v, ScratchPath: %v" ,
657- containerID , settings .CombinedLayers .ContainerRootPath , settings .CombinedLayers .Layers , settings .CombinedLayers .ScratchPath )
650+ switch modifyGuestSettingsRequest .RequestType {
651+ case guestrequest .RequestTypeAdd :
652+ containerID := settings .ContainerID
653+ log .G (ctx ).Tracef ("CWCOWCombinedLayers:: ContainerID: %v, ContainerRootPath: %v, Layers: %v, ScratchPath: %v" ,
654+ containerID , settings .CombinedLayers .ContainerRootPath , settings .CombinedLayers .Layers , settings .CombinedLayers .ScratchPath )
655+
656+ //Since unencrypted scratch is not an option, always pass true
657+ if err := b .hostState .securityOptions .PolicyEnforcer .EnforceScratchMountPolicy (ctx , settings .CombinedLayers .ContainerRootPath , true ); err != nil {
658+ return fmt .Errorf ("scratch mounting denied by policy: %w" , err )
659+ }
660+ // The following two folders are expected to be present in the scratch.
661+ // But since we have just formatted the scratch we would need to
662+ // create them manually.
663+ sandboxStateDirectory := filepath .Join (settings .CombinedLayers .ContainerRootPath , sandboxStateDirName )
664+ err = os .Mkdir (sandboxStateDirectory , 0777 )
665+ if err != nil {
666+ return fmt .Errorf ("failed to create sandboxStateDirectory: %w" , err )
667+ }
658668
659- //Since unencrypted scratch is not an option, always pass true
660- if err := b .hostState .securityOptions .PolicyEnforcer .EnforceScratchMountPolicy (ctx , settings .CombinedLayers .ContainerRootPath , true ); err != nil {
661- return fmt .Errorf ("scratch mounting denied by policy: %w" , err )
662- }
663- // The following two folders are expected to be present in the scratch.
664- // But since we have just formatted the scratch we would need to
665- // create them manually.
666- sandboxStateDirectory := filepath .Join (settings .CombinedLayers .ContainerRootPath , sandboxStateDirName )
667- err = os .Mkdir (sandboxStateDirectory , 0777 )
668- if err != nil {
669- return fmt .Errorf ("failed to create sandboxStateDirectory: %w" , err )
670- }
669+ hivesDirectory := filepath .Join (settings .CombinedLayers .ContainerRootPath , hivesDirName )
670+ err = os .Mkdir (hivesDirectory , 0777 )
671+ if err != nil {
672+ return fmt .Errorf ("failed to create hivesDirectory: %w" , err )
673+ }
671674
672- hivesDirectory := filepath .Join (settings .CombinedLayers .ContainerRootPath , hivesDirName )
673- err = os .Mkdir (hivesDirectory , 0777 )
674- if err != nil {
675- return fmt .Errorf ("failed to create hivesDirectory: %w" , err )
675+ case guestrequest .RequestTypeRemove :
676+ log .G (ctx ).Tracef ("CWCOWCombinedLayers: Remove" )
677+ if err := b .hostState .securityOptions .PolicyEnforcer .EnforceScratchUnmountPolicy (ctx , settings .CombinedLayers .ContainerRootPath ); err != nil {
678+ return fmt .Errorf ("scratch unmounting denied by policy: %w" , err )
679+ }
676680 }
677681
678682 // Reconstruct WCOWCombinedLayers{} req before forwarding to GCS
0 commit comments