Skip to content
This repository was archived by the owner on Mar 13, 2021. It is now read-only.

Change the way builds are annotated - #1015

Merged
scothis merged 1 commit into
projectriff:masterfrom
trisberg:annotate-build-spec
Mar 1, 2019
Merged

scothis merged 1 commit into
projectriff:masterfrom
trisberg:annotate-build-spec

Conversation

@trisberg

Copy link
Copy Markdown
Member

Fixes #939

@ericbottard

Copy link
Copy Markdown
Contributor

I can confirm this allows the triggering of a new build with "latest" manifest (while master doesn't)

@trisberg

Copy link
Copy Markdown
Member Author

The getBuild function should really be part of knative. I created a PR here: knative/serving#2737

@trisberg trisberg changed the title Changing the way builds are annotated DNM: Changing the way builds are annotated Dec 20, 2018
@trisberg

Copy link
Copy Markdown
Member Author

We should use the GetBuild method from knative/serving#2737 once we move to 0.3 for serving

@ericbottard

Copy link
Copy Markdown
Contributor

Should we move forward and merge (an updated version of) this now?

@trisberg
trisberg force-pushed the annotate-build-spec branch from 2ec4661 to 74a124d Compare January 22, 2019 17:59
@trisberg trisberg changed the title DNM: Changing the way builds are annotated Update to 0.3.0 Knative deps and Change the way builds are annotated Jan 22, 2019
@trisberg
trisberg force-pushed the annotate-build-spec branch from 74a124d to 80ba9ee Compare January 25, 2019 19:28

@scothis scothis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR is ready to be rebased now that #1062 merged

Comment thread pkg/core/function.go Outdated
Template: &build.TemplateInstantiationSpec{
Name: "riff-cnb",
Arguments: c.makeBuildArguments(options),
Object: &unstructured.Unstructured{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it shouldn't be necessary to fallback to the unstructured option since we are using a Build resource.

Comment thread pkg/core/annotations.go
}

func (c *client) bumpNonceAnnotationForBuild(s *v1alpha1.Service) {
configurationSpec := s.Spec.RunLatest.Configuration

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should we also handle Pinned and Release config modes?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

not in this PR, maybe separate issue

Comment thread pkg/core/annotations.go
configurationSpec := s.Spec.RunLatest.Configuration
build := getBuild(configurationSpec)
if build != nil {
annotations := build.GetAnnotations()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's no need to use the get/set method, you can interact with the Annotations field directly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmmm, just keeping the same code we already had, also not seeing how I can manipulate the annotations directly on an Unstructured object

Comment thread pkg/core/annotations.go
annotations = map[string]string{}
}
nonce := annotations[buildAnnotation]
i, err := strconv.Atoi(nonce)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

rather than futz with conversation and errors, can we simply assign a unique value like build.Generation or build.ResourceVersion if you'd rather a string. Both values are read-only (set by the api server) and guaranteed unique between mutations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

again, just keeping the same logic we already had, maybe we can create a separate PR if we want to change this

Comment thread pkg/core/annotations.go Outdated
}

func getBuild(configSpec v1alpha1.ConfigurationSpec) *unstructured.Unstructured {
// Trap panic from the Knative resources.GetBuild function call

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why does it panic? That seems like something that should be fixed upstream

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

there are a couple of panics in the upstream code, seems to be when the data doesn't match what is expected

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I reworked our tests to create a more complete Build object to avoid triggering a panic

@trisberg
trisberg force-pushed the annotate-build-spec branch from 80ba9ee to 7422bac Compare February 5, 2019 20:58
@trisberg

trisberg commented Feb 5, 2019

Copy link
Copy Markdown
Member Author

rebased

@trisberg
trisberg force-pushed the annotate-build-spec branch from 7422bac to bee6db4 Compare February 6, 2019 01:41
Comment thread pkg/core/annotations.go
"strconv"

"github.com/knative/serving/pkg/apis/serving/v1alpha1"
"github.com/knative/serving/pkg/reconciler/v1alpha1/configuration/resources"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We shouldn't use this package, it's an implementation detail for serving

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

hmm, I agree that it is not ideal, but do you have a better idea how to access the annotations of the build definition embedded in the kservice?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@trisberg trisberg Feb 7, 2019 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That seems worse, at least the implementation in knative is more likely to be maintained even if it is not exposed in the API

@trisberg trisberg changed the title Update to 0.3.0 Knative deps and Change the way builds are annotated Change the way builds are annotated Mar 1, 2019
@trisberg
trisberg force-pushed the annotate-build-spec branch from bee6db4 to 9f62019 Compare March 1, 2019 15:35
@trisberg

trisberg commented Mar 1, 2019

Copy link
Copy Markdown
Member Author

Rebased and squashed

- due to changes in Knative Serving we need to add a full Build as an Unstructured object

- we can then annotated the Build instead of the Revision to trigger a build

- this is necessary after the changes in knative/serving#2402

- use GetBuild method from "reconciler/v1alpha1/configuration/resources"

- fix tests to create Build objects that pass validation

- bump knative/build to 0.4.0
@trisberg
trisberg force-pushed the annotate-build-spec branch from 12850a4 to d6f913e Compare March 1, 2019 19:53
@trisberg

trisberg commented Mar 1, 2019

Copy link
Copy Markdown
Member Author

Rebased and squashed, again

@scothis
scothis merged commit 7856ecb into projectriff:master Mar 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants