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

feat: Use managed-by annotation #448

Merged
merged 1 commit into from
Apr 2, 2020
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
18 changes: 10 additions & 8 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,16 @@ func NewManager(
metricsServer,
recorder)

serviceController := service.NewServiceController(
kubeclientset,
servicesInformer,
rolloutsInformer,
resyncPeriod,
rolloutWorkqueue,
serviceWorkqueue,
metricsServer)
serviceController := service.NewServiceController(service.ControllerConfig{
Kubeclientset: kubeclientset,
Argoprojclientset: argoprojclientset,
RolloutsInformer: rolloutsInformer,
ServicesInformer: servicesInformer,
RolloutWorkqueue: rolloutWorkqueue,
ServiceWorkqueue: serviceWorkqueue,
ResyncPeriod: resyncPeriod,
MetricsServer: metricsServer,
})

ingressController := ingress.NewController(ingress.ControllerConfig{
IngressInformer: ingressesInformer,
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/rollouts/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ const (
// DefaultReplicaSetScaleDownDeadlineAnnotationKey is the default key attached to an old stable ReplicaSet after
// the rollout transitioned to a new version. It contains the time when the controller can scale down the RS.
DefaultReplicaSetScaleDownDeadlineAnnotationKey = "scale-down-deadline"

// ManagedByRolloutKey is the key used to indicate which rollout(s) manage a resource but doesn't own it.
ManagedByRolloutsKey = "argo-rollouts.argoproj.io/managed-by-rollouts"
// LabelKeyControllerInstanceID is the label the controller uses for the rollout, experiment, analysis segregation
// between controllers. Controllers will only operate on objects with the same instanceID as the controller.
LabelKeyControllerInstanceID = "argo-rollouts.argoproj.io/controller-instance-id"
Expand Down
30 changes: 15 additions & 15 deletions rollout/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1180,9 +1180,9 @@ func TestCreatePrePromotionAnalysisRun(t *testing.T) {
conditions.SetRolloutCondition(&r2.Status, pausedCondition)

previewSelector := map[string]string{v1alpha1.DefaultRolloutUniqueLabelKey: rs2PodHash}
previewSvc := newService("preview", 80, previewSelector)
previewSvc := newService("preview", 80, previewSelector, r2)
activeSelector := map[string]string{v1alpha1.DefaultRolloutUniqueLabelKey: rs1PodHash}
activeSvc := newService("active", 80, activeSelector)
activeSvc := newService("active", 80, activeSelector, r2)

f.objects = append(f.objects, r2, at)
f.kubeobjects = append(f.kubeobjects, previewSvc, activeSvc, rs1, rs2)
Expand Down Expand Up @@ -1225,7 +1225,7 @@ func TestDoNotCreatePrePromotionAnalysisAfterPromotionRollout(t *testing.T) {
rs2PodHash := rs2.Labels[v1alpha1.DefaultRolloutUniqueLabelKey]

serviceSelector := map[string]string{v1alpha1.DefaultRolloutUniqueLabelKey: rs2PodHash}
s := newService("bar", 80, serviceSelector)
s := newService("bar", 80, serviceSelector, r2)
f.kubeobjects = append(f.kubeobjects, s)

r2 = updateBlueGreenRolloutStatus(r2, "", rs2PodHash, rs2PodHash, 1, 1, 1, 1, false, true)
Expand Down Expand Up @@ -1265,7 +1265,7 @@ func TestDoNotCreatePrePromotionAnalysisRunOnNewRollout(t *testing.T) {
r.Status.Conditions = []v1alpha1.RolloutCondition{}
f.rolloutLister = append(f.rolloutLister, r)
f.objects = append(f.objects, r)
activeSvc := newService("active", 80, nil)
activeSvc := newService("active", 80, nil, r)
f.kubeobjects = append(f.kubeobjects, activeSvc)
f.serviceLister = append(f.serviceLister, activeSvc)

Expand Down Expand Up @@ -1300,9 +1300,9 @@ func TestDoNotCreatePrePromotionAnalysisRunOnNotReadyReplicaSet(t *testing.T) {
r2 = updateBlueGreenRolloutStatus(r2, rs2PodHash, rs1PodHash, rs1PodHash, 1, 2, 4, 2, false, true)

activeSelector := map[string]string{v1alpha1.DefaultRolloutUniqueLabelKey: rs1PodHash}
activeSvc := newService("active", 80, activeSelector)
activeSvc := newService("active", 80, activeSelector, r2)
previewSelector := map[string]string{v1alpha1.DefaultRolloutUniqueLabelKey: rs2PodHash}
previewSvc := newService("preview", 80, previewSelector)
previewSvc := newService("preview", 80, previewSelector, r2)

f.objects = append(f.objects, r2)
f.kubeobjects = append(f.kubeobjects, activeSvc, previewSvc, rs1, rs2)
Expand Down Expand Up @@ -1343,7 +1343,7 @@ func TestRolloutPrePromotionAnalysisBecomesInconclusive(t *testing.T) {
conditions.SetRolloutCondition(&r2.Status, pausedCondition)

activeSelector := map[string]string{v1alpha1.DefaultRolloutUniqueLabelKey: rs1PodHash}
activeSvc := newService("active", 80, activeSelector)
activeSvc := newService("active", 80, activeSelector, r2)

f.objects = append(f.objects, r2, at, ar)
f.kubeobjects = append(f.kubeobjects, activeSvc, rs1, rs2)
Expand Down Expand Up @@ -1403,7 +1403,7 @@ func TestRolloutPrePromotionAnalysisSwitchServiceAfterSuccess(t *testing.T) {
conditions.SetRolloutCondition(&r2.Status, pausedCondition)

activeSelector := map[string]string{v1alpha1.DefaultRolloutUniqueLabelKey: rs1PodHash}
activeSvc := newService("active", 80, activeSelector)
activeSvc := newService("active", 80, activeSelector, r2)

f.objects = append(f.objects, r2, at, ar)
f.kubeobjects = append(f.kubeobjects, activeSvc, rs1, rs2)
Expand Down Expand Up @@ -1461,7 +1461,7 @@ func TestRolloutPrePromotionAnalysisHonorAutoPromotionSeconds(t *testing.T) {
conditions.SetRolloutCondition(&r2.Status, pausedCondition)

activeSelector := map[string]string{v1alpha1.DefaultRolloutUniqueLabelKey: rs1PodHash}
activeSvc := newService("active", 80, activeSelector)
activeSvc := newService("active", 80, activeSelector, r2)

f.objects = append(f.objects, r2, at, ar)
f.kubeobjects = append(f.kubeobjects, activeSvc, rs1, rs2)
Expand Down Expand Up @@ -1521,7 +1521,7 @@ func TestRolloutPrePromotionAnalysisDoNothingOnInconclusiveAnalysis(t *testing.T
conditions.SetRolloutCondition(&r2.Status, pausedCondition)

activeSelector := map[string]string{v1alpha1.DefaultRolloutUniqueLabelKey: rs1PodHash}
activeSvc := newService("active", 80, activeSelector)
activeSvc := newService("active", 80, activeSelector, r2)

f.objects = append(f.objects, r2, at, ar)
f.kubeobjects = append(f.kubeobjects, activeSvc, rs1, rs2)
Expand Down Expand Up @@ -1561,7 +1561,7 @@ func TestAbortRolloutOnErrorPrePromotionAnalysis(t *testing.T) {
conditions.SetRolloutCondition(&r2.Status, pausedCondition)

activeSelector := map[string]string{v1alpha1.DefaultRolloutUniqueLabelKey: rs1PodHash}
activeSvc := newService("active", 80, activeSelector)
activeSvc := newService("active", 80, activeSelector, r2)

f.objects = append(f.objects, r2, at, ar)
f.kubeobjects = append(f.kubeobjects, activeSvc, rs1, rs2)
Expand Down Expand Up @@ -1609,7 +1609,7 @@ func TestCreatePostPromotionAnalysisRun(t *testing.T) {
r2 = updateBlueGreenRolloutStatus(r2, "", rs2PodHash, rs1PodHash, 1, 1, 2, 1, false, true)

activeSelector := map[string]string{v1alpha1.DefaultRolloutUniqueLabelKey: rs2PodHash}
activeSvc := newService("active", 80, activeSelector)
activeSvc := newService("active", 80, activeSelector, r2)

f.objects = append(f.objects, r2, at)
f.kubeobjects = append(f.kubeobjects, activeSvc, rs1, rs2)
Expand Down Expand Up @@ -1656,7 +1656,7 @@ func TestRolloutPostPromotionAnalysisSuccess(t *testing.T) {
r2 = updateBlueGreenRolloutStatus(r2, "", rs2PodHash, rs1PodHash, 1, 1, 1, 1, false, true)

activeSelector := map[string]string{v1alpha1.DefaultRolloutUniqueLabelKey: rs2PodHash}
activeSvc := newService("active", 80, activeSelector)
activeSvc := newService("active", 80, activeSelector, r2)

f.objects = append(f.objects, r2, at, ar)
f.kubeobjects = append(f.kubeobjects, activeSvc, rs1, rs2)
Expand Down Expand Up @@ -1710,7 +1710,7 @@ func TestPostPromotionAnalysisRunHandleInconclusive(t *testing.T) {
conditions.SetRolloutCondition(&r2.Status, pausedCondition)

activeSelector := map[string]string{v1alpha1.DefaultRolloutUniqueLabelKey: rs2PodHash}
activeSvc := newService("active", 80, activeSelector)
activeSvc := newService("active", 80, activeSelector, r2)

f.objects = append(f.objects, r2, at)
f.kubeobjects = append(f.kubeobjects, activeSvc, rs1, rs2)
Expand Down Expand Up @@ -1759,7 +1759,7 @@ func TestAbortRolloutOnErrorPostPromotionAnalysis(t *testing.T) {
conditions.SetRolloutCondition(&r2.Status, pausedCondition)

activeSelector := map[string]string{v1alpha1.DefaultRolloutUniqueLabelKey: rs2PodHash}
activeSvc := newService("active", 80, activeSelector)
activeSvc := newService("active", 80, activeSelector, r2)

f.objects = append(f.objects, r2, at, ar)
f.kubeobjects = append(f.kubeobjects, activeSvc, rs1, rs2)
Expand Down
Loading