Skip to content

Commit 3aa370c

Browse files
committed
Set default for DeploymentConfigSpec.RevisionHistoryLimit in apps/v1 to 10.
Fix tests now that we are really not doing cascade delete for legacy API. (Brings group API into tests.)
1 parent 0c81307 commit 3aa370c

File tree

18 files changed

+478
-36
lines changed

18 files changed

+478
-36
lines changed

api/protobuf-spec/github_com_openshift_origin_pkg_deploy_apis_apps_v1.proto

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger-spec/oapi-v1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23199,7 +23199,7 @@
2319923199
"revisionHistoryLimit": {
2320023200
"type": "integer",
2320123201
"format": "int32",
23202-
"description": "RevisionHistoryLimit is the number of old ReplicationControllers to retain to allow for rollbacks. This field is a pointer to allow for differentiation between an explicit zero and not specified."
23202+
"description": "RevisionHistoryLimit is the number of old ReplicationControllers to retain to allow for rollbacks. This field is a pointer to allow for differentiation between an explicit zero and not specified. Defaults to 10. (This only applies to DeploymentConfigs created via the new group API resource, not the legacy resource.)"
2320323203
},
2320423204
"test": {
2320523205
"type": "boolean",

api/swagger-spec/openshift-openapi-spec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89392,7 +89392,7 @@
8939289392
"format": "int32"
8939389393
},
8939489394
"revisionHistoryLimit": {
89395-
"description": "RevisionHistoryLimit is the number of old ReplicationControllers to retain to allow for rollbacks. This field is a pointer to allow for differentiation between an explicit zero and not specified.",
89395+
"description": "RevisionHistoryLimit is the number of old ReplicationControllers to retain to allow for rollbacks. This field is a pointer to allow for differentiation between an explicit zero and not specified. Defaults to 10. (This only applies to DeploymentConfigs created via the new group API resource, not the legacy resource.)",
8939689396
"type": "integer",
8939789397
"format": "int32"
8939889398
},
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package clientset
2+
3+
import (
4+
discovery "k8s.io/client-go/discovery"
5+
rest "k8s.io/client-go/rest"
6+
flowcontrol "k8s.io/client-go/util/flowcontrol"
7+
8+
appsV1 "github.com/openshift/origin/pkg/deploy/generated/clientset/typed/apps/v1"
9+
)
10+
11+
type Interface interface {
12+
AppsV1() appsV1.AppsV1Interface
13+
}
14+
15+
// Clientset contains the clients for groups. Each group has exactly one
16+
// version included in a Clientset.
17+
type Clientset struct {
18+
*discovery.DiscoveryClient
19+
appsV1 *appsV1.AppsV1Client
20+
}
21+
22+
// Make sure Clientset implements Interface
23+
var _ Interface = &Clientset{}
24+
25+
// AppsV1 retrieves the AppsV1Client
26+
func (c *Clientset) AppsV1() appsV1.AppsV1Interface {
27+
return c.appsV1
28+
}
29+
30+
// NewForConfig creates a new Clientset for the given config.
31+
func NewForConfig(c *rest.Config) (*Clientset, error) {
32+
configShallowCopy := *c
33+
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
34+
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
35+
}
36+
37+
var cs Clientset
38+
var err error
39+
40+
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
41+
if err != nil {
42+
return nil, err
43+
}
44+
45+
cs.appsV1, err = appsV1.NewForConfig(&configShallowCopy)
46+
if err != nil {
47+
return nil, err
48+
}
49+
50+
return &cs, nil
51+
}
52+
53+
// NewForConfigOrDie creates a new Clientset for the given config and
54+
// panics if there is an error in the config.
55+
func NewForConfigOrDie(c *rest.Config) *Clientset {
56+
cs, err := NewForConfig(c)
57+
if err != nil {
58+
panic(err)
59+
}
60+
return cs
61+
}

pkg/cmd/server/origin/legacy.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
buildconfig "github.com/openshift/origin/pkg/build/registry/buildconfig"
99
buildconfigetcd "github.com/openshift/origin/pkg/build/registry/buildconfig/etcd"
10+
"github.com/openshift/origin/pkg/deploy/registry/deployconfig"
1011
deploymentconfigetcd "github.com/openshift/origin/pkg/deploy/registry/deployconfig/etcd"
1112
routeregistry "github.com/openshift/origin/pkg/route/registry/route"
1213
routeetcd "github.com/openshift/origin/pkg/route/registry/route/etcd"
@@ -206,7 +207,8 @@ func LegacyStorage(storage map[schema.GroupVersion]map[string]rest.Storage) map[
206207
case "deploymentConfigs":
207208
restStorage := s.(*deploymentconfigetcd.REST)
208209
store := *restStorage.Store
209-
restStorage.DeleteStrategy = orphanByDefault(store.DeleteStrategy)
210+
store.CreateStrategy = deployconfig.LegacyStrategy
211+
store.DeleteStrategy = deployconfig.LegacyStrategy
210212
legacyStorage[resource] = &deploymentconfigetcd.REST{Store: &store}
211213
case "routes":
212214
restStorage := s.(*routeetcd.REST)
@@ -223,15 +225,3 @@ func LegacyStorage(storage map[schema.GroupVersion]map[string]rest.Storage) map[
223225
}
224226
return legacyStorage
225227
}
226-
227-
type orphaningDeleter struct {
228-
rest.RESTDeleteStrategy
229-
}
230-
231-
func (o orphaningDeleter) DefaultGarbageCollectionPolicy() rest.GarbageCollectionPolicy {
232-
return rest.OrphanDependents
233-
}
234-
235-
func orphanByDefault(in rest.RESTDeleteStrategy) rest.RESTDeleteStrategy {
236-
return orphaningDeleter{in}
237-
}

