Grant Gainey
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Pulp3-pulp_rpm Applicability Design ## Executive Summary In the RPM World, a key question Pulp needs to answer is “Given a set of installed Packages, what updates are **applicable** to me?”. ‘Applicable’ implies that we know three pieces of information: * A list of Package NEVRAs * A list of repositories we care about * A definition of module-state (installed/enabled modules) And can return the following information: * A list of all Package NEVRAs, available in the specified repositories, which are updates to the specified incoming list of NEVRAs (**required**) * A list of Advisories under which those Packages were released (**required**) * A list of Module NSVCAs, available in the specified repositories, which are updates to the specified incoming list of enabled NSVCAs (**required**) * A list of CVEs associated with those Advisories (**optional/stretch**) All of the required fields may return null-lists - Packages and Modules if there are no updates available, Advisories in that case and in the case where Packages are not associated with Advisories. CVEs are an optional stretch goal - we do not currently have any requests for applicability to return CVE data, but it is available in the database. Pulp_rpm in Pulp3 needs to be able to answer this question as quickly as possible. This doc is intended to capture the requirements, planning, and design options for answering this question. ## Definitions The pulp_rpm entities that applicability is concerned with include: * **Package** : binary blobs that are installed on/into systems/containers * **NEVRA** : Name/epoch/version/release/architecture - unique(ish) identifier of an Package (e.g., different signing-key or different checksum, for same NEVRA, pulled into a single repository, has happened ‘in the wild’ in the past) * **Repository** : Holder of Packages and metadata * **Advisory** (aka **Erratum**) : Atomic unit of repository-update and update-metadata * **CVE** : Common Vulnerabilities and Exposures - public definition of security issues. Associated with Advisories * **Module** : a set of packages that define an entity with its own release-cycle (separate from the base-OS on which it is installed) - e.g., Postgresql might be a module * **Module-stream** : a major release of a specific module - e.g., postgresql-10 and postgresql-11 might be separate streams of the postgresql module * **Module-context** : the ‘base-OS’ release the module is built for. * **NSVCA** - Name/Stream/Version/Context/Architecture - unique identifier of a specific installed/enabled module ## Current Pulp2 State * Pulp2 data-store is MongoDB * Pulp2 maintains a list of **Consumers**. * A consumer ‘knows’ the following ‘**content-state**’: * Its installed list of Packages * Its enabled repositories * Its current modularity-state * Because Pulp2 maintains the consumers, it can **cache** applicability-state * Because consumers change, Pulp2 must be informed whenever a given consumer’s content-state changes, and must recalculate and update that consumer’s applicability-state. * Because the content of repositories can change, Pulp2 must be informed whenever a repository’s state changes, and must recalculate and update the applicability-state of all consumers subscribed to that repository. * Pulp2 can be queried for the applicability-state of a specified consumer or set of consumers, reading from the consumer’s applicability cache. * Pulp2 returns a dictionary of lists, keyed by CONTENT TYPE, as applicability-state. ## Pulp3 differences * Pulp3 uses Postgres to maintain the relationships between entities * Pulp3 **DOES NOT** maintain consumers * Therefore, content-state **MUST BE PROVIDED** in each call to applicability * Therefore, Pulp3’s applicability-calculation is **STATELESS** * Therefore, Pulp3 **DOES NOT REQUIRE** the applicability-recalculation infrastructure * Therefore, performance is a **HIGH PRIORITY** for Pulp3’s ability to calculate and return applicability-state ## Requirements * Supports all RPM distributions * RHEL * Fedora * CentOS * SUSE * Stateless * Fast * Input **must** include: * Package NEVRA list * a list of repositories-of-interest * module-install/enabled-info * Output **must** include list of updateable Package NEVRAs. * Output **must** include list of updateable Module NSVCAs. * Output **may** include applicable-advisories * Some secondary requirements - subject to change * Avoid undue complication at install time * Avoid undue complications with monitoring * Avoid undue bloating of hardware requirements for Pulp3 * Include CVEs associated with advisories (very optional) ## Approach There are a number of projects/products other than Pulp-2 at Red Hat that calculate applicability based on content-state in a data store, including (but possibly not limited to) [Pulp-2](https://github.com/pulp/pulp_rpm/tree/2-master), [spacewalk](https://github.com/spacewalkproject/spacewalk), and [VMAAS](https://github.com/RedHatInsights/vmaas). As a first cut, we are going to try to reuse code from the most recent attempt, VMAAS. That service has been in production, is the backend ‘definition of truth’ for applicability in the Vulnerability portion of cloud.redhat.com, and has had some significant performance work done at the database level that we hope to be able to take advantage of. Also, unlike all the other current codebases, VMAAS shares the “stateless” and “knows nothing about consumers of applicability” design goals. Our overarching goals are threefold, in order: 1. “Have a solid API defined ASAP” 1. “Have that API working ASAP (even if performance is suboptimal)” 1. “Address performance issues by evaluating behavior under actual data loads”. The general approach we will be taking is 1. Propose initial API 1. Collaborate with community to refine and solidify 1. Implement API handlers as stubs a. API validation implemented b. Canned response returned 1. Implement/reuse ‘version compare’ in Postgresql using current NEVRA data of pulp_rpm as of 3.0’s release 1. Implement test-cases for testing correctness 1. Measure performance-characteristics under larger data-loads and adjust/add-to how we store NEVRA information in response Many of these points can be worked on concurrently. ## API - [Let the Fun Begin!] ### Overview IN: * List of NEVRAs (required) * List of repositories (required) * Set of modularity information (can be empty) ### Overview OUT: Nested JSON structure that contains: * For each repository: * For each incoming NEVRA found in that repository: * For each possible update to that NEVRA in that repository: * Update NEVRA * Advisory that released that update (if any) We choose to categorize output by-repository because the point of applicability is knowing what needs to be updated, and where the updates are available. “Firefox is out of date” is nice, “firefox as delivered from your ‘third-party-apps-x86_64’ repository is out of date” makes it possible for the user to take the next step. ### Specific Use Cases 1. As a user, I can get **all the applicability information** known to pulp_rpm for a set of NEVRAs and repositories * URL: POST http://pulp.example.com/pulp/api/v3/rpm/applicability * IN JSON: ``` { ‘rpms’: [‘nevra1’, ..., ’nevraN’], ‘repositories’: [‘repo-version-id1’,..., repo-version-idN’], ‘modules’: [ {‘module_nsvca’: ‘mod1’, ‘module_state’: ‘enabled’}, {‘module_nsvca’: ‘mod2’, ‘module_state’: ‘disabled’}, ... ] } ``` * OUT JSON: ``` { ‘repositories’ : [ { ‘repo-version-id’: ‘repo-version-id1’, ‘requested_packages’ : [ { ‘package’ : ‘nevra1’, ‘updates’ : [ { ‘nevra’ : ‘nevra1.1’, ‘cause’ : ‘advisory-1’ }, { ‘nevra’ : ‘nevra1.2’, ‘cause’ : ‘advisory-2’ }, ... { ‘nevra’ : ‘nevra1.N’, ‘cause’ : None } ] }, { ‘package’ : ‘nevra2’, ‘updates’ : [ { ‘nevra’ : ‘nevra2.1’, ‘cause’ : ‘advisory-3’ }, { ‘nevra’ : ‘nevra2.2’, ‘cause’ : ‘advisory-4’ }, ... { ‘nevra’ : ‘nevra1.N’, ‘cause’ : None } ] }, ... ], ‘requested_modules’ : [ { ‘module’ : ‘nsvca-1’, ‘updates’ : [ { ‘nsvca’ : ‘nsvca1.1’, ‘cause’ : ‘advisory-10’ }, { ‘module’ : ‘nsvca1.2’, ‘cause’ : None }, ... { ‘nsvca’ : ‘nsvca1.N’, ‘cause’ : ‘advisory-N’ }, ] }, { ‘module’ : ‘nsvca-2’, ‘updates’ : [ { ‘nsvca’ : ‘nsvca2.1’, ‘cause’ : ‘advisory-20’ }, { ‘nsvca’ : ‘nsvca2.2’, ‘cause’ : None }, ... { ‘nsvca’ : ‘nsvca2.N’, ‘cause’ : ‘advisory-M’ }, ] }, ... ] }, { ‘repo-version-id’ : ‘repo-version-id2’, … }, … { ‘repo-version-id’ : ‘repo-version-idN’, … } ] } ``` 2. As a user, I can get **just the set of uninstalled advisories** for a set of NEVRAs and repositories * URL: POST http://pulp.example.com/pulp/api/v3/rpm/applicability/advisories * IN JSON: see #1 * OUT JSON: ``` { ‘repositories’ : [ { ‘repo-version-id’: ‘repo-version-id1’, ‘applicable_advisories’ : [ ‘advisory-1’, …, ‘advisory-N’] }, …, { ‘repo-version-id’: ‘repo-version-idN’, ‘applicable_advisories’ : [ ‘advisory-1’, …, ‘advisory-N’] } ] } ``` 3. As a user, I can get **just the number of Packages that can be updated** from a set of NEVRAs and repos Collapse #3 and #4 into one? See below. 4. As a user, I can get **just the number of uninstalled advisories** for… * URL:POST http://pulp.example.com/pulp/api/v3/rpm/applicability/overview * IN JSON: see #1 * OUT JSON: ``` { ‘repositories’ : [ { ‘repo-version-id’: ‘repo-version-id1’, ‘num_applicable_packages’ : P, ‘num_applicable_modules’ : M, ‘num_applicable_advisories’ : A }, …, { ‘repo-version-id’: ‘repo-version-idN’, ‘num_applicable_packages’ : P, ‘num_applicable_modules’ : M, ‘num_applicable_advisories’ : A }, ] } ``` Number 1 is the base requirement. The rest are suggestions for potentially-useful shortcuts, based on how applicability is used in other products (primarily Satellite and Vulnerability) ### References for comparison * [Pulp2 API](https://docs.pulpproject.org/en/2.21/dev-guide/integration/rest-api/consumer/applicability.html#query-content-applicability) * [VMAAS API](https://webapp-vmaas-stable.1b13.insights.openshiftapps.com/api/ui/) ## Plan * Design approach out to community before break (this doc) * Minimal Viable Product by end of January-2020 * Addresses katello’s use-case(s) * API is solid * Performance will be whatever it is (naive approach) * Post-MVP plans will be driven by: * Community response to additional API needs * Performance under large data loads (10K repos, 250K Packages, 1K NEVRAs - response in 250msec? (wild guess here) (would mean “recalc all 10K of my systems”, from outside, would take 45 min?) ## Testing Applicability testing can be fraught with peril and edge-cases. Correctness-testing needs a defined repository with * At least two Packages with no update * At least two Packages with one update * At least two Packages with three updates * At least two modules with no updates * At least one module with updates The correct-output for the fixture should be determined ‘by hand’ and written into a correctness-file associated with the test-suite. Tests against the known-quantity can then compare directly against the canonical-definition-of-correct data. This known-quantity needs to be available ASAP - ‘correctness’ is The Hard Part of applicability, and we will want to be able to test it from the very beginning. ## Alternatives One alternative we discussed was whether we could just stand up the VMAAS ‘webapp’ service and use its approach. The short answer is “we could”, with something along these lines [drawing needed] : * Webapp stood up in its own container * Teach pulp_rpm to export all its data in webapp-expected format, to that container * Intercept applicability-api-calls, transform to webapp-expected format, gather results * Return results in form desired for Pulp The combination of install/management/monitoring complexity, and memory-impact (webapp in production keeps ~5Gb+ resident in memory at all times) made us decide against this approach. It would certainly be the way to guarantee fastest-possible-performance, however. If we discover performance-at-scale becoming a significant issue, we could go down this path without affecting the exposed API. ## Exposures * Advisory-to-Package not currently modeled in the DB for Pulp3. * Modularity. Computing availability in the face of modularity has turned out to be more exciting than anyone wanted it to be. In addition, there are known problems/errors/ambiguities in modularity, and the canonical definition of ‘correct’ continues to be ‘whatever libdnf is implementing this week’. We are likely to be affected by the complexity (and uncertainty) here. * Edge cases. Not just those introduced by modularity, either. NEVRA ‘is newer than’ has a number of ways to go subtly wrong. At a minimum, this code needs to be wrong **in the same way as everything else** in the RPM ecosystem. Consistency is king. * Fedora and CentOS - make sure everything works for pre- and post-modularity versions. * SUSE. As for CentOS and Fedora, will probably be most impactful of testing. Current installation guidelines explicitly say “requires some dependencies such as libsolv and libmodulemd which is provided only by Red Hat family distributions like Fedora.” This is needed for dependency-resolution, not applicability - but to what degree is Pulp3 suporting SUSE in the short term? ## References [Pulp2 Applicability-query API](https://docs.pulpproject.org/en/2.21/dev-guide/integration/rest-api/consumer/applicability.html#query-content-applicability) [VMAAS improved-EVR_T](https://github.com/RedHatInsights/vmaas/blob/master/database/vmaas_db_postgresql.sql#L2)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully