chainsaw: [Bug] Wait Condition not working with value provided

chainsaw version Version

v0.1.8

Description

I have a test case which creates a deployment and am trying to wait for a deployment to become Available=True.

I think the PR https://github.com/kyverno/chainsaw/pull/981 has broken the functionality, as when I reverted it (locally), compiled and ran it, it worked fine.

When I run the command locally (the one which it hangs on)

kubectl wait deployments.v1.apps --for=condition=available="True" nginx-deployment -n chainsaw-clever-quagga --timeout=-1s

It will work fine and resolve.

Steps to reproduce

  1. Run the code below and the COMMAND for waiting will hang.
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
  name: quick-start
spec:
  steps:
  - try:
    # first operation: create the config map
    - apply:
        resource:
          apiVersion: apps/v1
          kind: Deployment
          metadata:
            name: nginx-deployment
            labels:
              app: nginx
          spec:
            replicas: 1
            selector:
              matchLabels:
                app: nginx
            template:
              metadata:
                labels:
                  app: nginx
              spec:
                containers:
                  - name: nginx
                    image: nginx:latest
                    ports:
                      - containerPort: 80
    - wait:
        apiVersion: apps/v1
        kind: Deployment
        name: nginx-deployment
        timeout: 1m
        for:
          condition:
            name: available
            value: "True"
    # second operation: verify the config map exists and contains the expected data
    - assert:
        resource:
          apiVersion: apps/v1
          kind: Deployment
          metadata:
            name: nginx-deployment
            labels:
              app: nginx
          spec:
            replicas: 1
            selector:
              matchLabels:
                app: nginx
            template:
              metadata:
                labels:
                  app: nginx
              spec:
                containers:
                  - name: nginx
                    image: nginx:latest
                    ports:
                      - containerPort: 80

Expected behavior

  1. The command resolves when the condition is met.

Screenshots

Screenshot 2024-03-13 at 10 29 45 pm

Logs

No response

Slack discussion

No response

Troubleshooting

  • I have searched other issues in this repository and mine is not recorded.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 16 (16 by maintainers)

Most upvoted comments

@johnathan-sq yes

what we do is:

  • set a long timeout when invoking kubectl (--timeout=-1s uses a negative timeout, equivalent to one week)
  • but the operation has the timeout you set in the yaml

In the end the timeout you configure is applied at the operation level but not in the kubectl command itself, this way we don’t need to keep both in sync and avoid races.

Except the report looking incorrect it behaves as expected.