Skip to content
This repository was archived by the owner on Jun 24, 2020. It is now read-only.

Conversation

@trshafer
Copy link
Contributor

@trshafer trshafer commented Jun 20, 2019

Fixes #1.

@k4leung4 k4leung4 changed the title Add ability to update the image and tag of knative serving images [WIP] Add ability to update the image and tag of knative serving images Jun 20, 2019
Copy link
Contributor

@greghaynes greghaynes left a comment

Choose a reason for hiding this comment

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

A couple nits but LGTM.

UpdateConfigMap(u, data, log)
}
}
if u.GetKind() == "Deployment" {
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment on line 60 should get moved in to this function block now since it is not purely about config overriding

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Choose a reason for hiding this comment

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

I think it's one challenge here, just consider the image url in deployment.
Actually, there is image url in configmap, event in args in pod definition.
Could we have a common solution to pick them up and do replacement, use regex or something.

Copy link
Contributor Author

@trshafer trshafer Jul 2, 2019

Choose a reason for hiding this comment

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

I'm concerned with a common solution that supports replacing all possible values. I think if the configmap values need to be changed, they should use the config key that mutates configmaps.

The Image kind needs to be able to be updated though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to support Image

}
}

// Set some data in a configmap, only overwriting common keys if they differ
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment leftover from somewhere?

I'd also expect it to start with // UpdateImage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@trshafer trshafer force-pushed the add-image branch 2 times, most recently from b874955 to ce4fe0f Compare June 20, 2019 23:24
Copy link
Contributor

@jcrossley3 jcrossley3 left a comment

Choose a reason for hiding this comment

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

Looks good! I think we only need to update the CRD file.

registry := instance.Spec.Image.Image
tag := instance.Spec.Image.Tag
var deployment *appsv1.Deployment
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.Object, deployment); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I've been using scheme.Convert to do this in other places, but I'm not sure if either is preferred. It makes me think maybe the controller's scheme should be made available in this function though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

