Skip to content

Commit

Permalink
Rollout analysis plumbing (#183)
Browse files Browse the repository at this point in the history
* Add analysisRun plumbing to rollout controller
* Add types for analysisSteps
  • Loading branch information
dthomson25 authored Oct 7, 2019
1 parent 270aeac commit b6994d8
Show file tree
Hide file tree
Showing 12 changed files with 557 additions and 56 deletions.
7 changes: 3 additions & 4 deletions analysis/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ func NewAnalysisController(
analysisRunLister: analysisRunInformer.Lister(),
metricsServer: metricsServer,
analysisRunWorkQueue: analysisRunWorkQueue,

analysisRunSynced: analysisRunInformer.Informer().HasSynced,
recorder: recorder,
resyncPeriod: resyncPeriod,
analysisRunSynced: analysisRunInformer.Informer().HasSynced,
recorder: recorder,
resyncPeriod: resyncPeriod,
}

controller.enqueueAnalysis = func(obj interface{}) {
Expand Down
1 change: 1 addition & 0 deletions cmd/rollouts-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func newCommand() *cobra.Command {
argoRolloutsInformerFactory.Argoproj().V1alpha1().Rollouts(),
argoRolloutsInformerFactory.Argoproj().V1alpha1().Experiments(),
argoRolloutsInformerFactory.Argoproj().V1alpha1().AnalysisRuns(),
argoRolloutsInformerFactory.Argoproj().V1alpha1().AnalysisTemplates(),
resyncDuration,
metricsPort)

Expand Down
45 changes: 25 additions & 20 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ type Manager struct {
analysisController *analysis.AnalysisController
serviceController *service.ServiceController

rolloutSynced cache.InformerSynced
experimentSynced cache.InformerSynced
analysisRunSynced cache.InformerSynced
serviceSynced cache.InformerSynced
replicasSetSynced cache.InformerSynced
rolloutSynced cache.InformerSynced
experimentSynced cache.InformerSynced
analysisRunSynced cache.InformerSynced
analysisTemplateSynced cache.InformerSynced
serviceSynced cache.InformerSynced
replicasSetSynced cache.InformerSynced

rolloutWorkqueue workqueue.RateLimitingInterface
serviceWorkqueue workqueue.RateLimitingInterface
Expand All @@ -80,6 +81,7 @@ func NewManager(
rolloutsInformer informers.RolloutInformer,
experimentsInformer informers.ExperimentInformer,
analysisRunInformer informers.AnalysisRunInformer,
analysisTemplateInformer informers.AnalysisTemplateInformer,
resyncPeriod time.Duration,
metricsPort int) *Manager {

Expand All @@ -105,6 +107,8 @@ func NewManager(
rolloutController := rollout.NewRolloutController(kubeclientset,
argoprojclientset,
experimentsInformer,
analysisRunInformer,
analysisTemplateInformer,
replicaSetInformer,
servicesInformer,
rolloutsInformer,
Expand Down Expand Up @@ -143,20 +147,21 @@ func NewManager(
metricsServer)

cm := &Manager{
metricsServer: metricsServer,
rolloutSynced: rolloutsInformer.Informer().HasSynced,
serviceSynced: servicesInformer.Informer().HasSynced,
experimentSynced: experimentsInformer.Informer().HasSynced,
analysisRunSynced: analysisRunInformer.Informer().HasSynced,
replicasSetSynced: replicaSetInformer.Informer().HasSynced,
rolloutWorkqueue: rolloutWorkqueue,
experimentWorkqueue: experimentWorkqueue,
analysisRunWorkqueue: analysisRunWorkqueue,
serviceWorkqueue: serviceWorkqueue,
rolloutController: rolloutController,
serviceController: serviceController,
experimentController: experimentController,
analysisController: analysisController,
metricsServer: metricsServer,
rolloutSynced: rolloutsInformer.Informer().HasSynced,
serviceSynced: servicesInformer.Informer().HasSynced,
experimentSynced: experimentsInformer.Informer().HasSynced,
analysisRunSynced: analysisRunInformer.Informer().HasSynced,
analysisTemplateSynced: analysisTemplateInformer.Informer().HasSynced,
replicasSetSynced: replicaSetInformer.Informer().HasSynced,
rolloutWorkqueue: rolloutWorkqueue,
experimentWorkqueue: experimentWorkqueue,
analysisRunWorkqueue: analysisRunWorkqueue,
serviceWorkqueue: serviceWorkqueue,
rolloutController: rolloutController,
serviceController: serviceController,
experimentController: experimentController,
analysisController: analysisController,
}

return cm
Expand All @@ -175,7 +180,7 @@ func (c *Manager) Run(rolloutThreadiness, serviceThreadiness, experimentThreadin
defer c.analysisRunWorkqueue.ShutDown()
// Wait for the caches to be synced before starting workers
log.Info("Waiting for controller's informer caches to sync")
if ok := cache.WaitForCacheSync(stopCh, c.serviceSynced, c.rolloutSynced, c.experimentSynced, c.analysisRunSynced, c.replicasSetSynced); !ok {
if ok := cache.WaitForCacheSync(stopCh, c.serviceSynced, c.rolloutSynced, c.experimentSynced, c.analysisRunSynced, c.analysisTemplateSynced, c.replicasSetSynced); !ok {
return fmt.Errorf("failed to wait for caches to sync")
}

Expand Down
50 changes: 50 additions & 0 deletions manifests/crds/rollout-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,29 @@ spec:
type: object
canary:
properties:
analysis:
properties:
arguments:
items:
properties:
name:
type: string
value:
type: string
valueFrom:
properties:
podTemplateHashValue:
type: string
type: object
required:
- name
type: object
type: array
templateName:
type: string
required:
- templateName
type: object
canaryService:
type: string
maxSurge:
Expand All @@ -122,6 +145,29 @@ spec:
steps:
items:
properties:
analysis:
properties:
arguments:
items:
properties:
name:
type: string
value:
type: string
valueFrom:
properties:
podTemplateHashValue:
type: string
type: object
required:
- name
type: object
type: array
templateName:
type: string
required:
- templateName
type: object
experiment:
properties:
duration:
Expand Down Expand Up @@ -1903,6 +1949,10 @@ spec:
type: object
canary:
properties:
currentParellelAnalysisRun:
type: string
currentStepAnalysisRun:
type: string
experimentFailed:
type: boolean
stableRS:
Expand Down
50 changes: 50 additions & 0 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2195,6 +2195,29 @@ spec:
type: object
canary:
properties:
analysis:
properties:
arguments:
items:
properties:
name:
type: string
value:
type: string
valueFrom:
properties:
podTemplateHashValue:
type: string
type: object
required:
- name
type: object
type: array
templateName:
type: string
required:
- templateName
type: object
canaryService:
type: string
maxSurge:
Expand All @@ -2208,6 +2231,29 @@ spec:
steps:
items:
properties:
analysis:
properties:
arguments:
items:
properties:
name:
type: string
value:
type: string
valueFrom:
properties:
podTemplateHashValue:
type: string
type: object
required:
- name
type: object
type: array
templateName:
type: string
required:
- templateName
type: object
experiment:
properties:
duration:
Expand Down Expand Up @@ -3989,6 +4035,10 @@ spec:
type: object
canary:
properties:
currentParellelAnalysisRun:
type: string
currentStepAnalysisRun:
type: string
experimentFailed:
type: boolean
stableRS:
Expand Down
50 changes: 50 additions & 0 deletions manifests/namespace-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2195,6 +2195,29 @@ spec:
type: object
canary:
properties:
analysis:
properties:
arguments:
items:
properties:
name:
type: string
value:
type: string
valueFrom:
properties:
podTemplateHashValue:
type: string
type: object
required:
- name
type: object
type: array
templateName:
type: string
required:
- templateName
type: object
canaryService:
type: string
maxSurge:
Expand All @@ -2208,6 +2231,29 @@ spec:
steps:
items:
properties:
analysis:
properties:
arguments:
items:
properties:
name:
type: string
value:
type: string
valueFrom:
properties:
podTemplateHashValue:
type: string
type: object
required:
- name
type: object
type: array
templateName:
type: string
required:
- templateName
type: object
experiment:
properties:
duration:
Expand Down Expand Up @@ -3989,6 +4035,10 @@ spec:
type: object
canary:
properties:
currentParellelAnalysisRun:
type: string
currentStepAnalysisRun:
type: string
experimentFailed:
type: boolean
stableRS:
Expand Down
Loading

0 comments on commit b6994d8

Please sign in to comment.