How can I ensure that a Run exec always runs? Here...
# 🤖|ask-kapa
f
@microscopic-river-74022 How can I ensure that a Run exec always runs? Here it is:
Copy code
yaml
---
kind: Run
type: exec
name: setup-remote-nodes
description: Setup remote nodes for dev FM API client
dependencies:
  - build.fm-api-mock-server
  - build.fm-api-mock-client
spec:
  command:
    - /bin/bash
    - scripts/download-image.sh
    - --cluster
    - "${var.cluster}"
    - --ssh-key 
    - "${var.sshkey}"
    - --image 
    - ${actions.build.fm-api-mock-client.outputs.deploymentImageId}
    - --socket-host
    - wss://fm-api-${actions.deploy.fm-api-mock-server.var.apphost}/api/v1/ws
m
Please stand by @fresh-yak-35965 as I search the knowledge base. I normally take about 20 seconds or so. :wave:
---------------------- To ensure that a Run exec always runs, you can set
spec.cacheResult: false
in the Run definition. This will prevent Garden from caching the result of the Run, and it will always execute the Run regardless of previous results. Here is how you can modify your Run definition:
Copy code
yaml
---
kind: Run
type: exec
name: setup-remote-nodes
description: Setup remote nodes for dev FM API client
dependencies:
  - build.fm-api-mock-server
  - build.fm-api-mock-client
spec:
  cacheResult: false
  command:
    - /bin/bash
    - scripts/download-image.sh
    - --cluster
    - "${var.cluster}"
    - --ssh-key 
    - "${var.sshkey}"
    - --image 
    - ${actions.build.fm-api-mock-client.outputs.deploymentImageId}
    - --socket-host
    - wss://fm-api-${actions.deploy.fm-api-mock-server.var.apphost}/api/v1/ws
You can also manually run the Run using the command
garden run <run-name>
, which will run the Run even if the result is cached. Source: Garden FAQ () ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
message has been deleted
f
@microscopic-river-74022 Instead, can I make it so that a Run exec occurs every time that I start garden, regardless of what it's dependencies are with other garden objects?
m
Let me check the knowledge base for you. One moment! :books:
---------------------- Yes, you can achieve this by using the
exec
provider's
initScript
configuration. This allows you to run an arbitrary script when initializing providers. You can specify your Run command in this script. Here's an example of how you can configure it in your project level Garden config file:
Copy code
yaml
# In your project level Garden config file
apiVersion: garden.io/v1
kind: Project
name: my-project

providers:
  - name: exec
    initScript: "/bin/bash scripts/download-image.sh --cluster ${var.cluster} --ssh-key ${var.sshkey} --image ${actions.build.fm-api-mock-client.outputs.deploymentImageId} --socket-host wss://fm-api-${actions.deploy.fm-api-mock-server.var.apphost}/api/v1/ws"
  # ...
In this configuration, the
initScript
will run every time Garden is started, regardless of the dependencies of other Garden objects. Please note that the
initScript
is run in the project root when initializing providers. Source: Garden Exec Plugin () and Exec Provider Configuration () ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
message has been deleted
f
@microscopic-river-74022 I want the following garden file to run every time I start garden, regardless of what it's dependencies are. This isn't a mere issue of
cacheResult
, because currently, garden is not even executing this:
Copy code
yaml
---
kind: Run
type: exec
name: setup-remote-nodes
description: Setup remote nodes for dev FM API client
dependencies:
  - build.fm-api-mock-server
  - build.fm-api-mock-client
spec:
  cacheResult: false
  command:
    - /bin/bash
    - scripts/download-image.sh
    - --cluster
    - "${var.cluster}"
    - --ssh-key 
    - "${var.sshkey}"
    - --image 
    - ${actions.build.fm-api-mock-client.outputs.deploymentImageId}
    - --socket-host
    - wss://fm-api-${actions.deploy.fm-api-mock-server.var.apphost}/api/v1/ws
m
Let me check the knowledge base for you. One moment! :books:
---------------------- To ensure that the Run exec occurs every time you start Garden, regardless of its dependencies, you can use the
exec
provider's
initScript
configuration. This allows you to run an arbitrary script when initializing providers. You can specify your Run command in this script. Here's an example of how you can configure it in your project level Garden config file:
Copy code
yaml
# In your project level Garden config file
apiVersion: garden.io/v1
kind: Project
name: my-project

providers:
  - name: exec
    initScript: "/bin/bash scripts/download-image.sh --cluster ${var.cluster} --ssh-key ${var.sshkey} --image ${actions.build.fm-api-mock-client.outputs.deploymentImageId} --socket-host wss://fm-api-${actions.deploy.fm-api-mock-server.var.apphost}/api/v1/ws"
  # ...
In this configuration, the
initScript
will run every time Garden is started, regardless of the dependencies of other Garden objects. Please note that the
initScript
is run in the project root when initializing providers. Source: Garden Exec Plugin () and Exec Provider Configuration () ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
message has been deleted