result = append(result, extension.Transformers...)
}
// Let any config in instance override everything else
return append(result, func(u *unstructured.Unstructured) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we start adding more conditions in here, it might make more sense to define mf.Transformer functions elsewhere in the file and reference them here, similar to the mf.Inject* functions above (though they wouldn't have to be closures). I'll let you decide whether we do that now or later.

Choose a reason for hiding this comment

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

Right, if manifestival could supply something like InjectImageURL, that's will be great.

// +optional
Config map[string]map[string]string `json:"config,omitempty"`

Image Registry `json:"registry,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should include the proper updates to deploy/crds/serving_v1alpha1_knativeserving_crd.yaml with this PR. Either manually or via operator-sdk generate k8s

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

unstructured.SetNestedField(cm.Object, v, "data", k)
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't love the name "helpers.go" for this file (my fault), and you've added so many related functions that I might lean toward putting them in their own say, "images.go" file? Still in the common package, of course.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@trshafer trshafer force-pushed the add-image branch 4 times, most recently from e7ed236 to f4dba39 Compare June 24, 2019 15:37
@k4leung4
Copy link
Contributor

/test pull-knative-serving-operator-go-coverage

@trshafer trshafer force-pushed the add-image branch 3 times, most recently from eab4ac6 to 82d87a3 Compare June 25, 2019 22:08
@trshafer trshafer changed the title [WIP] Add ability to update the image and tag of knative serving images Add ability to update the image and tag of knative serving images Jun 25, 2019
@trshafer
Copy link
Contributor Author

trshafer commented Jun 25, 2019

I have verified that this works with:

apiVersion: serving.knative.dev/v1alpha1
kind: KnativeServing
metadata:
  name: knative-serving
spec:
  registry:
    default-registry: "my-registry.io/my-build/knative/cmd"
    default-tag: "v0.6.0"

How do you feel about this CRD?

Should it be:

spec:
  registry:
    default:
      registry: my-registry.io/my-build/knative/cmd
      tag: v0.6.0

It's a bit strange to have a default but not support the other services in the crd. Should this also support the other services before merging?

func updateDeployment(scheme *runtime.Scheme, instance *servingv1alpha1.KnativeServing, u *unstructured.Unstructured) error {

var deployment = &appsv1.Deployment{}
err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.Object, deployment)
Copy link
Contributor

Choose a reason for hiding this comment

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

is this better than scheme.Convert(u, deployment)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't get scheme.Convert(u, deployment) to work. I got error message TypeMeta not present in src which comes from https://github.com/kubernetes/apimachinery/blob/961b39a1baa06f6c52bdd048a809b9f5b47f1337/pkg/conversion/converter.go#L828. The issue I believe is TypeMeta

metav1.TypeMeta `json:",inline"`
is not in the unstructured map. It's unable to take the inline json content and convert it to a Deployment. This way worked.

I'll look more into the scheme tests and see if I can reproduce this issue: https://github.com/kubernetes/apimachinery/blob/961b39a1baa06f6c52bdd048a809b9f5b47f1337/pkg/runtime/scheme_test.go#L1

type Registry struct {
DefaultRegistry string `json:"default-registry,omitempty"`
DefaultTag string `json:"default-tag,omitempty"`
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the "Default*" prefix meant to imply? Why not just Name and Tag as the only elements of the Registry struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per comment #20 (comment), it demonstrates the that this is the default registry and tag to use. I am starting to prefer the nested default map.

@jcrossley3
Copy link
Contributor

jcrossley3 commented Jun 25, 2019

How do you feel about this CRD?

Should it be:

spec:
  registry:
    default:
      registry: my-registry.io/my-build/knative/cmd
      tag: v0.6.0

Personally, I'd prefer not to see "registry" used in two places: how about just name and tag?

It's a bit strange to have a default but not support the other services in the crd. Should this also support the other services before merging?

What other services? Like activator or autoscaler? So something like this?

spec:
  registry:
    default:
      name: my-registry.io/my-build/knative/cmd
      tag: v0.6.0
    autoscaler:
      name: my-other-registry.io/my-build/knative/cmd
      tag: v0.6.1

@jcrossley3
Copy link
Contributor

Also, would we expect this to be affected as well?

queueSidecarImage: gcr.io/knative-releases/github.com/knative/serving/cmd/queue@sha256:1e40c99ff5977daa2d69873fff604c6d09651af1f9ff15aadf8849b3ee77ab45

registry: "new-registry.io/test/path",
tag: "new-tag",
expected: "new-registry.io/test/path/queue:new-tag",
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Another challenge just occurred to me: RHT currently renames its images with a knative-serving- prefix, so queue becomes knative-serving-queue. Hence, our image name will be quay.io/openshift-knative/knative-serving-queue:v0.6.0. Will the current logic stick a / in there? If so, can we just expect the separator to be in the name, e.g quay.io/openshift-knative/knative-serving- and new-registry.io/test/path/?

@trshafer
Copy link
Contributor Author

Per comment #20 (comment), @greghaynes suggested an option that supports both a default and an individual override: #1 (comment). Your suggestion is the correct assumption. I should probably the ability to override the default per service in this PR, so I don't need to circle back again.

@trshafer
Copy link
Contributor Author

Per comment #20 (comment), that's a good question. I don't think so, but it would be surprising. Is it unreasonable for the user to make the CR:

spec:
  config:
    deployment: my-registry.io/my-build/knative/cmd/queue:v0.6.0
  registry:
    default:
      name: my-registry.io/my-build/knative/cmd
      tag: v0.6.0

What's unfortunate is the user will always need to do this, which is pretty non-obvious. @greghaynes @jcrossley3 what do you think?

@trshafer trshafer force-pushed the add-image branch 9 times, most recently from 66c69d1 to 3963496 Compare July 2, 2019 20:51
Copy link
Contributor

@jcrossley3 jcrossley3 left a comment

Choose a reason for hiding this comment

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

Only minor nits, so...
/lgtm

type Registry struct {
// The default image reference template to use for all knative images.
// It takes the form of example-registry.io/custom/path/${NAME}:custom-tag
// ${NAME} will be replaced by the deployment name.
Copy link
Contributor

Choose a reason for hiding this comment

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

Deployment name? Container? Image? Basename?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

// +optional
Config map[string]map[string]string `json:"config,omitempty"`

// A means to override the corresponding deployment images in the upstream deployments.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/deployment //

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


func updateCachingImage(scheme *runtime.Scheme, instance *servingv1alpha1.KnativeServing, u *unstructured.Unstructured) error {
var image = &caching.Image{}
err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.Object, image)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll look into why scheme.Convert doesn't work after this is merged.

…the Deployment Containers

Adds knative.dev/caching dependency
@knative-metrics-robot
Copy link

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

File Old Coverage New Coverage Delta
pkg/controller/knativeserving/common/config_maps.go Do not exist 0.0%
pkg/controller/knativeserving/common/extensions.go Do not exist 0.0%
pkg/controller/knativeserving/common/images.go Do not exist 100.0%

@knative-prow-robot
Copy link
Contributor

@trshafer: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-knative-serving-operator-go-coverage be16a31 link /test pull-knative-serving-operator-go-coverage

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

@jcrossley3
Copy link
Contributor

/lgtm

Copy link
Member

@evankanderson evankanderson left a comment

Choose a reason for hiding this comment

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

/lgtm
/hold cancel

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.

Operator should be able to install from different registries and tags

8 participants