Skip to content

Start to label builds with a hash of the spec from which they were created. - #2401

Merged
knative-prow-robot merged 1 commit into
knative:masterfrom
mattmoor:label-builds
Nov 6, 2018
Merged

knative-prow-robot merged 1 commit into
knative:masterfrom
mattmoor:label-builds

Conversation

@mattmoor

@mattmoor mattmoor commented Nov 4, 2018

Copy link
Copy Markdown
Contributor

Progress towards: #439

WIP until #2400 merges.

@knative-prow-robot knative-prow-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 4, 2018

@knative-prow-robot knative-prow-robot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mattmoor: 1 warning.

Details

In response to this:

Progress towards: #439

WIP until #2400 merges.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

)

func MakeRevision(config *v1alpha1.Configuration) *v1alpha1.Revision {
func MakeRevision(config *v1alpha1.Configuration, buildRef *corev1.ObjectReference) *v1alpha1.Revision {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Golint comments: exported function MakeRevision should have comment or be unexported. More info.

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 4, 2018
@mattmoor

mattmoor commented Nov 4, 2018

Copy link
Copy Markdown
Contributor Author

ugh, the full sha256 won't work because label values can only be 63 characters...


// Compute the hash of the current build's spec.
hasher := sha256.New()
hasher.Write(config.Spec.Build.Raw)

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 normalize this so that changes in whitespace don't trigger a new build.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm inclined to leave it as-is. I'd wager the Kubernetes API Server already normalizes things and the raw bytes should come from there.

// Compute the hash of the current build's spec.
hasher := sha256.New()
hasher.Write(config.Spec.Build.Raw)
h := hex.EncodeToString(hasher.Sum(nil))

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 a shortcut available sha256.Sum256

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, TIL.

@mattmoor
mattmoor force-pushed the label-builds branch 2 times, most recently from 4507de4 to 7cfee41 Compare November 5, 2018 20:27
@knative-prow-robot knative-prow-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 5, 2018
@mattmoor mattmoor changed the title [WIP] Start to label builds with a hash of the spec from which they were created. Start to label builds with a hash of the spec from which they were created. Nov 5, 2018
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 5, 2018
"blockOwnerDeletion": true,
}},
"labels": map[string]interface{}{
serving.BuildHashLabelKey: "2ee4528bee48a78637ec374eb58cb1977b9611b85545f8b91884ff80b8d9472",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd have expanded the key to be the actual string here and below, but it doesn't look like we do that for any of the other labels. /shrug

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread pkg/apis/serving/register.go Outdated
// generation of the Configuration that created this revision
ConfigurationGenerationLabelKey = GroupName + "/configurationGeneration"

// BuildHashLabelKey is the label key attached to Builds indicating the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

style nit: other comments are in the form "attached to a Foo" instead of "attached to Foos".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@knative-metrics-robot

Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-serving-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/configuration/resources/build.go 83.3% 87.1% 3.8

@jonjohnsonjr

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 5, 2018
@knative-prow-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jonjohnsonjr, mattmoor

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

The pull request process is described here

Details 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

@mattmoor

mattmoor commented Nov 5, 2018

Copy link
Copy Markdown
Contributor Author

/test pull-knative-serving-integration-tests

1 similar comment
@mattmoor

mattmoor commented Nov 6, 2018

Copy link
Copy Markdown
Contributor Author

/test pull-knative-serving-integration-tests

@knative-prow-robot
knative-prow-robot merged commit 8edb403 into knative:master Nov 6, 2018
@mattmoor
mattmoor deleted the label-builds branch November 6, 2018 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants