Skip to content

Commit

Permalink
Literally just s/Ela/Serving/g (#1249)
Browse files Browse the repository at this point in the history
I noticed a number of helpers in `./pkg/controller` still had `Ela` in their names, this literally replaces that substring across `./pkg/controller` and fixes one collateral breakage in `./pkg/activator`.
  • Loading branch information
mattmoor authored and google-prow-robot committed Jun 18, 2018
1 parent 1d26c3b commit 9b78bd3
Show file tree
Hide file tree
Showing 18 changed files with 78 additions and 78 deletions.
2 changes: 1 addition & 1 deletion pkg/activator/revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (r *revisionActivator) ActiveEndpoint(namespace, name string) (end Endpoint

// Get the revision endpoint
services := r.kubeClient.CoreV1().Services(revision.GetNamespace())
serviceName := controller.GetElaK8SServiceNameForRevision(revision)
serviceName := controller.GetServingK8SServiceNameForRevision(revision)
svc, err := services.Get(serviceName, metav1.GetOptions{})
if err != nil {
return internalError("Unable to get service %s for revision %s/%s: %v",
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type Base struct {
// KubeClientSet allows us to talk to the k8s for core APIs
KubeClientSet kubernetes.Interface

// ServingClientSet allows us to configure Ela objects
// ServingClientSet allows us to configure Serving objects
ServingClientSet clientset.Interface

// BuildClientSet allows us to configure Build objects
Expand Down
12 changes: 6 additions & 6 deletions pkg/controller/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func GetNetworkConfigMapName() string {
}

// Various functions for naming the resources for consistency
func GetElaNamespaceName(ns string) string {
func GetServingNamespaceName(ns string) string {
// We create resources in the same namespace as the Knative Serving resources by default.
// TODO(mattmoor): Expose a knob for creating resources in an alternate namespace.
return ns
Expand All @@ -60,15 +60,15 @@ func GetRouteRuleName(u *v1alpha1.Route, tt *v1alpha1.TrafficTarget) string {
return u.Name + "-istio"
}

func GetElaK8SIngressName(u *v1alpha1.Route) string {
func GetServingK8SIngressName(u *v1alpha1.Route) string {
return u.Name + "-ingress"
}

func GetElaK8SServiceNameForRevision(u *v1alpha1.Revision) string {
func GetServingK8SServiceNameForRevision(u *v1alpha1.Revision) string {
return u.Name + "-service"
}

func GetElaK8SServiceName(u *v1alpha1.Route) string {
func GetServingK8SServiceName(u *v1alpha1.Route) string {
return u.Name + "-service"
}

Expand All @@ -80,7 +80,7 @@ func GetServiceRouteName(u *v1alpha1.Service) string {
return u.Name
}

func GetElaK8SActivatorServiceName() string {
func GetServingK8SActivatorServiceName() string {
return "activator-service"
}

Expand All @@ -93,7 +93,7 @@ func GetRevisionHeaderNamespace() string {
}

func GetOrCreateRevisionNamespace(ctx context.Context, ns string, c clientset.Interface) (string, error) {
return GetOrCreateNamespace(ctx, GetElaNamespaceName(ns), c)
return GetOrCreateNamespace(ctx, GetServingNamespaceName(ns), c)
}

func GetOrCreateNamespace(ctx context.Context, namespace string, c clientset.Interface) (string, error) {
Expand Down
28 changes: 14 additions & 14 deletions pkg/controller/revision/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
)

// MakeElaAutoscalerDeployment creates the deployment of the
// MakeServingAutoscalerDeployment creates the deployment of the
// autoscaler for a particular revision.
func MakeElaAutoscalerDeployment(rev *v1alpha1.Revision, autoscalerImage string) *appsv1.Deployment {
func MakeServingAutoscalerDeployment(rev *v1alpha1.Revision, autoscalerImage string) *appsv1.Deployment {
configName := ""
if owner := metav1.GetControllerOf(rev); owner != nil && owner.Kind == "Configuration" {
configName = owner.Name
Expand All @@ -45,7 +45,7 @@ func MakeElaAutoscalerDeployment(rev *v1alpha1.Revision, autoscalerImage string)
MaxSurge: &intstr.IntOrString{Type: intstr.Int, IntVal: 1},
}

annotations := MakeElaResourceAnnotations(rev)
annotations := MakeServingResourceAnnotations(rev)
annotations[sidecarIstioInjectAnnotation] = "true"

replicas := int32(1)
Expand Down Expand Up @@ -78,20 +78,20 @@ func MakeElaAutoscalerDeployment(rev *v1alpha1.Revision, autoscalerImage string)
ObjectMeta: metav1.ObjectMeta{
Name: controller.GetRevisionAutoscalerName(rev),
Namespace: pkg.GetServingSystemNamespace(),
Labels: MakeElaResourceLabels(rev),
Annotations: MakeElaResourceAnnotations(rev),
Labels: MakeServingResourceLabels(rev),
Annotations: MakeServingResourceAnnotations(rev),
OwnerReferences: []metav1.OwnerReference{*controller.NewRevisionControllerRef(rev)},
},
Spec: appsv1.DeploymentSpec{
Replicas: &replicas,
Selector: MakeElaResourceSelector(rev),
Selector: MakeServingResourceSelector(rev),
Strategy: appsv1.DeploymentStrategy{
Type: "RollingUpdate",
RollingUpdate: &rollingUpdateConfig,
},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: makeElaAutoScalerLabels(rev),
Labels: makeServingAutoScalerLabels(rev),
Annotations: annotations,
},
Spec: corev1.PodSpec{
Expand Down Expand Up @@ -153,15 +153,15 @@ func MakeElaAutoscalerDeployment(rev *v1alpha1.Revision, autoscalerImage string)
}
}

// MakeElaAutoscalerService returns a service for the autoscaler of
// MakeServingAutoscalerService returns a service for the autoscaler of
// the given revision.
func MakeElaAutoscalerService(rev *v1alpha1.Revision) *corev1.Service {
func MakeServingAutoscalerService(rev *v1alpha1.Revision) *corev1.Service {
return &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: controller.GetRevisionAutoscalerName(rev),
Namespace: pkg.GetServingSystemNamespace(),
Labels: makeElaAutoScalerLabels(rev),
Annotations: MakeElaResourceAnnotations(rev),
Labels: makeServingAutoScalerLabels(rev),
Annotations: MakeServingResourceAnnotations(rev),
OwnerReferences: []metav1.OwnerReference{*controller.NewRevisionControllerRef(rev)},
},
Spec: corev1.ServiceSpec{
Expand All @@ -180,10 +180,10 @@ func MakeElaAutoscalerService(rev *v1alpha1.Revision) *corev1.Service {
}
}

// makeElaAutoScalerLabels constructs the labels we will apply to
// makeServingAutoScalerLabels constructs the labels we will apply to
// service and deployment specs for autoscaler.
func makeElaAutoScalerLabels(rev *v1alpha1.Revision) map[string]string {
labels := MakeElaResourceLabels(rev)
func makeServingAutoScalerLabels(rev *v1alpha1.Revision) map[string]string {
labels := MakeServingResourceLabels(rev)
labels[serving.AutoscalerLabelKey] = controller.GetRevisionAutoscalerName(rev)
return labels
}
24 changes: 12 additions & 12 deletions pkg/controller/revision/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func hasHTTPPath(p *corev1.Probe) bool {
return p.Handler.HTTPGet.Path != ""
}

// MakeElaPodSpec creates a pod spec.
func MakeElaPodSpec(rev *v1alpha1.Revision, controllerConfig *ControllerConfig) *corev1.PodSpec {
// MakeServingPodSpec creates a pod spec.
func MakeServingPodSpec(rev *v1alpha1.Revision, controllerConfig *ControllerConfig) *corev1.PodSpec {
configName := ""
if owner := metav1.GetControllerOf(rev); owner != nil && owner.Kind == "Configuration" {
configName = owner.Name
Expand Down Expand Up @@ -122,7 +122,7 @@ func MakeElaPodSpec(rev *v1alpha1.Revision, controllerConfig *ControllerConfig)
}

podSpec := &corev1.PodSpec{
Containers: []corev1.Container{*userContainer, *MakeElaQueueContainer(rev, controllerConfig)},
Containers: []corev1.Container{*userContainer, *MakeServingQueueContainer(rev, controllerConfig)},
Volumes: []corev1.Volume{varLogVolume},
ServiceAccountName: rev.Spec.ServiceAccountName,
}
Expand Down Expand Up @@ -197,15 +197,15 @@ func MakeElaPodSpec(rev *v1alpha1.Revision, controllerConfig *ControllerConfig)
return podSpec
}

// MakeElaDeployment creates a deployment.
func MakeElaDeployment(logger *zap.SugaredLogger, rev *v1alpha1.Revision,
// MakeServingDeployment creates a deployment.
func MakeServingDeployment(logger *zap.SugaredLogger, rev *v1alpha1.Revision,
networkConfig *NetworkConfig, controllerConfig *ControllerConfig) *appsv1.Deployment {
rollingUpdateConfig := appsv1.RollingUpdateDeployment{
MaxUnavailable: &elaPodMaxUnavailable,
MaxSurge: &elaPodMaxSurge,
}

podTemplateAnnotations := MakeElaResourceAnnotations(rev)
podTemplateAnnotations := MakeServingResourceAnnotations(rev)
podTemplateAnnotations[sidecarIstioInjectAnnotation] = "true"

// Inject the IP ranges for istio sidecar configuration.
Expand All @@ -229,25 +229,25 @@ func MakeElaDeployment(logger *zap.SugaredLogger, rev *v1alpha1.Revision,
return &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: controller.GetRevisionDeploymentName(rev),
Namespace: controller.GetElaNamespaceName(rev.Namespace),
Labels: MakeElaResourceLabels(rev),
Annotations: MakeElaResourceAnnotations(rev),
Namespace: controller.GetServingNamespaceName(rev.Namespace),
Labels: MakeServingResourceLabels(rev),
Annotations: MakeServingResourceAnnotations(rev),
OwnerReferences: []metav1.OwnerReference{*controller.NewRevisionControllerRef(rev)},
},
Spec: appsv1.DeploymentSpec{
Replicas: &elaPodReplicaCount,
Selector: MakeElaResourceSelector(rev),
Selector: MakeServingResourceSelector(rev),
Strategy: appsv1.DeploymentStrategy{
Type: "RollingUpdate",
RollingUpdate: &rollingUpdateConfig,
},
ProgressDeadlineSeconds: &progressDeadlineSeconds,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: MakeElaResourceLabels(rev),
Labels: MakeServingResourceLabels(rev),
Annotations: podTemplateAnnotations,
},
Spec: *MakeElaPodSpec(rev, controllerConfig),
Spec: *MakeServingPodSpec(rev, controllerConfig),
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/revision/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
)

// MakeElaQueueContainer creates the container spec for queue sidecar.
func MakeElaQueueContainer(rev *v1alpha1.Revision, controllerConfig *ControllerConfig) *corev1.Container {
// MakeServingQueueContainer creates the container spec for queue sidecar.
func MakeServingQueueContainer(rev *v1alpha1.Revision, controllerConfig *ControllerConfig) *corev1.Container {
configName := ""
if owner := metav1.GetControllerOf(rev); owner != nil && owner.Kind == "Configuration" {
configName = owner.Name
Expand Down
14 changes: 7 additions & 7 deletions pkg/controller/revision/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (

const appLabelKey = "app"

// MakeElaResourceLabels constructs the labels we will apply to K8s resources.
func MakeElaResourceLabels(revision *v1alpha1.Revision) map[string]string {
// MakeServingResourceLabels constructs the labels we will apply to K8s resources.
func MakeServingResourceLabels(revision *v1alpha1.Revision) map[string]string {
labels := make(map[string]string, len(revision.ObjectMeta.Labels)+2)
labels[serving.RevisionLabelKey] = revision.Name
labels[serving.RevisionUID] = string(revision.UID)
Expand All @@ -42,14 +42,14 @@ func MakeElaResourceLabels(revision *v1alpha1.Revision) map[string]string {
return labels
}

// MakeElaResourceSelector constructs the Selector we will apply to K8s resources.
func MakeElaResourceSelector(revision *v1alpha1.Revision) *metav1.LabelSelector {
return &metav1.LabelSelector{MatchLabels: MakeElaResourceLabels(revision)}
// MakeServingResourceSelector constructs the Selector we will apply to K8s resources.
func MakeServingResourceSelector(revision *v1alpha1.Revision) *metav1.LabelSelector {
return &metav1.LabelSelector{MatchLabels: MakeServingResourceLabels(revision)}
}

// MakeElaResourceAnnotations creates the annotations we will apply to
// MakeServingResourceAnnotations creates the annotations we will apply to
// child resource of the given revision.
func MakeElaResourceAnnotations(revision *v1alpha1.Revision) map[string]string {
func MakeServingResourceAnnotations(revision *v1alpha1.Revision) map[string]string {
annotations := make(map[string]string, len(revision.ObjectMeta.Annotations)+1)
for k, v := range revision.ObjectMeta.Annotations {
annotations[k] = v
Expand Down
20 changes: 10 additions & 10 deletions pkg/controller/revision/revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func (c *Controller) SyncEndpoints(endpoint *corev1.Endpoints) {
}

// Check to see if endpoint is the service endpoint
if eName != controller.GetElaK8SServiceNameForRevision(rev) {
if eName != controller.GetServingK8SServiceNameForRevision(rev) {
return
}

Expand Down Expand Up @@ -588,7 +588,7 @@ func (c *Controller) createK8SResources(ctx context.Context, rev *v1alpha1.Revis
func (c *Controller) deleteDeployment(ctx context.Context, rev *v1alpha1.Revision) error {
logger := logging.FromContext(ctx)
deploymentName := controller.GetRevisionDeploymentName(rev)
ns := controller.GetElaNamespaceName(rev.Namespace)
ns := controller.GetServingNamespaceName(rev.Namespace)
dc := c.KubeClientSet.AppsV1().Deployments(ns)
if _, err := dc.Get(deploymentName, metav1.GetOptions{}); err != nil && apierrs.IsNotFound(err) {
return nil
Expand All @@ -608,7 +608,7 @@ func (c *Controller) deleteDeployment(ctx context.Context, rev *v1alpha1.Revisio

func (c *Controller) reconcileDeployment(ctx context.Context, rev *v1alpha1.Revision) error {
logger := logging.FromContext(ctx)
ns := controller.GetElaNamespaceName(rev.Namespace)
ns := controller.GetServingNamespaceName(rev.Namespace)
dc := c.KubeClientSet.AppsV1().Deployments(ns)
// First, check if deployment exists already.
deploymentName := controller.GetRevisionDeploymentName(rev)
Expand All @@ -627,7 +627,7 @@ func (c *Controller) reconcileDeployment(ctx context.Context, rev *v1alpha1.Revi
}

// Create the deployment.
deployment := MakeElaDeployment(logger, rev, c.getNetworkConfig(), c.controllerConfig)
deployment := MakeServingDeployment(logger, rev, c.getNetworkConfig(), c.controllerConfig)

// Resolve tag image references to digests.
if err := c.resolver.Resolve(deployment); err != nil {
Expand All @@ -648,9 +648,9 @@ func (c *Controller) reconcileDeployment(ctx context.Context, rev *v1alpha1.Revi

func (c *Controller) deleteService(ctx context.Context, rev *v1alpha1.Revision) error {
logger := logging.FromContext(ctx)
ns := controller.GetElaNamespaceName(rev.Namespace)
ns := controller.GetServingNamespaceName(rev.Namespace)
sc := c.KubeClientSet.CoreV1().Services(ns)
serviceName := controller.GetElaK8SServiceNameForRevision(rev)
serviceName := controller.GetServingK8SServiceNameForRevision(rev)

logger.Infof("Deleting service %q", serviceName)
tmp := metav1.DeletePropagationForeground
Expand All @@ -666,9 +666,9 @@ func (c *Controller) deleteService(ctx context.Context, rev *v1alpha1.Revision)

func (c *Controller) reconcileService(ctx context.Context, rev *v1alpha1.Revision) (string, error) {
logger := logging.FromContext(ctx)
ns := controller.GetElaNamespaceName(rev.Namespace)
ns := controller.GetServingNamespaceName(rev.Namespace)
sc := c.KubeClientSet.CoreV1().Services(ns)
serviceName := controller.GetElaK8SServiceNameForRevision(rev)
serviceName := controller.GetServingK8SServiceNameForRevision(rev)

if _, err := sc.Get(serviceName, metav1.GetOptions{}); err != nil {
if !apierrs.IsNotFound(err) {
Expand Down Expand Up @@ -785,7 +785,7 @@ func (c *Controller) reconcileAutoscalerService(ctx context.Context, rev *v1alph
return nil
}

service := MakeElaAutoscalerService(rev)
service := MakeServingAutoscalerService(rev)
logger.Infof("Creating autoscaler Service: %q", service.Name)
_, err = sc.Create(service)
return err
Expand Down Expand Up @@ -829,7 +829,7 @@ func (c *Controller) reconcileAutoscalerDeployment(ctx context.Context, rev *v1a
return nil
}

deployment := MakeElaAutoscalerDeployment(rev, c.controllerConfig.AutoscalerImage)
deployment := MakeServingAutoscalerDeployment(rev, c.controllerConfig.AutoscalerImage)
logger.Infof("Creating autoscaler Deployment: %q", deployment.Name)
_, err = dc.Create(deployment)
return err
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/revision/revision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func TestCreateRevCreatesStuff(t *testing.T) {
}

foundQueueProxy := false
foundElaContainer := false
foundServingContainer := false
foundFluentdProxy := false
expectedPreStop := &corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{
Expand Down Expand Up @@ -421,7 +421,7 @@ func TestCreateRevCreatesStuff(t *testing.T) {
}
}
if container.Name == userContainerName {
foundElaContainer = true
foundServingContainer = true
// verify that the ReadinessProbe has our port.
if container.ReadinessProbe.Handler.HTTPGet.Port != intstr.FromInt(queue.RequestQueuePort) {
t.Errorf("Expect ReadinessProbe handler to have port %d, saw %v",
Expand All @@ -446,7 +446,7 @@ func TestCreateRevCreatesStuff(t *testing.T) {
if !foundFluentdProxy {
t.Error("Missing fluentd-proxy container")
}
if !foundElaContainer {
if !foundServingContainer {
t.Errorf("Missing %q container", userContainerName)
}
expectedLabels := sumMaps(
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/revision/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ var servicePort = 80
func MakeRevisionK8sService(rev *v1alpha1.Revision) *corev1.Service {
return &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: controller.GetElaK8SServiceNameForRevision(rev),
Namespace: controller.GetElaNamespaceName(rev.Namespace),
Labels: MakeElaResourceLabels(rev),
Annotations: MakeElaResourceAnnotations(rev),
Name: controller.GetServingK8SServiceNameForRevision(rev),
Namespace: controller.GetServingNamespaceName(rev.Namespace),
Labels: MakeServingResourceLabels(rev),
Annotations: MakeServingResourceAnnotations(rev),
OwnerReferences: []metav1.OwnerReference{*controller.NewRevisionControllerRef(rev)},
},
Spec: corev1.ServiceSpec{
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/route/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func MakeRouteIngress(route *v1alpha1.Route) *v1beta1.Ingress {

path := v1beta1.HTTPIngressPath{
Backend: v1beta1.IngressBackend{
ServiceName: controller.GetElaK8SServiceName(route),
ServiceName: controller.GetServingK8SServiceName(route),
ServicePort: intstr.IntOrString{Type: intstr.String, StrVal: "http"},
},
}
Expand All @@ -62,7 +62,7 @@ func MakeRouteIngress(route *v1alpha1.Route) *v1beta1.Ingress {

return &v1beta1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: controller.GetElaK8SIngressName(route),
Name: controller.GetServingK8SIngressName(route),
Namespace: route.Namespace,
Annotations: map[string]string{
"kubernetes.io/ingress.class": "istio",
Expand Down
Loading

0 comments on commit 9b78bd3

Please sign in to comment.