Skip to content

Commit

Permalink
Merge pull request #1817 from robnester-rh/KFLUXBUGS-1505
Browse files Browse the repository at this point in the history
KFLUXBUGS-1505 Fix EC OOM by specifying workers
  • Loading branch information
lcarva authored Aug 1, 2024
2 parents b2482b9 + 192b98a commit 388e80e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cmd/validate/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ func validateImageCmd(validate imageValidationFunc) *cobra.Command {
images string
noColor bool
forceColor bool
workers int
}{
strict: true,
strict: true,
workers: 5,
}

validOutputFormats := applicationsnapshot.OutputFormats
Expand Down Expand Up @@ -357,9 +359,9 @@ func validateImageCmd(validate imageValidationFunc) *cobra.Command {
}

numComponents := len(appComponents)
// TODO: Eventually, this should either be set as a parameter or adjusted based on the
// available resources. The main constraint seems to be memory.
numWorkers := 5

// Set numWorkers to the value from our flag. The default is 5.
numWorkers := data.workers

jobs := make(chan app.SnapshotComponent, numComponents)
results := make(chan result, numComponents)
Expand Down Expand Up @@ -503,6 +505,9 @@ func validateImageCmd(validate imageValidationFunc) *cobra.Command {
cmd.Flags().BoolVar(&data.forceColor, "color", data.info, hd.Doc(`
Enable color when using text output even when the current terminal does not support it`))

cmd.Flags().IntVar(&data.workers, "workers", data.workers, hd.Doc(`
Number of workers to use for validation. Defaults to 5.`))

if len(data.input) > 0 || len(data.filePath) > 0 || len(data.images) > 0 {
if err := cmd.MarkFlagRequired("image"); err != nil {
panic(err)
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_validate_image.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ mark (?) sign, for example: --output text=output.txt?show-successes=false
--snapshot:: Provide the AppStudio Snapshot as a source of the images to validate, as inline
JSON of the "spec" or a reference to a Kubernetes object [<namespace>/]<name>
-s, --strict:: Return non-zero status on non-successful validation. Defaults to true. Use --strict=false to return a zero status code. (Default: true)
--workers:: Number of workers to use for validation. Defaults to 5. (Default: 5)

== Options inherited from parent commands

Expand Down
3 changes: 3 additions & 0 deletions docs/modules/ROOT/pages/verify-enterprise-contract.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ paths can be provided by using the `:` separator.
*TIMEOUT* (`string`):: Timeout setting for `ec validate`.
+
*Default*: `5m0s`
*WORKERS* (`string`):: Number of parallel workers to use for policy evaluation.
+
*Default*: `1`

== Results

Expand Down
1 change: 1 addition & 0 deletions tasks/verify-enterprise-contract/0.1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ kubectl apply -f https://raw.githubusercontent.com/enterprise-contract/ec-cli/ma
* **STRICT**: Fail the task if policy fails. Set to "false" to disable it.
* **HOMEDIR**: Value for the HOME environment variable.
* **EFFECTIVE_TIME**: Run policy checks with the provided time.
* **WORKERS**: Number of parallel workers to use for validation.


## Usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ spec:
description: Timeout setting for `ec validate`.
default: "5m0s"

- name: WORKERS
type: string
description: Number of parallel workers to use for policy evaluation.
default: "1"

workspaces:
- name: data
description: The workspace where the snapshot spec json file resides
Expand Down Expand Up @@ -180,6 +185,8 @@ spec:
- "--rekor-url"
- "$(params.REKOR_HOST)"
- "--ignore-rekor=$(params.IGNORE_REKOR)"
- "--workers"
- "$(params.WORKERS)"
# NOTE: The syntax below is required to negate boolean parameters
- "--info=$(params.INFO)"
- "--timeout=$(params.TIMEOUT)"
Expand Down

0 comments on commit 388e80e

Please sign in to comment.