crc-org / crc-cloud

Disposable OpenShift instances on cloud in minutes
31 stars 19 forks source link

Refactor resources inside `Apply` functions #63

Closed adrianriobo closed 1 year ago

adrianriobo commented 1 year ago

Apply function is used to aggregate output values from resources, as those values are promises alike we need to wait until the resources are created to get the values and aggregate them for being used as input for another resources. The resources created inside an Apply function can not be evaluated during the preview phase and it seems this may impact on execution phase (running an update when it is not needed).

This PR will remove any resources from inside the Apply functions and use them only for generating new outputs (as aggreagate ouput values)

Fixes #62

adrianriobo commented 1 year ago

Tested with two creates in a row, now the second execution does no try to recreate any resource:

[ariobolo@ariobolo create]$ podman logs -f 22174319f3b3
Updating (crcCloud-Create):

    pulumi:pulumi:Stack crc-ocp412-crcCloud-Create running 
@ updating....
    aws:ec2:SecurityGroup OpenshiftLocal-OCP  
    tls:index:PrivateKey OpenshiftLocal-OCP  
    aws:ec2:KeyPair OpenshiftLocal-OCP  
    random:index:RandomPassword OpenshiftLocal-OCP  
    aws:ec2:Instance crc-ocp412  
    command:remote:CopyFile uploadClusterSetupScript  
    command:remote:CopyFile uploadNewPublicKey  
    command:remote:Command setXRightsForClusterSetupScript  
    command:remote:Command addPublicKeyAsAuthorized  
    command:remote:Command runClusterSetupScript  
    pulumi:pulumi:Stack crc-ocp412-crcCloud-Create  

Outputs:
    host       : "35.179.93.88"
    password   : [secret]
    private-key: [secret]
    username   : "core"

Resources:
    11 unchanged

Duration: 2s
adrianriobo commented 1 year ago

removed issue on Makefile, merged in conformance with merge party