Skip to content

Commit 22ee53a

Browse files
authored
Merge pull request #946 from stakater/SA-7383-remove-support-for-dc
Removed code for deployment config SA-7383
2 parents b56f8f5 + 61ba818 commit 22ee53a

File tree

3 files changed

+0
-216
lines changed

3 files changed

+0
-216
lines changed

internal/pkg/callbacks/rolling_upgrade.go

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
patchtypes "k8s.io/apimachinery/pkg/types"
1818

1919
argorolloutv1alpha1 "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1"
20-
openshiftv1 "github.com/openshift/api/apps/v1"
2120
)
2221

2322
// ItemFunc is a generic function to return a specific resource in given namespace
@@ -232,36 +231,6 @@ func GetStatefulSetItems(clients kube.Clients, namespace string) []runtime.Objec
232231
return items
233232
}
234233

235-
// GetDeploymentConfigItem returns the deploymentConfig in given namespace
236-
func GetDeploymentConfigItem(clients kube.Clients, name string, namespace string) (runtime.Object, error) {
237-
deploymentConfig, err := clients.OpenshiftAppsClient.AppsV1().DeploymentConfigs(namespace).Get(context.TODO(), name, meta_v1.GetOptions{})
238-
if err != nil {
239-
logrus.Errorf("Failed to get deploymentConfig %v", err)
240-
return nil, err
241-
}
242-
243-
return deploymentConfig, nil
244-
}
245-
246-
// GetDeploymentConfigItems returns the deploymentConfigs in given namespace
247-
func GetDeploymentConfigItems(clients kube.Clients, namespace string) []runtime.Object {
248-
deploymentConfigs, err := clients.OpenshiftAppsClient.AppsV1().DeploymentConfigs(namespace).List(context.TODO(), meta_v1.ListOptions{})
249-
if err != nil {
250-
logrus.Errorf("Failed to list deploymentConfigs %v", err)
251-
}
252-
253-
items := make([]runtime.Object, len(deploymentConfigs.Items))
254-
// Ensure we always have pod annotations to add to
255-
for i, v := range deploymentConfigs.Items {
256-
if v.Spec.Template.ObjectMeta.Annotations == nil {
257-
deploymentConfigs.Items[i].Spec.Template.ObjectMeta.Annotations = make(map[string]string)
258-
}
259-
items[i] = &deploymentConfigs.Items[i]
260-
}
261-
262-
return items
263-
}
264-
265234
// GetRolloutItem returns the rollout in given namespace
266235
func GetRolloutItem(clients kube.Clients, name string, namespace string) (runtime.Object, error) {
267236
rollout, err := clients.ArgoRolloutClient.ArgoprojV1alpha1().Rollouts(namespace).Get(context.TODO(), name, meta_v1.GetOptions{})
@@ -332,14 +301,6 @@ func GetStatefulSetAnnotations(item runtime.Object) map[string]string {
332301
return item.(*appsv1.StatefulSet).ObjectMeta.Annotations
333302
}
334303

335-
// GetDeploymentConfigAnnotations returns the annotations of given deploymentConfig
336-
func GetDeploymentConfigAnnotations(item runtime.Object) map[string]string {
337-
if item.(*openshiftv1.DeploymentConfig).ObjectMeta.Annotations == nil {
338-
item.(*openshiftv1.DeploymentConfig).ObjectMeta.Annotations = make(map[string]string)
339-
}
340-
return item.(*openshiftv1.DeploymentConfig).ObjectMeta.Annotations
341-
}
342-
343304
// GetRolloutAnnotations returns the annotations of given rollout
344305
func GetRolloutAnnotations(item runtime.Object) map[string]string {
345306
if item.(*argorolloutv1alpha1.Rollout).ObjectMeta.Annotations == nil {
@@ -388,14 +349,6 @@ func GetStatefulSetPodAnnotations(item runtime.Object) map[string]string {
388349
return item.(*appsv1.StatefulSet).Spec.Template.ObjectMeta.Annotations
389350
}
390351

391-
// GetDeploymentConfigPodAnnotations returns the pod's annotations of given deploymentConfig
392-
func GetDeploymentConfigPodAnnotations(item runtime.Object) map[string]string {
393-
if item.(*openshiftv1.DeploymentConfig).Spec.Template.ObjectMeta.Annotations == nil {
394-
item.(*openshiftv1.DeploymentConfig).Spec.Template.ObjectMeta.Annotations = make(map[string]string)
395-
}
396-
return item.(*openshiftv1.DeploymentConfig).Spec.Template.ObjectMeta.Annotations
397-
}
398-
399352
// GetRolloutPodAnnotations returns the pod's annotations of given rollout
400353
func GetRolloutPodAnnotations(item runtime.Object) map[string]string {
401354
if item.(*argorolloutv1alpha1.Rollout).Spec.Template.ObjectMeta.Annotations == nil {
@@ -429,11 +382,6 @@ func GetStatefulSetContainers(item runtime.Object) []v1.Container {
429382
return item.(*appsv1.StatefulSet).Spec.Template.Spec.Containers
430383
}
431384

432-
// GetDeploymentConfigContainers returns the containers of given deploymentConfig
433-
func GetDeploymentConfigContainers(item runtime.Object) []v1.Container {
434-
return item.(*openshiftv1.DeploymentConfig).Spec.Template.Spec.Containers
435-
}
436-
437385
// GetRolloutContainers returns the containers of given rollout
438386
func GetRolloutContainers(item runtime.Object) []v1.Container {
439387
return item.(*argorolloutv1alpha1.Rollout).Spec.Template.Spec.Containers
@@ -464,11 +412,6 @@ func GetStatefulSetInitContainers(item runtime.Object) []v1.Container {
464412
return item.(*appsv1.StatefulSet).Spec.Template.Spec.InitContainers
465413
}
466414

467-
// GetDeploymentConfigInitContainers returns the containers of given deploymentConfig
468-
func GetDeploymentConfigInitContainers(item runtime.Object) []v1.Container {
469-
return item.(*openshiftv1.DeploymentConfig).Spec.Template.Spec.InitContainers
470-
}
471-
472415
// GetRolloutInitContainers returns the containers of given rollout
473416
func GetRolloutInitContainers(item runtime.Object) []v1.Container {
474417
return item.(*argorolloutv1alpha1.Rollout).Spec.Template.Spec.InitContainers
@@ -575,19 +518,6 @@ func PatchStatefulSet(clients kube.Clients, namespace string, resource runtime.O
575518
return err
576519
}
577520

578-
// UpdateDeploymentConfig performs rolling upgrade on deploymentConfig
579-
func UpdateDeploymentConfig(clients kube.Clients, namespace string, resource runtime.Object) error {
580-
deploymentConfig := resource.(*openshiftv1.DeploymentConfig)
581-
_, err := clients.OpenshiftAppsClient.AppsV1().DeploymentConfigs(namespace).Update(context.TODO(), deploymentConfig, meta_v1.UpdateOptions{FieldManager: "Reloader"})
582-
return err
583-
}
584-
585-
func PatchDeploymentConfig(clients kube.Clients, namespace string, resource runtime.Object, patchType patchtypes.PatchType, bytes []byte) error {
586-
deploymentConfig := resource.(*openshiftv1.DeploymentConfig)
587-
_, err := clients.OpenshiftAppsClient.AppsV1().DeploymentConfigs(namespace).Patch(context.TODO(), deploymentConfig.Name, patchType, bytes, meta_v1.PatchOptions{FieldManager: "Reloader"})
588-
return err
589-
}
590-
591521
// UpdateRollout performs rolling upgrade on rollout
592522
func UpdateRollout(clients kube.Clients, namespace string, resource runtime.Object) error {
593523
rollout := resource.(*argorolloutv1alpha1.Rollout)
@@ -631,11 +561,6 @@ func GetStatefulSetVolumes(item runtime.Object) []v1.Volume {
631561
return item.(*appsv1.StatefulSet).Spec.Template.Spec.Volumes
632562
}
633563

634-
// GetDeploymentConfigVolumes returns the Volumes of given deploymentConfig
635-
func GetDeploymentConfigVolumes(item runtime.Object) []v1.Volume {
636-
return item.(*openshiftv1.DeploymentConfig).Spec.Template.Spec.Volumes
637-
}
638-
639564
// GetRolloutVolumes returns the Volumes of given rollout
640565
func GetRolloutVolumes(item runtime.Object) []v1.Volume {
641566
return item.(*argorolloutv1alpha1.Rollout).Spec.Template.Spec.Volumes

internal/pkg/controller/controller_test.go

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -68,64 +68,6 @@ func TestMain(m *testing.M) {
6868
os.Exit(retCode)
6969
}
7070

71-
// Perform rolling upgrade on deploymentConfig and create pod annotation var upon updating the configmap
72-
func TestControllerUpdatingConfigmapShouldCreatePodAnnotationInDeploymentConfig(t *testing.T) {
73-
options.ReloadStrategy = constants.AnnotationsReloadStrategy
74-
75-
// Don't run test on non-openshift environment
76-
if !kube.IsOpenshift {
77-
return
78-
}
79-
80-
// Creating configmap
81-
configmapName := configmapNamePrefix + "-update-" + testutil.RandSeq(5)
82-
configmapClient, err := testutil.CreateConfigMap(clients.KubernetesClient, namespace, configmapName, "www.google.com")
83-
if err != nil {
84-
t.Errorf("Error while creating the configmap %v", err)
85-
}
86-
87-
// Creating deployment
88-
_, err = testutil.CreateDeploymentConfig(clients.OpenshiftAppsClient, configmapName, namespace, true)
89-
if err != nil {
90-
t.Errorf("Error in deploymentConfig creation: %v", err)
91-
}
92-
93-
// Updating configmap for first time
94-
updateErr := testutil.UpdateConfigMap(configmapClient, namespace, configmapName, "", "www.stakater.com")
95-
if updateErr != nil {
96-
t.Errorf("Configmap was not updated")
97-
}
98-
99-
// Verifying deployment update
100-
logrus.Infof("Verifying pod annotation has been created")
101-
shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, namespace, configmapName, "www.stakater.com")
102-
config := util.Config{
103-
Namespace: namespace,
104-
ResourceName: configmapName,
105-
SHAValue: shaData,
106-
Annotation: options.ConfigmapUpdateOnChangeAnnotation,
107-
}
108-
deploymentConfigFuncs := handler.GetDeploymentConfigRollingUpgradeFuncs()
109-
updated := testutil.VerifyResourceAnnotationUpdate(clients, config, deploymentConfigFuncs)
110-
if !updated {
111-
t.Errorf("DeploymentConfig was not updated")
112-
}
113-
time.Sleep(sleepDuration)
114-
115-
// Deleting deployment
116-
err = testutil.DeleteDeploymentConfig(clients.OpenshiftAppsClient, namespace, configmapName)
117-
if err != nil {
118-
logrus.Errorf("Error while deleting the deploymentConfig %v", err)
119-
}
120-
121-
// Deleting configmap
122-
err = testutil.DeleteConfigMap(clients.KubernetesClient, namespace, configmapName)
123-
if err != nil {
124-
logrus.Errorf("Error while deleting the configmap %v", err)
125-
}
126-
time.Sleep(sleepDuration)
127-
}
128-
12971
// Perform rolling upgrade on deployment and create pod annotation var upon updating the configmap
13072
func TestControllerUpdatingConfigmapShouldCreatePodAnnotationInDeployment(t *testing.T) {
13173
options.ReloadStrategy = constants.AnnotationsReloadStrategy
@@ -1078,64 +1020,6 @@ func TestControllerUpdatingSecretShouldCreatePodAnnotationInStatefulSet(t *testi
10781020
time.Sleep(sleepDuration)
10791021
}
10801022

1081-
// Perform rolling upgrade on deploymentConfig and create env var upon updating the configmap
1082-
func TestControllerUpdatingConfigmapShouldCreateEnvInDeploymentConfig(t *testing.T) {
1083-
options.ReloadStrategy = constants.EnvVarsReloadStrategy
1084-
1085-
// Don't run test on non-openshift environment
1086-
if !kube.IsOpenshift {
1087-
return
1088-
}
1089-
1090-
// Creating configmap
1091-
configmapName := configmapNamePrefix + "-update-" + testutil.RandSeq(5)
1092-
configmapClient, err := testutil.CreateConfigMap(clients.KubernetesClient, namespace, configmapName, "www.google.com")
1093-
if err != nil {
1094-
t.Errorf("Error while creating the configmap %v", err)
1095-
}
1096-
1097-
// Creating deployment
1098-
_, err = testutil.CreateDeploymentConfig(clients.OpenshiftAppsClient, configmapName, namespace, true)
1099-
if err != nil {
1100-
t.Errorf("Error in deploymentConfig creation: %v", err)
1101-
}
1102-
1103-
// Updating configmap for first time
1104-
updateErr := testutil.UpdateConfigMap(configmapClient, namespace, configmapName, "", "www.stakater.com")
1105-
if updateErr != nil {
1106-
t.Errorf("Configmap was not updated")
1107-
}
1108-
1109-
// Verifying deployment update
1110-
logrus.Infof("Verifying env var has been created")
1111-
shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, namespace, configmapName, "www.stakater.com")
1112-
config := util.Config{
1113-
Namespace: namespace,
1114-
ResourceName: configmapName,
1115-
SHAValue: shaData,
1116-
Annotation: options.ConfigmapUpdateOnChangeAnnotation,
1117-
}
1118-
deploymentConfigFuncs := handler.GetDeploymentConfigRollingUpgradeFuncs()
1119-
updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, deploymentConfigFuncs)
1120-
if !updated {
1121-
t.Errorf("DeploymentConfig was not updated")
1122-
}
1123-
time.Sleep(sleepDuration)
1124-
1125-
// Deleting deployment
1126-
err = testutil.DeleteDeploymentConfig(clients.OpenshiftAppsClient, namespace, configmapName)
1127-
if err != nil {
1128-
logrus.Errorf("Error while deleting the deploymentConfig %v", err)
1129-
}
1130-
1131-
// Deleting configmap
1132-
err = testutil.DeleteConfigMap(clients.KubernetesClient, namespace, configmapName)
1133-
if err != nil {
1134-
logrus.Errorf("Error while deleting the configmap %v", err)
1135-
}
1136-
time.Sleep(sleepDuration)
1137-
}
1138-
11391023
// Perform rolling upgrade on deployment and create env var upon updating the configmap
11401024
func TestControllerUpdatingConfigmapShouldCreateEnvInDeployment(t *testing.T) {
11411025
options.ReloadStrategy = constants.EnvVarsReloadStrategy

internal/pkg/handler/upgrade.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -119,24 +119,6 @@ func GetStatefulSetRollingUpgradeFuncs() callbacks.RollingUpgradeFuncs {
119119
}
120120
}
121121

122-
// GetDeploymentConfigRollingUpgradeFuncs returns all callback funcs for a deploymentConfig
123-
func GetDeploymentConfigRollingUpgradeFuncs() callbacks.RollingUpgradeFuncs {
124-
return callbacks.RollingUpgradeFuncs{
125-
ItemFunc: callbacks.GetDeploymentConfigItem,
126-
ItemsFunc: callbacks.GetDeploymentConfigItems,
127-
AnnotationsFunc: callbacks.GetDeploymentConfigAnnotations,
128-
PodAnnotationsFunc: callbacks.GetDeploymentConfigPodAnnotations,
129-
ContainersFunc: callbacks.GetDeploymentConfigContainers,
130-
InitContainersFunc: callbacks.GetDeploymentConfigInitContainers,
131-
UpdateFunc: callbacks.UpdateDeploymentConfig,
132-
PatchFunc: callbacks.PatchDeploymentConfig,
133-
PatchTemplatesFunc: callbacks.GetPatchTemplates,
134-
VolumesFunc: callbacks.GetDeploymentConfigVolumes,
135-
ResourceType: "DeploymentConfig",
136-
SupportsPatch: true,
137-
}
138-
}
139-
140122
// GetArgoRolloutRollingUpgradeFuncs returns all callback funcs for a rollout
141123
func GetArgoRolloutRollingUpgradeFuncs() callbacks.RollingUpgradeFuncs {
142124
return callbacks.RollingUpgradeFuncs{
@@ -210,13 +192,6 @@ func doRollingUpgrade(config util.Config, collectors metrics.Collectors, recorde
210192
return err
211193
}
212194

213-
if kube.IsOpenshift {
214-
err = rollingUpgrade(clients, config, GetDeploymentConfigRollingUpgradeFuncs(), collectors, recorder, invoke)
215-
if err != nil {
216-
return err
217-
}
218-
}
219-
220195
if options.IsArgoRollouts == "true" {
221196
err = rollingUpgrade(clients, config, GetArgoRolloutRollingUpgradeFuncs(), collectors, recorder, invoke)
222197
if err != nil {

0 commit comments

Comments
 (0)