Dry Run

The dry run is a very useful way to check the application configuration and the definitions. The dry run will render the application and print the output resources that check passed on the service side. If the definitions(component, trait) is invalid, the dry run will print the error message.

The policies and workflows can not be dry run currently, this is a insufficiency.

When you do the following things please must pass dry run.

  • Create or update an application.
  • Create or update the definition, and dry run some example applications.

Dry run via CLI

There is a simple application:

  1. kind: Application
  2. apiVersion: core.oam.dev/v1beta1
  3. metadata:
  4. name: webservice-app
  5. spec:
  6. components:
  7. - name: frontend
  8. type: webservice
  9. properties:
  10. image: oamdev/testapp:v1
  11. cmd: ["node", "server.js"]
  12. ports:
  13. - port: 8080
  14. expose: true
  15. traits:
  16. - type: scaler
  17. properties:
  18. replicas: 1

Copy it and write a file app.yaml

  1. vela dry-run app.yaml

The outputs:

  1. ---
  2. # Application(webservice-app) -- Component(frontend)
  3. ---
  4. apiVersion: apps/v1
  5. kind: Deployment
  6. metadata:
  7. annotations: {}
  8. labels:
  9. app.oam.dev/appRevision: ""
  10. app.oam.dev/component: frontend
  11. app.oam.dev/name: webservice-app
  12. app.oam.dev/namespace: default
  13. app.oam.dev/resourceType: WORKLOAD
  14. workload.oam.dev/type: webservice
  15. name: frontend
  16. namespace: default
  17. spec:
  18. replicas: 1
  19. selector:
  20. matchLabels:
  21. app.oam.dev/component: frontend
  22. template:
  23. metadata:
  24. labels:
  25. app.oam.dev/component: frontend
  26. app.oam.dev/name: webservice-app
  27. spec:
  28. containers:
  29. - command:
  30. - node
  31. - server.js
  32. image: oamdev/testapp:v1
  33. name: frontend
  34. ports:
  35. - containerPort: 8080
  36. name: port-8080
  37. protocol: TCP
  38. ---
  39. ## From the auxiliary workload
  40. apiVersion: v1
  41. kind: Service
  42. metadata:
  43. annotations: {}
  44. labels:
  45. app.oam.dev/appRevision: ""
  46. app.oam.dev/component: frontend
  47. app.oam.dev/name: webservice-app
  48. app.oam.dev/namespace: default
  49. app.oam.dev/resourceType: TRAIT
  50. trait.oam.dev/resource: webserviceExpose
  51. trait.oam.dev/type: AuxiliaryWorkload
  52. name: frontend
  53. namespace: default
  54. spec:
  55. ports:
  56. - name: port-8080
  57. port: 8080
  58. targetPort: 8080
  59. selector:
  60. app.oam.dev/component: frontend
  61. type: ClusterIP
  62. ---

If we set the expose field of the port as false, the output resources do not include the Service. If we set the replicas field as “1”, the output will be an error message:

  1. Error: validate application: ./app.yaml by dry-run: admission webhook "validating.core.oam.dev.v1beta1.applications" denied the request: field "schematic": Invalid value error encountered, cannot evaluate trait "scaler": invalid template of trait scaler after merge with parameter and context: parameter.replicas: conflicting values (*1 | int) and "1" (mismatched types int and string) (and 1 more errors).

This means the replicas field is int type but we provide a string value, this application configuration is not valid.

More use cases refer to the Dry run command

Dry run via UI

dry-run

Clicking the Deploy button to open the workflow selector dialog. You could select a workflow(every workflow corresponding to an environment) and click the DryRun button to execute a dry run. If passed, the result is like this

dry-run-successfully

The result report is different from the CLI, there is a complete application configuration that is generated from the application metadata, you could check it. Different environments may have different application configurations.