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

Enables status subresource in order to fix generation bumping #786

Closed
Closed
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
1 change: 1 addition & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions config/300-configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ spec:
kind: Configuration
plural: configurations
scope: Namespaced
subresources:
status: {}
2 changes: 2 additions & 0 deletions config/300-revision.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ spec:
kind: Revision
plural: revisions
scope: Namespaced
subresources:
status: {}
2 changes: 2 additions & 0 deletions config/300-route.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ spec:
kind: Route
plural: routes
scope: Namespaced
subresources:
status: {}
2 changes: 2 additions & 0 deletions config/300-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ spec:
kind: Service
plural: services
scope: Namespaced
subresources:
status: {}
2 changes: 2 additions & 0 deletions docs/creating-a-kubernetes-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ To use a k8s cluster running in GKE:
--scopes=cloud-platform \
--machine-type=n1-standard-4 \
--enable-autoscaling --min-nodes=1 --max-nodes=3 \
--enable-kubernetes-alpha \
knative-demo
```

Expand All @@ -45,6 +46,7 @@ To use a k8s cluster running in GKE:
* Knative Serving currently requires 4-cpu nodes to run conformance tests.
Changing the machine type from the default may cause failures.
* Autoscale from 1 to 3 nodes. Adjust this for your use case
* Kubernetes alpha features are required to enable the `CustomResourceSubresources` feature.
* Change this to your preferred cluster name

You can see the list of supported cluster versions in a particular zone by
Expand Down
14 changes: 0 additions & 14 deletions pkg/apis/serving/v1alpha1/configuration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ type Configuration struct {

// ConfigurationSpec holds the desired state of the Configuration (from the client).
type ConfigurationSpec struct {
// TODO: Generation does not work correctly with CRD. They are scrubbed
// by the APIserver (https://github.com/kubernetes/kubernetes/issues/58778)
// So, we add Generation here. Once that gets fixed, remove this and use
// ObjectMeta.Generation instead.
Generation int64 `json:"generation,omitempty"`

// Build optionally holds the specification for the build to
// perform to produce the Revision's container image.
Build *build.BuildSpec `json:"build,omitempty"`
Expand Down Expand Up @@ -122,14 +116,6 @@ type ConfigurationList struct {
Items []Configuration `json:"items"`
}

func (r *Configuration) GetGeneration() int64 {
return r.Spec.Generation
}

func (r *Configuration) SetGeneration(generation int64) {
r.Spec.Generation = generation
}

func (r *Configuration) GetSpecJSON() ([]byte, error) {
return json.Marshal(r.Spec)
}
Expand Down
12 changes: 0 additions & 12 deletions pkg/apis/serving/v1alpha1/configuration_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ import (
corev1 "k8s.io/api/core/v1"
)

func TestConfigurationGeneration(t *testing.T) {
config := Configuration{}
if e, a := int64(0), config.GetGeneration(); e != a {
t.Errorf("empty revision generation should be 0 was: %d", a)
}

config.SetGeneration(5)
if e, a := int64(5), config.GetGeneration(); e != a {
t.Errorf("getgeneration mismatch expected: %d got: %d", e, a)
}
}

func TestConfigurationIsReady(t *testing.T) {
cases := []struct {
name string
Expand Down
14 changes: 0 additions & 14 deletions pkg/apis/serving/v1alpha1/revision_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ const (

// RevisionSpec holds the desired state of the Revision (from the client).
type RevisionSpec struct {
// TODO: Generation does not work correctly with CRD. They are scrubbed
// by the APIserver (https://github.com/kubernetes/kubernetes/issues/58778)
// So, we add Generation here. Once that gets fixed, remove this and use
// ObjectMeta.Generation instead.
Generation int64 `json:"generation,omitempty"`

// ServingState holds a value describing the desired state the Kubernetes
// resources should be in for this Revision.
// Users must not specify this when creating a revision. It is expected
Expand Down Expand Up @@ -191,14 +185,6 @@ type RevisionList struct {
Items []Revision `json:"items"`
}

func (r *Revision) GetGeneration() int64 {
return r.Spec.Generation
}

func (r *Revision) SetGeneration(generation int64) {
r.Spec.Generation = generation
}

func (r *Revision) GetSpecJSON() ([]byte, error) {
return json.Marshal(r.Spec)
}
Expand Down
13 changes: 0 additions & 13 deletions pkg/apis/serving/v1alpha1/revision_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@ import (
corev1 "k8s.io/api/core/v1"
)

func TestGeneration(t *testing.T) {
r := Revision{}
if a := r.GetGeneration(); a != 0 {
t.Errorf("empty revision generation should be 0 was: %d", a)
}

r.SetGeneration(5)
if e, a := int64(5), r.GetGeneration(); e != a {
t.Errorf("getgeneration mismatch expected: %d got: %d", e, a)
}

}

func TestIsReady(t *testing.T) {
cases := []struct {
name string
Expand Down
14 changes: 0 additions & 14 deletions pkg/apis/serving/v1alpha1/route_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ type TrafficTarget struct {

// RouteSpec holds the desired state of the Route (from the client).
type RouteSpec struct {
// TODO: Generation does not work correctly with CRD. They are scrubbed
// by the APIserver (https://github.com/kubernetes/kubernetes/issues/58778)
// So, we add Generation here. Once that gets fixed, remove this and use
// ObjectMeta.Generation instead.
Generation int64 `json:"generation,omitempty"`

// Traffic specifies how to distribute traffic over a collection of Knative Serving Revisions and Configurations.
Traffic []TrafficTarget `json:"traffic,omitempty"`
}
Expand Down Expand Up @@ -141,14 +135,6 @@ type RouteList struct {
Items []Route `json:"items"`
}

func (r *Route) GetGeneration() int64 {
return r.Spec.Generation
}

func (r *Route) SetGeneration(generation int64) {
r.Spec.Generation = generation
}

func (r *Route) GetSpecJSON() ([]byte, error) {
return json.Marshal(r.Spec)
}
Expand Down
16 changes: 1 addition & 15 deletions pkg/apis/serving/v1alpha1/service_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,8 @@ type Service struct {
}

// ServiceSpec represents the configuration for the Service object.
// Exactly one of its members (other than Generation) must be specified.
// Exactly one of its members must be specified.
type ServiceSpec struct {
// TODO: Generation does not work correctly with CRD. They are scrubbed
// by the APIserver (https://github.com/kubernetes/kubernetes/issues/58778)
// So, we add Generation here. Once that gets fixed, remove this and use
// ObjectMeta.Generation instead.
Generation int64 `json:"generation,omitempty"`

// RunLatest defines a simple Service. It will automatically
// configure a route that keeps the latest ready revision
// from the supplied configuration running.
Expand Down Expand Up @@ -108,14 +102,6 @@ type ServiceList struct {
Items []Service `json:"items"`
}

func (s *Service) GetGeneration() int64 {
return s.Spec.Generation
}

func (s *Service) SetGeneration(generation int64) {
s.Spec.Generation = generation
}

func (s *Service) GetSpecJSON() ([]byte, error) {
return json.Marshal(s.Spec)
}
Expand Down
Loading