Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an initial importer for Image Repositories #1303

Merged
merged 4 commits into from
Mar 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions examples/image-repositories/image-repositories.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"name": "ruby-20-centos7"
},
"tags": {
"latest": "latest"
}
},
{
Expand All @@ -20,7 +19,6 @@
"name": "nodejs-010-centos7"
},
"tags": {
"latest": "latest"
}
},
{
Expand All @@ -31,7 +29,6 @@
"name": "wildfly-8-centos"
},
"tags": {
"latest": "latest"
}
}
],
Expand Down
3 changes: 2 additions & 1 deletion examples/sample-app/application-template-dockerbuild.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"kind": "ImageRepository",
"metadata": {
"name": "ruby-20-centos7"
}
},
"dockerImageRepository": "openshift/ruby-20-centos7"
},
{
"apiVersion": "v1beta1",
Expand Down
3 changes: 2 additions & 1 deletion examples/sample-app/application-template-stibuild.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"kind": "ImageRepository",
"metadata": {
"name": "ruby-20-centos7"
}
},
"dockerImageRepository": "openshift/ruby-20-centos7"
},
{
"apiVersion": "v1beta1",
Expand Down
7 changes: 5 additions & 2 deletions hack/test-cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,9 @@ osc create -f examples/image-repositories/image-repositories.json
[ -n "$(osc get imageRepositories wildfly-8-centos -t "{{.status.dockerImageRepository}}")" ]
osc delete imageRepositories ruby-20-centos7
osc delete imageRepositories nodejs-010-centos7
osc delete imageRepositories wildfly-8-centos
[ -z "$(osc get imageRepositories ruby-20-centos7 -t "{{.status.dockerImageRepository}}")" ]
[ -z "$(osc get imageRepositories nodejs-010-centos7 -t "{{.status.dockerImageRepository}}")" ]
[ -z "$(osc get imageRepositories wildfly-8-centos -t "{{.status.dockerImageRepository}}")" ]
# don't delete wildfly-8-centos
echo "imageRepositories: ok"

osc create -f test/integration/fixtures/test-image-repository.json
Expand Down Expand Up @@ -324,4 +323,8 @@ openshift ex registry --create --credentials="${OPENSHIFTCONFIG}"
[ "$(openshift ex registry | grep 'service exists')" ]
echo "ex registry: ok"

# verify the image repository had its tags populated
[ -n "$(osc get imageRepositories wildfly-8-centos -t "{{.tags.latest}}")" ]
[ -n "$(osc get imageRepositories wildfly-8-centos -t "{{ index .metadata.annotations \"openshift.io/image.dockerRepositoryCheck\"}}")" ]

osc get minions,pods
2 changes: 1 addition & 1 deletion hack/test-end-to-end.sh
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ osc create -n test -f "${STI_CONFIG_FILE}"

# Trigger build
echo "[INFO] Starting build from ${STI_CONFIG_FILE} and streaming its logs..."
osc start-build -n test ruby-sample-build --follow
#osc start-build -n test ruby-sample-build --follow
wait_for_build "test"
wait_for_app "test"

Expand Down
69 changes: 35 additions & 34 deletions pkg/build/controller/image_change_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package controller
import (
"fmt"

"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/golang/glog"

"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"

buildapi "github.com/openshift/origin/pkg/build/api"
buildclient "github.com/openshift/origin/pkg/build/client"
buildutil "github.com/openshift/origin/pkg/build/util"
Expand Down Expand Up @@ -33,63 +35,62 @@ type ImageChangeController struct {
}

// HandleImageRepo processes the next ImageRepository event.
func (c *ImageChangeController) HandleImageRepo(imageRepo *imageapi.ImageRepository) error {
glog.V(4).Infof("Build image change controller detected imagerepo change %s", imageRepo.DockerImageRepository)
imageSubstitutions := make(map[string]string)
func (c *ImageChangeController) HandleImageRepo(repo *imageapi.ImageRepository) error {
glog.V(4).Infof("Build image change controller detected imagerepo change %s", repo.Status.DockerImageRepository)
subs := make(map[string]string)
Copy link
Contributor

Choose a reason for hiding this comment

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

-1


// TODO: this is inefficient
for _, bc := range c.BuildConfigStore.List() {
config := bc.(*buildapi.BuildConfig)
glog.V(4).Infof("Detecting changed images for buildConfig %s", config.Name)

// Extract relevant triggers for this imageRepo for this config
shouldTriggerBuild := false
shouldBuild := false
// For every ImageChange trigger find the latest tagged image from the image repository and replace that value
// throughout the build strategies. A new build is triggered only if the latest tagged image id or pull spec
// differs from the last triggered build recorded on the build config.
for _, trigger := range config.Triggers {
if trigger.Type != buildapi.ImageChangeBuildTriggerType {
continue
}
icTrigger := trigger.ImageChange
change := trigger.ImageChange
Copy link
Contributor

Choose a reason for hiding this comment

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

-1, it's not a change, it's a trigger. specifically an image change trigger.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, it's the parameters to an image change trigger. It's the definition of what should change.

----- Original Message -----

    for _, trigger := range config.Triggers {
        if trigger.Type != buildapi.ImageChangeBuildTriggerType {
            continue
        }
  •       icTrigger := trigger.ImageChange
    
  •       change := trigger.ImageChange
    

-1, it's not a change, it's a trigger. specifically an image change trigger.


Reply to this email directly or view it on GitHub:
https://github.com/openshift/origin/pull/1303/files#r26478655

Copy link
Contributor

Choose a reason for hiding this comment

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

the parameters would include the actual new imageid, this doesn't. this is the vessel, not the values.

// only trigger a build if this image repo matches the name and namespace of the ref in the build trigger
// also do not trigger if the imagerepo does not have a valid DockerImageRepository value for us to pull
// the image from
if imageRepo.Status.DockerImageRepository == "" || icTrigger.From.Name != imageRepo.Name || (len(icTrigger.From.Namespace) != 0 && icTrigger.From.Namespace != imageRepo.Namespace) {
if repo.Status.DockerImageRepository == "" || change.From.Name != repo.Name || (len(change.From.Namespace) != 0 && change.From.Namespace != repo.Namespace) {
Copy link
Contributor

Choose a reason for hiding this comment

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

-1 to removing code comments explaining the logical flow.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the comments were moved up (and reworded a bit) - see line 47.

Copy link
Contributor

Choose a reason for hiding this comment

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

so they were. +1 to cancel my -1. :)

continue
}
// for every ImageChange trigger, record the image it substitutes for and get the latest
// image id from the imagerepository. We will substitute all images in the buildconfig
// with the latest values from the imagerepositories.
tag := icTrigger.Tag
if len(tag) == 0 {
tag = buildapi.DefaultImageTag
}
latest, err := imageapi.LatestTaggedImage(*imageRepo, tag)
latest, err := imageapi.LatestTaggedImage(repo, change.Tag)
if err != nil {
glog.V(2).Info(err)
util.HandleError(fmt.Errorf("unable to find tagged image: %v", err))
continue
}

// (must be different) to trigger a build
if icTrigger.LastTriggeredImageID != latest.Image {
imageSubstitutions[icTrigger.Image] = latest.DockerImageReference
shouldTriggerBuild = true
icTrigger.LastTriggeredImageID = latest.Image
last := change.LastTriggeredImageID
next := latest.Image
if len(next) == 0 {
// tags without images should still trigger builds (when going from a pure tag to an image
// based tag, we should rebuild)
next = latest.DockerImageReference
}
if len(last) == 0 || next != last {
subs[change.Image] = latest.DockerImageReference
Copy link
Contributor

Choose a reason for hiding this comment

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

DockerImageReference is a fully qualified/tagged/immutable value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

----- Original Message -----

            continue
        }

        // (must be different) to trigger a build
  •       if icTrigger.LastTriggeredImageID != latest.Image {
    
  •           imageSubstitutions[icTrigger.Image] = latest.DockerImageReference
    
  •           shouldTriggerBuild = true
    
  •           icTrigger.LastTriggeredImageID = latest.Image
    
  •       last := change.LastTriggeredImageID
    
  •       next := latest.Image
    
  •       if len(next) == 0 {
    
  •           // tags without images should still trigger builds (when going from a
    
    pure tag to an image
  •           // based tag, we should rebuild)
    
  •           next = latest.DockerImageReference
    
  •       }
    
  •       if len(last) == 0 || next != last {
    
  •           subs[change.Image] = latest.DockerImageReference
    

DockerImageReference is a fully qualified/tagged/immutable value?


Reply to this email directly or view it on GitHub:
https://github.com/openshift/origin/pull/1303/files#r26511971

change.LastTriggeredImageID = next
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be latest.DockerImageReference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, see the comment that tags are not required to have images (we may not have a record of the image, but we may still have a pull spec)

----- Original Message -----

            continue
        }

        // (must be different) to trigger a build
  •       if icTrigger.LastTriggeredImageID != latest.Image {
    
  •           imageSubstitutions[icTrigger.Image] = latest.DockerImageReference
    
  •           shouldTriggerBuild = true
    
  •           icTrigger.LastTriggeredImageID = latest.Image
    
  •       last := change.LastTriggeredImageID
    
  •       next := latest.Image
    
  •       if len(next) == 0 {
    
  •           // tags without images should still trigger builds (when going from a
    
    pure tag to an image
  •           // based tag, we should rebuild)
    
  •           next = latest.DockerImageReference
    
  •       }
    
  •       if len(last) == 0 || next != last {
    
  •           subs[change.Image] = latest.DockerImageReference
    
  •           change.LastTriggeredImageID = next
    

shouldn't this be latest.DockerImageReference?


Reply to this email directly or view it on GitHub:
https://github.com/openshift/origin/pull/1303/files#r26512121

Copy link
Contributor

Choose a reason for hiding this comment

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

that's my point... what we should be recording here is the exact pull spec we used last time we built this, so we don't build it again using that same pull spec.

i'm not clear on what "latest.Image" is (i haven't read this full PR) but it doesn't seem as uniquely identifying to a specific imageid/hash.

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're pulling from an external registry and it doesn't support pull by id (v2 registry or the tag/id hack we're doing for v1), then the best you can do is pull by tag.

latest.Image is an actual image id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ImageID is not guaranteed to be there. PullSpec is. If you transfer a tag from a pull spec to an image, or an image to a pull spec, then a change triggers the build. We need to store something. The field is poorly named.

----- Original Message -----

            continue
        }

        // (must be different) to trigger a build
  •       if icTrigger.LastTriggeredImageID != latest.Image {
    
  •           imageSubstitutions[icTrigger.Image] = latest.DockerImageReference
    
  •           shouldTriggerBuild = true
    
  •           icTrigger.LastTriggeredImageID = latest.Image
    
  •       last := change.LastTriggeredImageID
    
  •       next := latest.Image
    
  •       if len(next) == 0 {
    
  •           // tags without images should still trigger builds (when going from a
    
    pure tag to an image
  •           // based tag, we should rebuild)
    
  •           next = latest.DockerImageReference
    
  •       }
    
  •       if len(last) == 0 || next != last {
    
  •           subs[change.Image] = latest.DockerImageReference
    
  •           change.LastTriggeredImageID = next
    

If we're pulling from an external registry and it doesn't support pull by id
(v2 registry or the tag/id hack we're doing for v1), then the best you can
do is pull by tag.

latest.Image is an actual image id


Reply to this email directly or view it on GitHub:
https://github.com/openshift/origin/pull/1303/files#r26513301

Copy link
Contributor

Choose a reason for hiding this comment

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

(and if there is a reason to run that build again, because latest.DockerImageReference does not uniquely identify a specific image hash and you want to pick up the new layer that latest.DockerImageReference now represents, then this change is breaking the fundamental premise of the image change controller which is that the build it produces can be rerun at any time and will use the exact same image layers)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we have virtual pull specs (tag points to id) the only thing that will change will be the id. But a build should be triggered anyway.

----- Original Message -----

            continue
        }

        // (must be different) to trigger a build
  •       if icTrigger.LastTriggeredImageID != latest.Image {
    
  •           imageSubstitutions[icTrigger.Image] = latest.DockerImageReference
    
  •           shouldTriggerBuild = true
    
  •           icTrigger.LastTriggeredImageID = latest.Image
    
  •       last := change.LastTriggeredImageID
    
  •       next := latest.Image
    
  •       if len(next) == 0 {
    
  •           // tags without images should still trigger builds (when going from a
    
    pure tag to an image
  •           // based tag, we should rebuild)
    
  •           next = latest.DockerImageReference
    
  •       }
    
  •       if len(last) == 0 || next != last {
    
  •           subs[change.Image] = latest.DockerImageReference
    
  •           change.LastTriggeredImageID = next
    

i didn't suggest using image. i suggested using pullspec. If the last time
you ran the build, you used latest.DockerImageReference, then there's no
reason to run a build using that value again, therefore that is the value
you should be storing in the LastTriggeredImageID field (I agree it's now
poorly named due to this change, it wasn't at the time it was created)


Reply to this email directly or view it on GitHub:
https://github.com/openshift/origin/pull/1303/files#r26517217

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pull spec by tags will continue to be supported - we only guarantee a pull spec by image change will fire if the specs don't match, or the ids don't match.

----- Original Message -----

            continue
        }

        // (must be different) to trigger a build
  •       if icTrigger.LastTriggeredImageID != latest.Image {
    
  •           imageSubstitutions[icTrigger.Image] = latest.DockerImageReference
    
  •           shouldTriggerBuild = true
    
  •           icTrigger.LastTriggeredImageID = latest.Image
    
  •       last := change.LastTriggeredImageID
    
  •       next := latest.Image
    
  •       if len(next) == 0 {
    
  •           // tags without images should still trigger builds (when going from a
    
    pure tag to an image
  •           // based tag, we should rebuild)
    
  •           next = latest.DockerImageReference
    
  •       }
    
  •       if len(last) == 0 || next != last {
    
  •           subs[change.Image] = latest.DockerImageReference
    
  •           change.LastTriggeredImageID = next
    

(and if there is a reason to run that build again, because
latest.DockerImageReference does not uniquely identify a specific image hash
and you want to pick up the new layer that latest.DockerImageReference now
represents, then this change is breaking the fundamental premise of the
image change controller which is that the build it produces can be rerun at
any time and will use the exact same image layers)


Reply to this email directly or view it on GitHub:
https://github.com/openshift/origin/pull/1303/files#r26517459

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

----- Original Message -----

            continue
        }

        // (must be different) to trigger a build
  •       if icTrigger.LastTriggeredImageID != latest.Image {
    
  •           imageSubstitutions[icTrigger.Image] = latest.DockerImageReference
    
  •           shouldTriggerBuild = true
    
  •           icTrigger.LastTriggeredImageID = latest.Image
    
  •       last := change.LastTriggeredImageID
    
  •       next := latest.Image
    
  •       if len(next) == 0 {
    
  •           // tags without images should still trigger builds (when going from a
    
    pure tag to an image
  •           // based tag, we should rebuild)
    
  •           next = latest.DockerImageReference
    
  •       }
    
  •       if len(last) == 0 || next != last {
    
  •           subs[change.Image] = latest.DockerImageReference
    
  •           change.LastTriggeredImageID = next
    

Sounds like this is going to need some work when this merges:
https://ci.openshift.redhat.com/openshift-docs-master-testing/latest/using_openshift/builds.html#image-change-triggers


Reply to this email directly or view it on GitHub:
https://github.com/openshift/origin/pull/1303/files#r26518976

shouldBuild = true
}
}

if shouldTriggerBuild {
if shouldBuild {
glog.V(4).Infof("Running build for buildConfig %s in namespace %s", config.Name, config.Namespace)
b := buildutil.GenerateBuildFromConfig(config, nil, imageSubstitutions)
b := buildutil.GenerateBuildFromConfig(config, nil, subs)
if err := c.BuildCreator.Create(config.Namespace, b); err != nil {
return fmt.Errorf("Error starting build for buildConfig %s: %v", config.Name, err)
} else {
if err := c.BuildConfigUpdater.Update(config); err != nil {
// This is not a retryable error because the build has been created. The worst case
// outcome of not updating the buildconfig is that we might rerun a build for the
// same "new" imageid change in the future, which is better than guaranteeing we
// run the build 2+ times by retrying it here.
glog.V(2).Infof("Error updating buildConfig %v: %v", config.Name, err)
return ImageChangeControllerFatalError{Reason: fmt.Sprintf("Error updating buildConfig %s with new LastTriggeredImageID", config.Name), Err: err}
}
return fmt.Errorf("error starting build for buildConfig %s: %v", config.Name, err)
}
if err := c.BuildConfigUpdater.Update(config); err != nil {
// This is not a retryable error because the build has been created. The worst case
// outcome of not updating the buildconfig is that we might rerun a build for the
// same "new" imageid change in the future, which is better than running the build
// 2+ times by retrying it here.
return ImageChangeControllerFatalError{Reason: fmt.Sprintf("Error updating buildConfig %s with new LastTriggeredImageID", config.Name), Err: err}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/build/util/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func GenerateBuildWithImageTag(config *buildapi.BuildConfig, revision *buildapi.
if len(tag) == 0 {
tag = buildapi.DefaultImageTag
}
latest, err := imageapi.LatestTaggedImage(*imageRepo, tag)
latest, err := imageapi.LatestTaggedImage(imageRepo, tag)
if err != nil {
continue
}
Expand Down
41 changes: 27 additions & 14 deletions pkg/cmd/server/origin/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import (
deployetcd "github.com/openshift/origin/pkg/deploy/registry/etcd"
deployrollback "github.com/openshift/origin/pkg/deploy/rollback"
"github.com/openshift/origin/pkg/dns"
imagecontroller "github.com/openshift/origin/pkg/image/controller"
"github.com/openshift/origin/pkg/image/registry/image"
imageetcd "github.com/openshift/origin/pkg/image/registry/image/etcd"
"github.com/openshift/origin/pkg/image/registry/imagerepository"
Expand Down Expand Up @@ -159,6 +160,11 @@ func (c *MasterConfig) ImageChangeControllerClient() *osclient.Client {
return c.OSClient
}

// ImageImportControllerClient returns the deployment client object
func (c *MasterConfig) ImageImportControllerClient() *osclient.Client {
return c.OSClient
}

// DeploymentControllerClients returns the deployment controller client object
func (c *MasterConfig) DeploymentControllerClients() (*osclient.Client, *kclient.Client) {
return c.OSClient, c.KubernetesClient
Expand Down Expand Up @@ -197,8 +203,8 @@ func (c *MasterConfig) InstallProtectedAPI(container *restful.Container) []strin

imageStorage := imageetcd.NewREST(c.EtcdHelper)
imageRegistry := image.NewRegistry(imageStorage)
imageRepositoryStorage := imagerepositoryetcd.NewREST(c.EtcdHelper, imagerepository.DefaultRegistryFunc(defaultRegistryFunc))
imageRepositoryRegistry := imagerepository.NewRegistry(imageRepositoryStorage)
imageRepositoryStorage, imageRepositoryStatus := imagerepositoryetcd.NewREST(c.EtcdHelper, imagerepository.DefaultRegistryFunc(defaultRegistryFunc))
imageRepositoryRegistry := imagerepository.NewRegistry(imageRepositoryStorage, imageRepositoryStatus)
imageRepositoryMappingStorage := imagerepositorymapping.NewREST(imageRegistry, imageRepositoryRegistry)
imageRepositoryTagStorage := imagerepositorytag.NewREST(imageRegistry, imageRepositoryRegistry)
imageStreamImageStorage := imagestreamimage.NewREST(imageRegistry, imageRepositoryRegistry)
Expand Down Expand Up @@ -227,14 +233,15 @@ func (c *MasterConfig) InstallProtectedAPI(container *restful.Container) []strin
"buildConfigs": buildconfigregistry.NewREST(buildEtcd),
"buildLogs": buildlogregistry.NewREST(buildEtcd, c.BuildLogClient()),

"images": imageStorage,
"imageStreams": imageRepositoryStorage,
"imageStreamImages": imageStreamImageStorage,
"imageStreamMappings": imageRepositoryMappingStorage,
"imageStreamTags": imageRepositoryTagStorage,
"imageRepositories": imageRepositoryStorage,
"imageRepositoryMappings": imageRepositoryMappingStorage,
"imageRepositoryTags": imageRepositoryTagStorage,
"images": imageStorage,
"imageStreams": imageRepositoryStorage,
"imageStreamImages": imageStreamImageStorage,
"imageStreamMappings": imageRepositoryMappingStorage,
"imageStreamTags": imageRepositoryTagStorage,
"imageRepositories": imageRepositoryStorage,
"imageRepositories/status": imageRepositoryStatus,
"imageRepositoryMappings": imageRepositoryMappingStorage,
"imageRepositoryTags": imageRepositoryTagStorage,

"deployments": deployregistry.NewREST(deployEtcd),
"deploymentConfigs": deployconfigregistry.NewREST(deployEtcd),
Expand Down Expand Up @@ -774,10 +781,7 @@ func (c *MasterConfig) RouteAllocator() *routeallocationcontroller.RouteAllocati
KubeClient: c.KubeClient(),
}

subdomain := os.Getenv("OPENSHIFT_ROUTE_SUBDOMAIN")
if len(subdomain) == 0 {
subdomain = OpenShiftRouteSubdomain
}
subdomain := env("OPENSHIFT_ROUTE_SUBDOMAIN", OpenShiftRouteSubdomain)

plugin, err := routeplugin.NewSimpleAllocationPlugin(subdomain)
if err != nil {
Expand All @@ -787,6 +791,15 @@ func (c *MasterConfig) RouteAllocator() *routeallocationcontroller.RouteAllocati
return factory.Create(plugin)
}

func (c *MasterConfig) RunImageImportController() {
osclient := c.ImageImportControllerClient()
factory := imagecontroller.ImportControllerFactory{
Client: osclient,
}
controller := factory.Create()
controller.Run()
}

// ensureCORSAllowedOrigins takes a string list of origins and attempts to covert them to CORS origin
// regexes, or exits if it cannot.
func (c *MasterConfig) ensureCORSAllowedOrigins() []*regexp.Regexp {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/server/start/start_master.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ func StartMaster(openshiftMasterConfig *configapi.MasterConfig) error {
openshiftConfig.RunDeploymentConfigController()
openshiftConfig.RunDeploymentConfigChangeController()
openshiftConfig.RunDeploymentImageChangeTriggerController()
openshiftConfig.RunImageImportController()
openshiftConfig.RunProjectAuthorizationCache()

return nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/deploy/controller/imagechange/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (c *ImageChangeController) Handle(imageRepo *imageapi.ImageRepository) erro
continue
}

latest, err := imageapi.LatestTaggedImage(*imageRepo, params.Tag)
latest, err := imageapi.LatestTaggedImage(imageRepo, params.Tag)
if err != nil {
glog.V(4).Infof("Skipping container %s for config %s; %s", container.Name, labelFor(config), err)
continue
Expand Down Expand Up @@ -146,7 +146,7 @@ func (c *ImageChangeController) regenerate(imageRepo *imageapi.ImageRepository,
continue
}

latest, err := imageapi.LatestTaggedImage(*imageRepo, trigger.Tag)
latest, err := imageapi.LatestTaggedImage(imageRepo, trigger.Tag)
if err != nil {
return fmt.Errorf("error generating new version of deploymentConfig: %s: %s", labelFor(config), err)
}
Expand Down
9 changes: 1 addition & 8 deletions pkg/deploy/generator/config_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,8 @@ func replaceReferences(dc *deployapi.DeploymentConfig, repos reposByIndex) (chan
}
params := dc.Triggers[i].ImageChangeParams

// lookup image id
tag := params.Tag
if len(tag) == 0 {
// TODO: replace with "preferred tag" from repo
tag = "latest"
}

// get the image ref from the repo's tag history
latest, err := imageapi.LatestTaggedImage(*repo, tag)
latest, err := imageapi.LatestTaggedImage(repo, params.Tag)
if err != nil {
errs = append(errs, errors.NewFieldInvalid(fmt.Sprintf("triggers[%d].imageChange.from", i), repo.Name, err.Error()))
continue
Expand Down
Loading