Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Support analysis providers. #599

Closed
jortel opened this issue Feb 6, 2024 · 1 comment · Fixed by #606
Closed

✨ Support analysis providers. #599

jortel opened this issue Feb 6, 2024 · 1 comment · Fixed by #606
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. priority/normal Higher priority than priority/minor. Nice to have. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@jortel
Copy link
Contributor

jortel commented Feb 6, 2024

Problem

Currently: Each addon defines a single container.
Currently: analysis is performed by running a task that specifies the tackle2-addon-analyzer addon. The name of the addon is hard-coded in the UI. This addon image incorporates support goland and Java providers.

The analyzer images are being refactored and the analyzer image will no longer bundle language providers. Instead, each provider will be packaged as a separate image. To support this, addons will need to be defined multiple containers. A main container for the addon and additional (sidecar) containers (one for each provider).

Future features may require runtime selection of an addon based on the kind-of task and the kind-of subject (application|platform|...) the task is executed on.
Examples:

  • application technology discovery.
  • platform discovery.
  • platform analysis.

Questions/Assumptions:

  • Do we need to support multi-language applications? Yes.
  • Can the filtering of targets/rulesets and selection of providers be driven by language tags? Yes.

Solution

Support optional addon Extensions. Each extension is a (sidecar) container and most likely a service. For example: an RDBMS or LSP provider. All containers within a task pod are injected with the same items as the main addon contianer:

  • Shared (EmptyDir) volume.
  • Security token.
  • Task (id).

Both addon and extension selection may be either:

  • explicit - (specified on the task)
  • determined by matched criteria.

Selection

As selector uses Label-Selector syntax and supports the following:

  • tag:category=tag
  • platform:(source|target)=kind

Examples:

Java
selector: tag:Language=Java

Java or XML
selector: tag:Language=Java || tag:Language=XML

No language tag.
selector: ! tag:Language=

Java and Linux
selector: tag:Language=Java && tag:OperatingSystem=Linux

Addon & Extension CRs

New Extension CR (Spec):

kind: Extension
spec:
  addon (string):
  container (core.v1.Container):
  selector (string):
  metadata (object):

Fields:

  • extension - declares compatibility with addons.
  • container - defines the extension container.
  • selector - defines selector for inclusion in the addon task pod.
  • metadata - defines unstructured information.

Changed Addon CR (Spec):

- image:
- imagePullPolicy:
- resources:

+ kind (string):
+ container  (core.v1.Container):
+ selector:
+ metadata (object):

Fields:

  • kind - declares compatibility with a kind of task.
  • container - defines the addon container.
  • selector - defines addon selector for task (kind).
  • metadata - defines unstructured information.
  • schema - FUTURE defines the Task.Data schema.

For symmetry and completeness, the metadata field is added and the separate addon fields for the container are replaced with the entire k8s Container. This is mainly a general improvement while we're changing the CR.

Example:

---
kind: Addon
apiVersion: tackle.konveyor.io/v1alpha1
metadata:
  namespace: konveyor-tackle
  name: analyzer
spec:
  container:
    name: addon
    imagePullPolicy: Always
    image: quay.io/jortel/tackle2-addon-analyzer:provider

---
kind: Extension
apiVersion: tackle.konveyor.io/v1alpha1
metadata:
  namespace: konveyor-tackle
  name: java
spec:
  addon: analyzer
  selector: tag:Language=Java || !tag:Language
  container:
    name: java
    imagePullPolicy: Always
    image: quay.io/konveyor/java-external-provider
    args:
    - --port
    - $(PORT)
    env:
    - name: PORT
      value: ${seq:8000}
    resources:
      limits:
        cpu: 1
        memory: 3Gi
      requests:
        cpu: 1
        memory: 3Gi
  metadata:
    resources:
    - selector: identity:kind=maven
      fields:
      - name: settings
        path: /shared/creds/maven/settings.xml
        key: maven.settings.path
    provider:
      name: java
      address: localhost:$(PORT)
      initConfig:
      - providerSpecificConfig:
          mavenSettingsFile: $(maven.settings.path)

API

Task API resource changes:

