Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Avoid name conflict by using deployment+delimiter+container as the key #159

Merged
merged 1 commit into from
Mar 30, 2020

Conversation

houshengbo
Copy link

@houshengbo houshengbo commented Mar 30, 2020

Issue to be fixed

Fixes #148

Proposed Changes

Release Note

Copy link
Contributor

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

Choose a reason for hiding this comment

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

@houshengbo: 0 warnings.

In response to this:

Issue to be fixed

Fixes #

Proposed Changes

Release Note

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.

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: houshengbo

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

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

@@ -33,6 +33,7 @@ import (
var (
// The string to be replaced by the container name
containerNameVariable = "${NAME}"
delimiter = "-"
Copy link
Member

Choose a reason for hiding this comment

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

Format Go code:

Suggested change
delimiter = "-"
delimiter = "-"

@houshengbo houshengbo force-pushed the change-container-key branch 2 times, most recently from e912d23 to 4f88185 Compare March 30, 2020 18:18
@@ -33,6 +33,7 @@ import (
var (
// The string to be replaced by the container name
containerNameVariable = "${NAME}"
delimiter = "-"
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought the decision from chat was to use / as a delimiter, am I misremembering?

In particular, because - is allowed in deployment's container names, the override for

deployment-container

is ambiguous, it could mean container in deployment, or it could mean a container called deployment-container.

Copy link
Author

@houshengbo houshengbo Mar 30, 2020

Choose a reason for hiding this comment

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

I got the issue. It looks like I need to switch to /.

func getNewImage(registry *eventingv1alpha1.Registry, containerName string) string {
overrideImage := registry.Override[containerName]
func getNewImage(registry *eventingv1alpha1.Registry, containerName, deploymentName string) string {
overrideImage := registry.Override[deploymentName+delimiter+containerName]
Copy link
Contributor

Choose a reason for hiding this comment

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

Re-using the same override map for deployment and deployment-container style overrides could cause issues if the deployment name contains -, which seems to be possible.

Thoughts on creating two maps, one for container-only overrides and one for deployment+container?

Copy link
Author

Choose a reason for hiding this comment

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

I have changed the delimiter to /.

@@ -172,6 +172,96 @@ var updateDeploymentImageTests = []updateDeploymentImageTest{
Env: []corev1.EnvVar{{Name: "SOME_IMAGE", Value: "docker.io/my/overridden-image"}},
}},
},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to test a few more corner cases:

  • container X in multiple deployments
  • Specify just X-Y, doesn't apply to container called X-Y

@knative-metrics-robot
Copy link

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

File Old Coverage New Coverage Delta
pkg/reconciler/knativeeventing/common/images.go 91.1% 91.5% 0.4

@Cynocracy
Copy link
Contributor

/lgtm

@knative-prow-robot knative-prow-robot merged commit 044d9c4 into knative:master Mar 30, 2020
houshengbo pushed a commit to houshengbo/eventing-operator that referenced this pull request Mar 31, 2020
houshengbo pushed a commit to houshengbo/eventing-operator that referenced this pull request Mar 31, 2020
@aliok
Copy link
Member

aliok commented Apr 3, 2020

I wanted to give this a try today.
All works fine. Precedence of deployment+containerName over containerName is also good.
Image overrides with env vars continue working fine, no regressions there.

Here are the cases I tried:

cat <<EOS |kubectl apply -f -
---
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeEventing
metadata:
  name: knative-eventing
  namespace: knative-eventing
spec:
  registry:
    override:
      eventing-controller: docker.io/foo
EOS
cat <<EOS |kubectl apply -f -
---
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeEventing
metadata:
  name: knative-eventing
  namespace: knative-eventing
spec:
  registry:
    override:
      eventing-controller/eventing-controller: docker.io/foo
EOS
cat <<EOS |kubectl apply -f -
---
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeEventing
metadata:
  name: knative-eventing
  namespace: knative-eventing
spec:
  registry:
    override:
      eventing-controller: docker.io/foo1
      eventing-controller/eventing-controller: docker.io/foo2
EOS
cat <<EOS |kubectl apply -f -
---
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeEventing
metadata:
  name: knative-eventing
  namespace: knative-eventing
spec:
  registry:
    override:
      eventing-controller: docker.io/foo1
      eventing-controller/eventing-controller: docker.io/foo2
      PING_IMAGE: docker.io/foo_ping
EOS

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve the container image override mechanism
7 participants