Coder Social home page Coder Social logo

Comments (6)

jtaleric avatar jtaleric commented on August 23, 2024

Did you try with pin_node removed from the CR?

          # pin_node is an optional kubernetes hostname to which the pgbench pod will be pinned
          pin_node: 

When looking at the code.


{% if item.1.pin_node is defined and item.1.pin_node|length and item.1.pin_node is not sameas "" %}
      nodeSelector:
        kubernetes.io/hostname: '{{ item.1.pin_node }}'
{% endif %}

We might want to check the length of pin_node against a value, for example :

{% if item.1.pin_node is defined and item.1.pin_node|length > 1 and item.1.pin_node is not sameas "" %}
      nodeSelector:
        kubernetes.io/hostname: '{{ item.1.pin_node }}'
{% endif %}

from benchmark-operator.

dustinblack avatar dustinblack commented on August 23, 2024

Tested these conditions:

  1. pin_node not defined: passed
  2. pin_node defined with a valid node name (from oc get nodes): passed
  3. pin_node defined but empty: failed
  4. pin_node defined as '': passed
  5. pin_node defined as false: failed

5 above was just an extra test, so I'm sure 3 is what got you.

In the case of 3, we get the error:

object of type 'NoneType' has no len()

So I don't think there will be a difference in checking item.1.pin_node|length vs item.1.pin_node|length > 0 since it's simply angry that you can't check length on a NoneType variable (defined but without a value).

I'll look at this again tomorrow after some sleep and coffee. I'm sure there is a simple solution in the if statement that I'm not seeing right now.

from benchmark-operator.

jtaleric avatar jtaleric commented on August 23, 2024

Instead of us having to duplicate logic (like we currently are), how about we create role/pretasks that runs before all the other roles.

The responsibility of this role is to check for things like this in the CR, reducing the duplicate checks we currently have to do.

In this case we would need

item.1.ping_node is not none

I don't think this will eliminate all checks in other roles, but it will reduce things, additionally catch the error early... @dustinblack @aakarshg @dry923 thoughts?

from benchmark-operator.

dustinblack avatar dustinblack commented on August 23, 2024

@jtaleric So this might for instance convert any defined but empty variables from the CR into blank values ('') instead, so that the validation logic within the main role is simplified?

from benchmark-operator.

dustinblack avatar dustinblack commented on August 23, 2024

Tested with simplified if logic:

{% if item.1.pin_node is defined and item.1.pin_node %}

And the results look good:

  1. pin_node not defined: passed
  2. pin_node defined with a valid node name (from oc get nodes): passed
  3. pin_node defined but empty: passed << winning
  4. pin_node defined as '': passed
  5. pin_node defined as false: passed << winning

from benchmark-operator.

dustinblack avatar dustinblack commented on August 23, 2024

Fixed with PR #145

from benchmark-operator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.