Skip to content

Commit

Permalink
Issue #630 - stop PackageRevision updates from changing creationTimes…
Browse files Browse the repository at this point in the history
…tamp

- wired CreationTimestamp in from underlying PackageRev CR when getting
  a PackageRevision together from Git
  - as mentioned as an option in old comment
    kptdev/kpt#3992 (comment)
  - and same in OCI implementation for consistency's sake
  - previous implementation got CreationTimestamp from 'updated' attribute
    which is got from the creation timestamp of the latest commit to the
    branch in Git, and so kept changing
    - underlying PackageRev CR is a Kubernetes object and has a static
      creationTimestamp
- wired PackageRev details/ObjectMeta data into PackageRevision returned
  from update-package-resources flow
  - was previously just empty values with a zero timestamp
  - which broke a test once the creationTimestamp fix was applied

nephio-project/nephio#630
  • Loading branch information
JamesMcDermott committed Feb 11, 2025
1 parent 1d6ba30 commit ab8911b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@ func (cad *cadEngine) UpdatePackageResources(ctx context.Context, repositoryObj
if err != nil {
return nil, renderStatus, err
}
repoPkgRev.SetMeta(rev.ObjectMeta)

return repoPkgRev, renderStatus, nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/git/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (p *gitPackageRevision) GetPackageRevision(ctx context.Context) (*v1alpha1.
UID: p.uid(),
ResourceVersion: p.commit.String(),
CreationTimestamp: metav1.Time{
Time: p.updated,
Time: p.metadata.CreationTimestamp.Time,
},
},
Spec: v1alpha1.PackageRevisionSpec{
Expand Down Expand Up @@ -209,7 +209,7 @@ func (p *gitPackageRevision) GetResources(ctx context.Context) (*v1alpha1.Packag
UID: p.uid(),
ResourceVersion: p.commit.String(),
CreationTimestamp: metav1.Time{
Time: p.updated,
Time: p.metadata.CreationTimestamp.Time,
},
OwnerReferences: []metav1.OwnerReference{}, // TODO: should point to repository resource
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (p *ociPackageRevision) GetResources(ctx context.Context) (*v1alpha1.Packag
Name: p.KubeObjectName(),
Namespace: p.parent.namespace,
CreationTimestamp: metav1.Time{
Time: p.created,
Time: p.metadata.CreationTimestamp.Time,
},
ResourceVersion: p.resourceVersion,
UID: p.uid,
Expand Down Expand Up @@ -351,7 +351,7 @@ func (p *ociPackageRevision) GetPackageRevision(ctx context.Context) (*v1alpha1.
Name: p.KubeObjectName(),
Namespace: p.parent.namespace,
CreationTimestamp: metav1.Time{
Time: p.created,
Time: p.metadata.CreationTimestamp.Time,
},
ResourceVersion: p.resourceVersion,
UID: p.uid,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ func (t *PorchSuite) TestUpdateResourcesEmptyPatch(ctx context.Context) {
}, &resourcesAfterUpdate)

assert.Equal(t, 3, len(resourcesAfterUpdate.Spec.Resources))
assert.True(t, reflect.DeepEqual(resourcesBeforeUpdate, resourcesAfterUpdate))
assert.EqualValues(t, resourcesBeforeUpdate, resourcesAfterUpdate)
}

func (t *PorchSuite) TestConcurrentResourceUpdates(ctx context.Context) {
Expand Down

0 comments on commit ab8911b

Please sign in to comment.