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

Have PackageVariant set readiness gate on PackageRevisions #156

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

JamesMcDermott
Copy link
Contributor

@JamesMcDermott JamesMcDermott commented Dec 10, 2024

Implements #615

  • incoming ReadinessGates and Conditions are now saved in PackageRevision creation flows

    • this includes init and clone operations
      • a new PackageRevision now has the PackagePipelinePassed Condition and
        ReadinessGate by default
      • set to False on creation, but the initial (no-op) render run effectively
        sets it to True by default
      • API-based init operations (Create) will include any Conditions passed in
        in the request
        • and add ReadinessGates based on the Conditions
  • a successful render run sets the PackagePipelinePassed condition:

    • to False before starting
    • to True on successful completion
    • effectively preventing the PackageRevision from being proposed using porchctl
      rpkg propose while the pipeline is running
      • a future commit will move this validation from porchctl into the API server
        to lock out API-based propose operations as well
  • PackageVariant controller now sets its own condition and readiness gate on PackageRevisions it manages

    • and manages this Condition independently to allow it to lock out propose operations while the controller is performing multiple operations
  • PackageVariant controller can now handle optimistic concurrency conflicts when making its final (per-reconcile) status update to a PackageVariant

  • refactors internal conversion of Kptfiles to YAML since readiness condition information is stored in the package Kptfile

    • unifies all cases to the same kyaml/yaml-based method (KptFile.ToYamlString() and ToYamlString(*fn.KubeObject))
    • this ensures consistency in the Kptfile YAML (indentation, field order etc.)
    • and reduces the chances of Git conflicts when setting and updating readiness conditions
  • adds more info to error message in case of Git conflict when applying a patch

  • CLI E2E tests now give more information on failure

    • pointing out config.yaml file containing command that produced unexpected result and 0-based index of the failed command in that file
  • CLI E2E tests now fail on first test failure to allow easier identification of the failed test's output

  • some refactoring/renaming for readbility

  • fixed typo in Makefile comment

@efiacor
Copy link
Collaborator

efiacor commented Dec 10, 2024

/test presubmit-nephio-go-test

@@ -334,6 +350,13 @@ func (r *PackageVariantReconciler) ensurePackageVariant(ctx context.Context,
if err = r.Client.Create(ctx, newPR); err != nil {
return nil, err
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'd be interested to see how this works in a full test-infra e2e run.
Also, may be somewhat aligned with what @kispaljr was working on?

@efiacor
Copy link
Collaborator

efiacor commented Dec 10, 2024

/test presubmit-nephio-go-test

5 similar comments
@JamesMcDermott
Copy link
Contributor Author

/test presubmit-nephio-go-test

@JamesMcDermott
Copy link
Contributor Author

/test presubmit-nephio-go-test

@JamesMcDermott
Copy link
Contributor Author

/test presubmit-nephio-go-test

@liamfallon
Copy link
Member

/test presubmit-nephio-go-test

@JamesMcDermott
Copy link
Contributor Author

/test presubmit-nephio-go-test

Copy link
Collaborator

@kispaljr kispaljr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I welcome this PR, and wholeheartedly agree with the general direction. :)
These are my initial comments, but could you give me also a couple more days to understand the logic a bit better?

- PackageVariant controller now uses a readiness gate to allow
  a PackageRevision to complete its mutation pipeline before it
  is allowed to be proposed/approved
- refactored conversion of Kptfiles to YAML since readiness condition
  information is stored in the package Kptfile
  - unified all cases to the same kyaml/yaml-based method
    (KptFile.ToYamlString() and ToYamlString(*fn.KubeObject))
  - this ensures consistency in the YAML (indentation, field order etc.)
  - and reduces the chances of Git conflicts when setting and updating
    readiness conditions
- added more info to error message in case of Git conflict when applying
  a patch

nephio-project/nephio#615
- previous solution broke existing functionality to copy comments between Kptfile objects
  - resulting in failing unit tests
    - fix for that brought back the Git conflicts caused by indentation, field order etc.
    - re-refactored conversion of Kptfiles to YAML
      - KubeObject-related conversion methods (KubeObject/YAML and YAML/KubeObject)
        now live out in the util package as they aren't Kptfile-specific any more

nephio-project/nephio#615
@JamesMcDermott JamesMcDermott force-pushed the pv-pipeline-readiness-gates branch from 3cff6bb to 60cb107 Compare December 17, 2024 10:30
… pipeline-passed condition

- review comments to increase applicability of pipeline-passed readiness condition
  - to enable this: if an incoming PackageRevision update changes only that
    readiness condition, detect that, skip the pipeline/rendering/etc., and
    only update the Kptfile with the readiness condition update
- other tidy-up/wording comments

nephio-project/nephio#615
…on flows

- this includes both init and clone operations
  - a new PackageRevision now has the PackagePipelinePassed Condition and
    ReadinessGate by default
  - set to False on creation, but the initial (no-op) render run effectively
    sets it to True by default
  - API-based init operations (Create) will include any Conditions passed in
    in the request
    - and add ReadinessGates based on the Conditions
- a successful render run sets the PackagePipelinePassed condition:
  - to False before starting
  - to True on successful completion
  - effectively preventing the PackageRevision from being proposed using porchctl
    rpkg propose while the pipeline is running
    - a future commit will move this validation from porchctl into the API server
      to lock out API-based propose operations as well
- PackageVariant controller sets its own condition and readiness gate on
  PackageRevisions it manages
  - and manages this Condition independently to allow it to lock out propose
    operations while the controller is performing multiple operations
- PackageVariant controller can handle optimistic concurrency conflicts when
  making its final (per-reconcile) status update to a PackageVariant
- some refactoring/renaming for readbility
- fixed typo in Makefile comment

nephio-project/nephio#615
…erver

- apply readiness-gate lockout to API operations as well as porchctl CLI

nephio-project/nephio#615
@@ -516,6 +535,35 @@ func (cad *cadEngine) UpdatePackageResources(ctx context.Context, repositoryObj
return repoPkgRev, renderStatus, nil
}

func pushPipelineReadinessGate(ctx context.Context, repo repository.Repository, repoPr repository.PackageRevision) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the engine handling of drafts even more complex but there is no oopter way to do this with the current code structure. Let's refactor engine.go in Nephio R5.

Copy link
Member

@liamfallon liamfallon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

Very comprehensive work @JamesMcDermott

Copy link
Contributor

nephio-prow bot commented Feb 4, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JamesMcDermott, liamfallon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@nephio-prow nephio-prow bot added the approved label Feb 4, 2025
JamesMcDermott added a commit to Nordix/nephio-docs that referenced this pull request Feb 10, 2025
- new document describing operation of readiness gates on PackageRevisions
  - in general (no existing document for it)
  - specifically the changes introduced in
    nephio-project/porch#156
    - including default readiness gates managed by Porch server for all
      PackageRevisions and by package variant controller for PackageRevisions
      controlled by a PackageVariant
- new diagram to illustrate flows

nephio-project/nephio#615
nephio-project/porch#156
@kispaljr
Copy link
Collaborator

I read through the latest code changes. All my previous comments are now resolved.
I focused my review on the pkg/task package, and that seems excellent to me.

all-in-all: it looks good to me, it can be merged from my part

Copy link
Collaborator

@kispaljr kispaljr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, as we already discussed on Slack, it would make porch behavior more consistent if the readinessGates + conditions would be also merged from the PR objects that are created with an edit task (similarly how you implemented it to clone and init), but that is not mandatory. This PR can be merged without that.

@efiacor
Copy link
Collaborator

efiacor commented Feb 25, 2025

Need to run it through a few e2e runs. Hit an issue on the free5gc suite. Will run again and collect data if it's a recurring issue.

- Edit operation now includes ReadinessGates and Conditions passed
  in as part of the edit request
  - adding them to existing ones from the Kptfile in the
    PackageRevision being edited
- Init, Edit, and Clone operations now merge their lists of
  Conditions/ReadinessGates (any passed in in the API request
  are added to the defaults/existing ones)
  - instead of using slices.Concat which allowed duplicates
    (with same Condition.Type) to stay
  - Conditions/ReadinessGates passed in in the API request
    will OVERRIDE default/existing ones

nephio-project/nephio#615
- Edit operation now includes ReadinessGates and Conditions passed
  in as part of the edit request
  - adding them to existing ones from the Kptfile in the
    PackageRevision being edited
- Init, Edit, and Clone operations now merge their lists of
  Conditions/ReadinessGates (any passed in in the API request
  are added to the defaults/existing ones)
  - instead of using slices.Concat which allowed duplicates
    (with same Condition.Type) to stay
  - Conditions/ReadinessGates passed in in the API request
    will OVERRIDE default/existing ones

nephio-project/nephio#615
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants