Giter VIP home page Giter VIP logo

orm's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

orm's Issues

Invalid path validation and omitted path tolerance in ORM

ORM controller detects invalid path in owner and owned resources. However, it is hard to tell whether a path is invalid or omitted (use default value) in an resource. The proposed solution is to divide the scenario into 2 cases

  1. During ORM composing/debug time, developer wants to detect all the paths to make sure they're correct.
  2. During production time, devops wants to tolerate the omitted path, assuming the path is correct.

The solution is:

  • 1. We introduce annotations to control the validation.

    • a. “devops.turbonomic.io/validate-owner-path”: “enabled” # ”enabled/disabled” default is enabled
    • b. “devops.turbonomic.io/validate-owned-path”: “enabled” # “enabled/disabled” default in enabled
  • 2. If validation is enabled, we only process ORM mappings with all resources are present and all paths are located.

  • 3. If validation is disabled,

    • a. we do not show those mappings with missing/omitted paths in status,
    • b. we do use those mappings with missing/omitted paths in action execution.
  • In addition to that, ORM record event for actions to OwnerCRs, and call out when omitted path are completed by ORM.

Support predefined variable to retrieve string value from owned resource

In first release, we only support {{owned.name}} to retrieve metadata.name of owned resource to be used in patterns. But in some cases, the information we need lives in a label (or somewhere else) rather than the name. So we want to allow orm composer to be able to provide a path to retrieve the string value anywhere inside the owned resource.

example:

    - ownerPath: .spec.settings.deployment.serverBundles[?(@.name=="{{.owned.metadata.labels.xxx/yyy}}")].replica
      owned:
        apiVersion: apps/v1
        kind: Deployment
        selector: serverBundle_component
        path: .spec.replicas

If the path does not point to a string value, an error should be reported.

Allow predefined selectors

The duplicated long list of label selector to address different path with same group of owned resource looks clumsy. I think we can allow predefined selector (like parameters) to be reused. something like this:

...
spec:
...
  mappings:
    selectors:
      core: 
        matchExpressions:
        - key: app.kubernetes.io/name
          operator: In
          values:
          - action-orchestrator
          - api
          - auth
          - clustermgr
          ...
    patterns:
    - ownerPath: .spec.{{.owned.name}}.resources
      owned:
        path: .spec.template.spec.containers[?(@.name=="{{.owned.name}}")].resources
        apiVersion: apps/v1
        kind: Deployment
        selector: core
    - ownerPath: .spec.{{.owned.name}}.replicaCount
      owned:
        path: .spec.replicas
        apiVersion: apps/v1
        kind: Deployment
        selector: core    

escape dot in jsonpath

Use case 1 - labels:

metadata:
  labels:
    "ibm.com/type": "app"

Use case 2 - special field:

spec:
  components:
    ibm.com:
      websphere:
        resources:

In order to work with fields with dot in the key, we can't use jsonpath like .metadata.labels.ibm.com/type or .spec.ibm.com.websphere.resources

According to evaluator from https://jsonpath.com/

the right way is to use .metadata.labels.['ibm.com/type'] .spec.['ibm.com'].websphere.resources

we need to support that approach.

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.