Skip to content

ContainerSource uses fixed names, rather than GenerateName#1628

Merged
knative-prow-robot merged 2 commits into
knative:masterfrom
Harwayne:containersource-fixedname
Aug 5, 2019
Merged

ContainerSource uses fixed names, rather than GenerateName#1628
knative-prow-robot merged 2 commits into
knative:masterfrom
Harwayne:containersource-fixedname

Conversation

@Harwayne
Copy link
Copy Markdown
Contributor

@Harwayne Harwayne commented Aug 2, 2019

Helps with #1250

Proposed Changes

  • ContainerSource uses fixed names for its receive adapter Deployment.

Release Note

ContainerSource will delete its old receive adapter Deployment only if the ContainerSource
is Ready=True. If the ContainerSource never reaches Ready=True, then a subsequent 
release will ignore any old GenerateName based receive adapter Deployments. They
will be garbage collected when the ContainerSource itself is deleted. 

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Aug 2, 2019
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Harwayne

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

@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 2, 2019
@Harwayne
Copy link
Copy Markdown
Contributor Author

Harwayne commented Aug 2, 2019

/test pull-knative-eventing-unit-tests

@Harwayne
Copy link
Copy Markdown
Contributor Author

Harwayne commented Aug 5, 2019

Ping.

return ra, nil
} else if err != nil {
r.markDeployingAndRecordEvent(src, corev1.EventTypeWarning, "DeploymentGetFailed", "Error getting deployment: %v", err)

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.

remove empty line

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.

return nil, fmt.Errorf("getting deployment: %v", err)
} else if !metav1.IsControlledBy(ra, src) {
r.markDeployingAndRecordEvent(src, corev1.EventTypeWarning, "DeploymentNotOwned", "Deployment %q is not owned by this ContainerSource", ra.Name)
return nil, fmt.Errorf("deploymtn %q is not owned by ContainerSource %q", ra.Name, src.Name)
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.

typo: deploymtn

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.

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.

return ra, fmt.Errorf("updating deployment: %v", err)
}
return ra, nil
} else {
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 think you can get rid of this last else statement and just log

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 don't think so. For example, if the receive adapter isn't found, then it is created. If we moved the log line outside the else, we would log that we are reusing an existing receive adapter.

func (r *Reconciler) podSpecChanged(oldPodSpec corev1.PodSpec, newPodSpec corev1.PodSpec) bool {
// Since the Deployment spec has fields defaulted by the webhook, it won't
// be equal to expected. Use DeepDerivative to compare only the fields that
// are set in expected.
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.

update comment, expected should be oldPodSpec?

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 (switched to newPodSpec).

func (r *Reconciler) createDeployment(ctx context.Context, source *v1alpha1.ContainerSource, args resources.ContainerArguments) (*appsv1.Deployment, error) {
deployment := resources.MakeDeployment(args)
return r.KubeClientSet.AppsV1().Deployments(source.Namespace).Create(deployment)
func (r *Reconciler) deleteOldReceiveAdapter(ctx context.Context, src *v1alpha1.ContainerSource, currentName string) error {
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.

maybe add a TODO that this should be deleted after the 0.8 cut?

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.

@nachocano
Copy link
Copy Markdown
Contributor

/lgtm

/hold for cosmetic comments...

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 5, 2019
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Aug 5, 2019
@knative-metrics-robot
Copy link
Copy Markdown

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

File Old Coverage New Coverage Delta
pkg/reconciler/containersource/containersource.go 81.0% 78.5% -2.5

@nachocano
Copy link
Copy Markdown
Contributor

/hold cancel

@nachocano
Copy link
Copy Markdown
Contributor

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 5, 2019
@Harwayne
Copy link
Copy Markdown
Contributor Author

Harwayne commented Aug 5, 2019

/test pull-knative-eventing-unit-tests

@knative-prow-robot knative-prow-robot merged commit 87169d7 into knative:master Aug 5, 2019
@Harwayne Harwayne deleted the containersource-fixedname branch September 17, 2019 20:32
aliok pushed a commit to aliok/eventing that referenced this pull request Feb 15, 2022
See openshift/release#26101

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>

Co-authored-by: Pierangelo Di Pilato <pierdipi@redhat.com>
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. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants