Skip to content

Commit

Permalink
deploy: merge deployment config controller and generic trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
mfojtik committed Jun 27, 2017
1 parent 247631a commit c2271e9
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 519 deletions.
12 changes: 0 additions & 12 deletions pkg/cmd/server/bootstrappolicy/controller_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,6 @@ func init() {
rbac.NewRule("create", "get", "list", "watch", "update", "patch", "delete").Groups(kapiGroup).Resources("replicationcontrollers").RuleOrDie(),
rbac.NewRule("update").Groups(deployGroup, legacyDeployGroup).Resources("deploymentconfigs/status").RuleOrDie(),
rbac.NewRule("get", "list", "watch").Groups(deployGroup, legacyDeployGroup).Resources("deploymentconfigs").RuleOrDie(),
eventsRule(),
},
})

// deployment-trigger-controller
addControllerRole(rbac.ClusterRole{
ObjectMeta: metav1.ObjectMeta{Name: saRolePrefix + InfraDeploymentTriggerControllerServiceAccountName},
Rules: []rbac.PolicyRule{
rbac.NewRule("get", "list", "watch").Groups(kapiGroup).Resources("replicationcontrollers").RuleOrDie(),
rbac.NewRule("get", "list", "watch").Groups(deployGroup, legacyDeployGroup).Resources("deploymentconfigs").RuleOrDie(),
rbac.NewRule("get", "list", "watch").Groups(imageGroup, legacyImageGroup).Resources("imagestreams").RuleOrDie(),

rbac.NewRule("create").Groups(deployGroup, legacyDeployGroup).Resources("deploymentconfigs/instantiate").RuleOrDie(),
eventsRule(),
},
Expand Down
1 change: 0 additions & 1 deletion pkg/cmd/server/bootstrappolicy/infra_sa_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const (
InfraBuildControllerServiceAccountName = "build-controller"
InfraBuildConfigChangeControllerServiceAccountName = "build-config-change-controller"
InfraDeploymentConfigControllerServiceAccountName = "deploymentconfig-controller"
InfraDeploymentTriggerControllerServiceAccountName = "deployment-trigger-controller"
InfraDeployerControllerServiceAccountName = "deployer-controller"
InfraImageTriggerControllerServiceAccountName = "image-trigger-controller"
InfraImageImportControllerServiceAccountName = "image-import-controller"
Expand Down
3 changes: 0 additions & 3 deletions pkg/cmd/server/origin/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,6 @@ func (c *MasterConfig) NewOpenshiftControllerInitializers() (map[string]controll
deploymentConfig := controller.DeploymentConfigControllerConfig{Codec: codec}
ret["openshift.io/deploymentconfig"] = deploymentConfig.RunController

deploymentTrigger := controller.DeploymentTriggerControllerConfig{Codec: codec}
ret["openshift.io/deploymenttrigger"] = deploymentTrigger.RunController

// initialize other controllers
imageTrigger := controller.ImageTriggerControllerConfig{
HasBuilderEnabled: c.Options.DisabledFeatures.Has(configapi.FeatureBuilder),
Expand Down
24 changes: 0 additions & 24 deletions pkg/cmd/server/origin/controller/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
deployercontroller "github.com/openshift/origin/pkg/deploy/controller/deployer"
deployconfigcontroller "github.com/openshift/origin/pkg/deploy/controller/deploymentconfig"
triggercontroller "github.com/openshift/origin/pkg/deploy/controller/generictrigger"
)

type DeployerControllerConfig struct {
Expand All @@ -21,10 +20,6 @@ type DeploymentConfigControllerConfig struct {
Codec runtime.Codec
}

type DeploymentTriggerControllerConfig struct {
Codec runtime.Codec
}

func (c *DeployerControllerConfig) RunController(ctx ControllerContext) (bool, error) {
kubeClient, err := ctx.ClientBuilder.Client(bootstrappolicy.InfraDeployerControllerServiceAccountName)
if err != nil {
Expand Down Expand Up @@ -66,22 +61,3 @@ func (c *DeploymentConfigControllerConfig) RunController(ctx ControllerContext)

return true, nil
}

func (c *DeploymentTriggerControllerConfig) RunController(ctx ControllerContext) (bool, error) {
saName := bootstrappolicy.InfraDeploymentTriggerControllerServiceAccountName

deprecatedOcTriggerClient, err := ctx.ClientBuilder.DeprecatedOpenshiftClient(saName)
if err != nil {
return true, err
}

go triggercontroller.NewDeploymentTriggerController(
ctx.AppInformers.Apps().InternalVersion().DeploymentConfigs().Informer(),
ctx.ExternalKubeInformers.Core().V1().ReplicationControllers().Informer(),
ctx.ImageInformers.Image().InternalVersion().ImageStreams().Informer(),
deprecatedOcTriggerClient,
c.Codec,
).Run(5, ctx.Stop)

return true, nil
}
1 change: 0 additions & 1 deletion pkg/cmd/server/start/start_master.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,6 @@ func startControllers(oc *origin.MasterConfig, kc *kubernetes.MasterConfig) erro
"openshift.io/origin-namespace",
"openshift.io/deployer",
"openshift.io/deploymentconfig",
"openshift.io/deploymenttrigger",
"openshift.io/image-trigger",
"openshift.io/image-import",
"openshift.io/service-serving-cert",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type DeploymentConfigController struct {
func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) error {
glog.V(5).Infof("Reconciling %s/%s", config.Namespace, config.Name)
// There's nothing to reconcile until the version is nonzero.
if config.Status.LatestVersion == 0 {
if config.Status.LatestVersion == 0 && !deployutil.HasChangeTrigger(config) {
return c.updateStatus(config, []*v1.ReplicationController{})
}

Expand Down Expand Up @@ -181,6 +181,30 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig)
c.recorder.Eventf(config, v1.EventTypeNormal, "DeploymentAwaitingCancellation", "Deployment of version %d awaiting cancellation of older running deployments", config.Status.LatestVersion)
return fmt.Errorf("found previous inflight deployment for %s - requeuing", deployutil.LabelForDeploymentConfig(config))
}
// If we already have latest deployment running but the config template does not match
// the latest deployment assume this is a config change and trigger a new deployment if
// the config change trigger is enabled.
if deployutil.HasChangeTrigger(config) && !config.Spec.Paused {
needRollout := false
if config.Status.LatestVersion == 0 {
glog.V(4).Infof("Rolling out initial deployment for %s/%s", config.Namespace, config.Name)
needRollout = true
} else if latestIsDeployed {
if ok, changes, err := deployutil.HasLatestPodTemplate(config, latestDeployment); !ok || err != nil {
if err != nil {
glog.Errorf("Error while checking for latest pod template in replication controller: %v", err)
} else {
glog.V(4).Infof("Rolling out #%d deployment for %s/%s caused by config change, diff: %s", config.Status.LatestVersion+1, config.Namespace, config.Name, changes)
needRollout = true
}
}
}
if needRollout {
deployutil.RecordConfigChangeCause(config)
config.Status.LatestVersion++
return c.updateStatus(config, existingDeployments)
}
}
// If the latest deployment already exists, reconcile existing deployments
// and return early.
if latestIsDeployed {
Expand Down
1 change: 0 additions & 1 deletion pkg/deploy/controller/deploymentconfig/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ func (c *DeploymentConfigController) updateDeploymentConfig(old, cur interface{}
if newDc.ResourceVersion == oldDc.ResourceVersion {
return
}

glog.V(4).Infof("Updating deployment config %q", newDc.Name)
c.enqueueDeploymentConfig(newDc)
}
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit c2271e9

Please sign in to comment.