+ Extensions []string `json: "extensions,omitempty"`.

Example:

addon: analyzer
extensions:
- java

Port Injection

The task manager will provide a set of injector (macros). Format: ${<macro}. Injector macros may be specified in the container.Spec:

  • command
  • args
  • env

Automatic port assignment will be supported using a sequence (generator) macro.
Format: ${seq:pool}.
Example:

container:
  name: Test
  env:
  - name: PORT
    value: ${seq:8000}

Kinds of Tasks

A task (definition) defines a kind-of task which performs a specific action on a specific subject.

To prevent hard-coding tag names in the UI (anywhere), we may consider data-driven approaches.
Introducing named task (definitions) which represent a known kind-of task. Each (definition) defines the input schema and how an addon (that implements the task) may be selected. Addons (optionally) declare that they implement a kind-of task.

New Task CR:

  • name
  • dependencies:
  • data (object)

Fields:

  • name the kind-of task.
  • dependencies list of task names used to define execution dependency.
  • data - data object passed to the addon.
  • schema - FUTURE defines the Task.Data schema.
kind=Task
name: discovery
addon:
 - name: discovery
kind=Task
name: analysis
dependencies:
- discovery
kind=Task
name: platform-analysis
kind=Task
name: platform-discovery

Add Task.Kind which can be applied by the exiting task endpoints. Either kind OR addon and extensions may be specified but not both.

+ Kind []string `json: "kind,omitempty"`.

Example:

kind: analyzer

Add a new read-only endpoints.

  • /tasks/:id/attached - download (tgz) attached files.
  • /k8s/addons - moved from /addons
  • /k8s/addons/:name - moved from /addons/:name, includes extensions.
  • /k8s/extensions - new extensions colleciton
  • /k8s/extensions/:name - new extension by name

Task Priority

Tasks will be run in order of:

  • priority
  • id

Pods are created with the appropriate PriorityClass to ensure node scheduling matches. Task dependencies will be escalated as needed to prevent priority inversion. When (dep) tasks are already scheduled (Pending), the pod will be recreated referencing the updated priority class.

When the nodes are saturated and task pods are phase=Pending, the task manager may reschedule (delete) task with lower priority in an effort for higher priority pods to be run by the node scheduler. PriorityClass preemption should handle this.

Addon (adaptor)

Environment (variable) Injection

To injecting container environment variables into the Extension.metadata.
The format is exactly like k8s environment variable: $(variable).

Example:

container:
  name: Test
  env:
  - name: PORT
  - value: 8000
metadata:
  address: localhost:$(PORT)
    ...

Analyzer Addon (adaptor)

delegated to: konveyor/tackle2-addon-analyzer#83

Resource Injector

Aggregate the initConfig fragments from each Extension.metadata.

Inject information into the initConfig.

  • credentials.

Considering: To support this, a set of injectors will be provided to get, store hub REST resource (fields). Fetched resources are assigned to variables that may be used in the metadata.
Resource:

  • selector (format: <kind>:<key>=<value>)
  • fields[]:
    • name: - name.
    • path: - (optional) value stored at the specified path.
    • key: - value stored in key referenced as $(key). Assigned to path, when specified.

Example:

metadata:
  resources:
  - kind: identity:kind=maven
    fields:
    - name: settings
      path: /shared/creds/maven/settings.xml
       key: settings.path
  - kind: identity=other
    fields:
    - name: user
       key: auth.user
    - name: password
       key: auth.password
  provider:
    initConfig:
     mavenSettingsPath: $(settings.path)
     user: $(auth.user)
     password: $(auth.password)
@jortel jortel self-assigned this Feb 6, 2024
@konveyor-ci-bot konveyor-ci-bot bot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Feb 8, 2024
@konveyor-ci-bot
Copy link

This issue is currently awaiting triage.
If contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.
The triage/accepted label can be added by org members.

