@@ -470,12 +470,19 @@ func create(state gen.Atom, data ResourceUpdateData, proc gen.Process) (gen.Atom
470470 return StateFinishedWithError , data , nil , nil
471471 }
472472
473+ compressedProps , err := plugin .CompressJSON (convertedResource .Properties )
474+ if err != nil {
475+ proc .Log ().Error ("failed to compress resource properties: %v" , err )
476+ data .resourceUpdate .MarkAsFailed ()
477+ return StateFinishedWithError , data , nil , nil
478+ }
479+
473480 createOperation := plugin.CreateResource {
474- Namespace : convertedResource .Namespace (),
475- ResourceType : convertedResource .Type ,
476- Label : convertedResource .Label ,
477- Properties : convertedResource . Properties ,
478- TargetConfig : data .resourceUpdate .ResourceTarget .Config ,
481+ Namespace : convertedResource .Namespace (),
482+ ResourceType : convertedResource .Type ,
483+ Label : convertedResource .Label ,
484+ CompressedProperties : compressedProps ,
485+ TargetConfig : data .resourceUpdate .ResourceTarget .Config ,
479486 }
480487
481488 // First we check if progress already was made on the create operation. This can happen for example if the node crashed while the
@@ -556,15 +563,28 @@ func update(state gen.Atom, data ResourceUpdateData, proc gen.Process) (gen.Atom
556563 return StateFinishedWithError , data , nil , nil
557564 }
558565
566+ compressedDesired , err := plugin .CompressJSON (convertedResource .Properties )
567+ if err != nil {
568+ proc .Log ().Error ("failed to compress desired properties: %v" , err )
569+ data .resourceUpdate .MarkAsFailed ()
570+ return StateFinishedWithError , data , nil , nil
571+ }
572+ compressedPrior , err := plugin .CompressJSON (convertedExisting .Properties )
573+ if err != nil {
574+ proc .Log ().Error ("failed to compress prior properties: %v" , err )
575+ data .resourceUpdate .MarkAsFailed ()
576+ return StateFinishedWithError , data , nil , nil
577+ }
578+
559579 updateOperation := plugin.UpdateResource {
560- Namespace : convertedResource .Namespace (),
561- NativeID : convertedResource .NativeID ,
562- ResourceType : convertedResource .Type ,
563- Label : convertedResource .Label ,
564- PriorProperties : convertedExisting . Properties ,
565- DesiredProperties : convertedResource . Properties ,
566- PatchDocument : string (data .resourceUpdate .DesiredState .PatchDocument ),
567- TargetConfig : data .resourceUpdate .ResourceTarget .Config ,
580+ Namespace : convertedResource .Namespace (),
581+ NativeID : convertedResource .NativeID ,
582+ ResourceType : convertedResource .Type ,
583+ Label : convertedResource .Label ,
584+ CompressedPriorProperties : compressedPrior ,
585+ CompressedDesiredProperties : compressedDesired ,
586+ PatchDocument : string (data .resourceUpdate .DesiredState .PatchDocument ),
587+ TargetConfig : data .resourceUpdate .ResourceTarget .Config ,
568588 }
569589
570590 // First we check if progress already was made on the update operation. This can happen for example if the node crashed while the
@@ -635,6 +655,17 @@ func resumeWaitingForResource(state gen.Atom, data ResourceUpdateData, progress
635655// state machine to the next state when the plugin operation finished successfully. After the last plugin operation, or
636656// after the first error, it reports the final state to the stack updater and exits.
637657func handleProgressUpdate (from gen.PID , state gen.Atom , data ResourceUpdateData , message plugin.TrackedProgress , proc gen.Process ) (gen.Atom , ResourceUpdateData , []statemachine.Action , error ) {
658+ // Decompress resource properties if sent compressed over Ergo
659+ if len (message .CompressedResourceProperties ) > 0 && len (message .ResourceProperties ) == 0 {
660+ decompressed , err := plugin .DecompressJSON (message .CompressedResourceProperties )
661+ if err != nil {
662+ proc .Log ().Error ("failed to decompress resource properties" , "error" , err )
663+ data .resourceUpdate .MarkAsFailed ()
664+ return StateFinishedWithError , data , nil , nil
665+ }
666+ message .ResourceProperties = decompressed
667+ }
668+
638669 err := data .resourceUpdate .RecordProgress (& message )
639670 if err != nil {
640671 proc .Log ().Error ("failed to record progress for resource update" , "error" , err )
@@ -845,6 +876,15 @@ func doPluginOperation(resourceURI pkgmodel.FormaeURI, operation plugin.PluginOp
845876 return nil , fmt .Errorf ("expected TrackedProgress, got %T" , response )
846877 }
847878
879+ // Decompress resource properties if sent compressed over Ergo (64KB limit)
880+ if len (progressResult .CompressedResourceProperties ) > 0 && len (progressResult .ResourceProperties ) == 0 {
881+ decompressed , err := plugin .DecompressJSON (progressResult .CompressedResourceProperties )
882+ if err != nil {
883+ return nil , fmt .Errorf ("failed to decompress resource properties: %w" , err )
884+ }
885+ progressResult .ResourceProperties = decompressed
886+ }
887+
848888 return & progressResult , nil
849889}
850890
0 commit comments