pkg/deploy/apis/apps/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const (
2020
// This is set as the default value for ActiveDeadlineSeconds for the deployer pod.
2121
// Currently set to 6 hours.
2222
MaxDeploymentDurationSeconds int64 = 21600
23+
// DefaultRevisionHistoryLimit is the number of old ReplicationControllers to retain to allow for rollbacks.
24+
// This only applies to DeploymentConfigs created via the new group API resource, not the legacy resource.
25+
DefaultRevisionHistoryLimit int32 = 10
2326
)
2427

2528
// These constants represent keys used for correlating objects related to deployments.
@@ -156,6 +159,7 @@ type DeploymentConfigSpec struct {
156159

157160
// RevisionHistoryLimit is the number of old ReplicationControllers to retain to allow for rollbacks.
158161
// This field is a pointer to allow for differentiation between an explicit zero and not specified.
162+
// Defaults to 10. (This only applies to DeploymentConfigs created via the new group API resource, not the legacy resource.)
159163
RevisionHistoryLimit *int32
160164

161165
// Test ensures that this deployment config will have zero replicas except while a deployment is running. This allows the

pkg/deploy/apis/apps/v1/defaults.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ import (
66
deployapi "github.com/openshift/origin/pkg/deploy/apis/apps"
77
)
88

9+
// Applies defaults only for API group "apps.openshift.io" and not for the legacy API.
10+
// This function is called from storage layer where differentiation
11+
// between legacy and group API can be made and is not related to other functions here
12+
// which are called fom auto-generated code.
13+
func AppsV1DeploymentConfigLayeredDefaults(dc *deployapi.DeploymentConfig) {
14+
if dc.Spec.RevisionHistoryLimit == nil {
15+
v := deployapi.DefaultRevisionHistoryLimit
16+
dc.Spec.RevisionHistoryLimit = &v
17+
}
18+
}
19+
920
// Keep this in sync with pkg/api/serialization_test.go#defaultHookContainerName
1021
func defaultHookContainerName(hook *LifecycleHook, containerName string) {
1122
if hook == nil {

pkg/deploy/apis/apps/v1/generated.proto

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/deploy/apis/apps/v1/swagger_doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ var map_DeploymentConfigSpec = map[string]string{
101101
"minReadySeconds": "MinReadySeconds is the minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)",
102102
"triggers": "Triggers determine how updates to a DeploymentConfig result in new deployments. If no triggers are defined, a new deployment can only occur as a result of an explicit client update to the DeploymentConfig with a new LatestVersion. If null, defaults to having a config change trigger.",
103103
"replicas": "Replicas is the number of desired replicas.",
104-
"revisionHistoryLimit": "RevisionHistoryLimit is the number of old ReplicationControllers to retain to allow for rollbacks. This field is a pointer to allow for differentiation between an explicit zero and not specified.",
104+
"revisionHistoryLimit": "RevisionHistoryLimit is the number of old ReplicationControllers to retain to allow for rollbacks. This field is a pointer to allow for differentiation between an explicit zero and not specified. Defaults to 10. (This only applies to DeploymentConfigs created via the new group API resource, not the legacy resource.)",
105105
"test": "Test ensures that this deployment config will have zero replicas except while a deployment is running. This allows the deployment config to be used as a continuous deployment test - triggering on images, running the deployment, and then succeeding or failing. Post strategy hooks and After actions can be used to integrate successful deployment with an action.",
106106
"paused": "Paused indicates that the deployment config is paused resulting in no new deployments on template changes or changes in the template caused by other triggers.",
107107
"selector": "Selector is a label query over pods that should match the Replicas count.",

pkg/deploy/apis/apps/v1/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type DeploymentConfigSpec struct {
5151

5252
// RevisionHistoryLimit is the number of old ReplicationControllers to retain to allow for rollbacks.
5353
// This field is a pointer to allow for differentiation between an explicit zero and not specified.
54+
// Defaults to 10. (This only applies to DeploymentConfigs created via the new group API resource, not the legacy resource.)
5455
RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,4,opt,name=revisionHistoryLimit"`
5556

5657
// Test ensures that this deployment config will have zero replicas except while a deployment is running. This allows the

0 commit comments

Comments
 (0)