@konveyor-ci-bot konveyor-ci-bot bot added needs-kind Indicates an issue or PR lacks a `kind/foo` label and requires one. needs-priority Indicates an issue or PR lacks a `priority/foo` label and requires one. labels Feb 8, 2024
@jortel jortel added kind/feature Categorizes issue or PR as related to a new feature. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-kind Indicates an issue or PR lacks a `kind/foo` label and requires one. needs-priority Indicates an issue or PR lacks a `priority/foo` label and requires one. labels Feb 12, 2024
@konveyor-ci-bot konveyor-ci-bot bot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates an issue or PR lacks a `priority/foo` label and requires one. labels Feb 12, 2024
@jortel jortel added priority/major Important over the long term, but may not be staffed and/or may need multiple releases to complete. priority/normal Higher priority than priority/minor. Nice to have. and removed priority/major Important over the long term, but may not be staffed and/or may need multiple releases to complete. labels Feb 15, 2024
@konveyor-ci-bot konveyor-ci-bot bot removed the needs-priority Indicates an issue or PR lacks a `priority/foo` label and requires one. label Feb 15, 2024
@dymurray dymurray added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label May 6, 2024
@jortel jortel added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 6, 2024
jortel added a commit that referenced this issue Jun 6, 2024
Support dynamic selection of multiple providers in separate containers.

closes #599 

Summary by package:
- /addon
- add support for addons to fetch the _Addon_ using the binding through
the addon (adapter) package.
  - add environment variables injector.  replaces $(var) with values.
- /api
  - addon 
    - support changes in addon and extension CRs. 
    - included (new) extensions in _Addon_ resource.
  - task
    - removed unused fields: variant, purged. 
    - support new addon and extensions fields.
- resolve k8s resources referenced by task: addon, extension, task,
priority for validation and default priority.
   - taskgroup - support changes in task.
   - delegate CRUD (including cancel) to the task manager. This ensure:
     - tasks in flight are not updated by multiple threads.
- delegates complexities on what can be updated when to the task manger.
 - /binding - add support for reading Get, List addons.
 - generated/crd - result of: (make generate && make manifests)
- /k8s/api -
   - addon - updated to support dynamic addon selection.
   - task - added to support dynamic addon selection.
   - extension - added to support extensions with dynamic selection.
- /migration/v13 - core.go updated.
   - Task.kind added.
   - Task.Extensions added. 
- Task.Attached added to support attached pod definition and container
logs.
- Task.Policy structured _TaskPolicy_. which includes preemption
policies. Structured improved the api.
- /model - ref migration v13.
- /reaper
  -  reap files attached to tasks.
  - report released event.
- /settings - add hub setting for location of /shared (emptydir).
- /task - support:
- converted task models to use json serializer (while adding other json
fields).
- multi-container task pods which ensured extension container
termination.
  - both static and dynamic addon seletion.
  - both static and dynamic extension selection. 
  - task (kinds)
- priority escalation based on _task-kind_ dependencies. Prevents
priority inversions.
  - task preemption based on priority.
- enhanced ordering based on _task-kind_ dependency. adds task Postponed
rule.
- attach pod.yaml (including events) and container logs to the task on
pod completion.
  - support resource quota.
- add environment variable injection _(mainly to support automatic port
assignment for providers)._
- add ${seq:<pool>} macro _(mainly to support automatic port assignment
for providers)._
  - add task event reporting.
  - refactored the manager:
    - task state simplified: pending state removed (reported by event).
    -  consolidate errors into error.go and add _soft_ error concept.
- Manager.runReady() into separate methods for better decomposition.
each loop through and acts on the list.
- Manager.updateRunning() into separate methods for better functional
decomposition.
- fetch all k8s resources at once instead of hammering the api-server.
---

json serialization: added a custom json (model) serializer. This was
needed because we need the serializer to
handle the map[any]any problem with binding yaml. Removed
api/base.go/strMap() and moved it to the new serializer. Only being used
by tasks.

---

Added/Updated CRDs:
- Addon (updated)
- Extension
- Task

---------

Signed-off-by: Jeff Ortel <jortel@redhat.com>
jortel added a commit to konveyor/tackle2-addon-analyzer that referenced this issue Jun 6, 2024
ref: konveyor/tackle2-hub#599

Signed-off-by: Jeff Ortel <jortel@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. priority/normal Higher priority than priority/minor. Nice to have. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants