diff --git a/Gopkg.lock b/Gopkg.lock index b686983035d..cb9dbe8ec55 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -232,11 +232,11 @@ revision = "6f77996f0c42f7b84e5a2b252227263f93432e9b" [[projects]] - digest = "1:7915c656a10819b240db94ffd6afc6a621af4687db735341d9919668750485ec" + digest = "1:10aa62acd56f635de190110a836aa261b3774e697b2b6a7af27d8263cf856d47" name = "github.com/google/go-containerregistry" packages = ["pkg/name"] pruneopts = "NUT" - revision = "abf9ef06abd9f532944e28e8942644ea4b710a40" + revision = "b02d448a3705facf11018efff34f1d2830be5724" [[projects]] digest = "1:52c5834e2bebac9030c97cc0798ac11c3aa8a39f098aeb419f142533da6cd3cc" @@ -1160,34 +1160,39 @@ revision = "8d271d903fe4c290aa361acfb242cff7bcee96f1" [[projects]] - branch = "release-0.8" - digest = "1:84ed12904805906e55c729c010f8fc2e0b1f1fc632ac8e2e3d1dd78a0b0df5f7" + branch = "release-0.9" + digest = "1:956b23f6a705b334220488771de42ef4656ee92171ab438a4726da9716737478" name = "knative.dev/pkg" packages = [ "apis", "apis/duck", + "apis/duck/v1", "apis/duck/v1alpha1", "apis/duck/v1beta1", "apis/istio", "apis/istio/common/v1alpha1", "apis/istio/v1alpha3", + "apis/v1alpha1", "configmap", "kmeta", "kmp", + "network", "ptr", ] pruneopts = "NUT" - revision = "2b848f71969c997809a2dbea8351eaadb23e9bc9" + revision = "74659889c421b26b9a416fd203f5a8d3e602bfb2" [[projects]] - digest = "1:bd209e6c1c513e386aff27d9b99ac5b50bbd62a4e849efddabc4764a90b9e52c" + digest = "1:0fe70e481a28d645302f993afc02f97a8eac5a4faa07e16a25d6e28f546b20d2" name = "knative.dev/serving" packages = [ "pkg/apis/autoscaling", + "pkg/apis/autoscaling/v1alpha1", "pkg/apis/config", "pkg/apis/networking", "pkg/apis/networking/v1alpha1", "pkg/apis/serving", + "pkg/apis/serving/v1", "pkg/apis/serving/v1alpha1", "pkg/apis/serving/v1beta1", "pkg/gc", @@ -1195,8 +1200,8 @@ "pkg/reconciler/route/config", ] pruneopts = "NUT" - revision = "3f73b117b61ee5d8fe5dcedd6cca2c96014329a9" - version = "v0.8.0" + revision = "b066e90ccd6f091e0faf65a759f3ce789d373457" + version = "v0.9.0" [[projects]] digest = "1:45fb4267f4868479b71ec2b2aff638a24ff09dc11568f6ceb087dabbc856f455" @@ -1279,6 +1284,7 @@ analyzer-version = 1 input-imports = [ "github.com/cloudevents/sdk-go", + "github.com/cloudevents/sdk-go/pkg/cloudevents/transport", "github.com/emicklei/go-restful", "github.com/getkin/kin-openapi/openapi3", "github.com/getkin/kin-openapi/openapi3filter", @@ -1288,6 +1294,7 @@ "github.com/golang/protobuf/ptypes/any", "github.com/google/go-cmp/cmp", "github.com/google/go-cmp/cmp/cmpopts", + "github.com/google/uuid", "github.com/mattbaird/jsonpatch", "github.com/onsi/ginkgo", "github.com/onsi/gomega", @@ -1342,7 +1349,6 @@ "knative.dev/serving/pkg/apis/serving", "knative.dev/serving/pkg/apis/serving/v1alpha1", "knative.dev/serving/pkg/apis/serving/v1beta1", - "knative.dev/serving/pkg/network", "sigs.k8s.io/controller-runtime/pkg/client", "sigs.k8s.io/controller-runtime/pkg/client/config", "sigs.k8s.io/controller-runtime/pkg/controller", diff --git a/Gopkg.toml b/Gopkg.toml index d33ee564cc7..32ab2db0233 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -46,7 +46,7 @@ version="v1.4.7" [[constraint]] name = "knative.dev/serving" - version = "=v0.8.0" + version = "=v0.9" [[override]] name="sigs.k8s.io/controller-runtime" @@ -59,7 +59,7 @@ version="v1.4.7" [[override]] name = "knative.dev/pkg" - branch = "release-0.8" + branch = "release-0.9" [[override]] name = "k8s.io/api" diff --git a/pkg/apis/serving/v1alpha2/inferenceservice_status_test.go b/pkg/apis/serving/v1alpha2/inferenceservice_status_test.go index a9c8eb96bca..bb49e8b509c 100644 --- a/pkg/apis/serving/v1alpha2/inferenceservice_status_test.go +++ b/pkg/apis/serving/v1alpha2/inferenceservice_status_test.go @@ -20,6 +20,7 @@ import ( "github.com/kubeflow/kfserving/pkg/constants" "k8s.io/api/core/v1" "knative.dev/pkg/apis/duck" + duckv1 "knative.dev/pkg/apis/duck/v1" duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/serving/pkg/apis/serving/v1alpha1" "testing" @@ -59,8 +60,8 @@ func TestInferenceServiceIsReady(t *testing.T) { }, { name: "Different condition type should not be ready", defaultServiceStatus: v1alpha1.ServiceStatus{ - Status: duckv1beta1.Status{ - Conditions: duckv1beta1.Conditions{{ + Status: duckv1.Status{ + Conditions: duckv1.Conditions{{ Type: "Foo", Status: v1.ConditionTrue, }}, @@ -70,8 +71,8 @@ func TestInferenceServiceIsReady(t *testing.T) { }, { name: "False condition status should not be ready", defaultServiceStatus: v1alpha1.ServiceStatus{ - Status: duckv1beta1.Status{ - Conditions: duckv1beta1.Conditions{{ + Status: duckv1.Status{ + Conditions: duckv1.Conditions{{ Type: v1alpha1.ServiceConditionReady, Status: v1.ConditionFalse, }}, @@ -81,8 +82,8 @@ func TestInferenceServiceIsReady(t *testing.T) { }, { name: "Unknown condition status should not be ready", defaultServiceStatus: v1alpha1.ServiceStatus{ - Status: duckv1beta1.Status{ - Conditions: duckv1beta1.Conditions{{ + Status: duckv1.Status{ + Conditions: duckv1.Conditions{{ Type: v1alpha1.ServiceConditionReady, Status: v1.ConditionUnknown, }}, @@ -92,8 +93,8 @@ func TestInferenceServiceIsReady(t *testing.T) { }, { name: "Missing condition status should not be ready", defaultServiceStatus: v1alpha1.ServiceStatus{ - Status: duckv1beta1.Status{ - Conditions: duckv1beta1.Conditions{{ + Status: duckv1.Status{ + Conditions: duckv1.Conditions{{ Type: v1alpha1.ConfigurationConditionReady, }}, }, @@ -102,8 +103,8 @@ func TestInferenceServiceIsReady(t *testing.T) { }, { name: "True condition status should be ready", defaultServiceStatus: v1alpha1.ServiceStatus{ - Status: duckv1beta1.Status{ - Conditions: duckv1beta1.Conditions{{ + Status: duckv1.Status{ + Conditions: duckv1.Conditions{{ Type: v1alpha1.ConfigurationConditionReady, Status: v1.ConditionTrue, }}, @@ -121,8 +122,8 @@ func TestInferenceServiceIsReady(t *testing.T) { }, { name: "Default service, route conditions with ready status should be ready", defaultServiceStatus: v1alpha1.ServiceStatus{ - Status: duckv1beta1.Status{ - Conditions: duckv1beta1.Conditions{{ + Status: duckv1.Status{ + Conditions: duckv1.Conditions{{ Type: "Foo", Status: v1.ConditionTrue, }, { @@ -144,8 +145,8 @@ func TestInferenceServiceIsReady(t *testing.T) { }, { name: "Default/canary service, route conditions with ready status should be ready", defaultServiceStatus: v1alpha1.ServiceStatus{ - Status: duckv1beta1.Status{ - Conditions: duckv1beta1.Conditions{{ + Status: duckv1.Status{ + Conditions: duckv1.Conditions{{ Type: v1alpha1.ConfigurationConditionReady, Status: v1.ConditionTrue, }, @@ -153,8 +154,8 @@ func TestInferenceServiceIsReady(t *testing.T) { }, }, canaryServiceStatus: v1alpha1.ServiceStatus{ - Status: duckv1beta1.Status{ - Conditions: duckv1beta1.Conditions{{ + Status: duckv1.Status{ + Conditions: duckv1.Conditions{{ Type: v1alpha1.ConfigurationConditionReady, Status: v1.ConditionTrue, }, @@ -173,8 +174,8 @@ func TestInferenceServiceIsReady(t *testing.T) { }, { name: "Multiple conditions with ready status false should not be ready", defaultServiceStatus: v1alpha1.ServiceStatus{ - Status: duckv1beta1.Status{ - Conditions: duckv1beta1.Conditions{{ + Status: duckv1.Status{ + Conditions: duckv1.Conditions{{ Type: "Foo", Status: v1.ConditionTrue, }, { diff --git a/pkg/controller/inferenceservice/controller_test.go b/pkg/controller/inferenceservice/controller_test.go index 2a8c39c104d..f0b66e1bfd8 100644 --- a/pkg/controller/inferenceservice/controller_test.go +++ b/pkg/controller/inferenceservice/controller_test.go @@ -31,7 +31,7 @@ import ( testutils "github.com/kubeflow/kfserving/pkg/testing" v1 "k8s.io/api/core/v1" "knative.dev/pkg/apis" - "knative.dev/serving/pkg/apis/serving/v1beta1" + knservingv1 "knative.dev/serving/pkg/apis/serving/v1" "github.com/kubeflow/kfserving/pkg/apis/serving/v1alpha2" kfserving "github.com/kubeflow/kfserving/pkg/apis/serving/v1alpha2" @@ -39,6 +39,7 @@ import ( "golang.org/x/net/context" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + duckv1 "knative.dev/pkg/apis/duck/v1" duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/apis/istio/common/v1alpha1" istiov1alpha1 "knative.dev/pkg/apis/istio/common/v1alpha1" @@ -175,7 +176,7 @@ func TestInferenceServiceWithOnlyPredictor(t *testing.T) { }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultPredictorTimeout, PodSpec: v1.PodSpec{ Containers: []v1.Container{ @@ -206,7 +207,7 @@ func TestInferenceServiceWithOnlyPredictor(t *testing.T) { updateDefault.Status.LatestCreatedRevisionName = "revision-v1" updateDefault.Status.LatestReadyRevisionName = "revision-v1" updateDefault.Status.URL, _ = apis.ParseURL("http://revision-v1.myns.myingress.com") - updateDefault.Status.Conditions = duckv1beta1.Conditions{ + updateDefault.Status.Conditions = duckv1.Conditions{ { Type: knservingv1alpha1.ServiceConditionReady, Status: "True", @@ -406,7 +407,7 @@ func TestInferenceServiceWithDefaultAndCanaryPredictor(t *testing.T) { }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultPredictorTimeout, PodSpec: v1.PodSpec{ Containers: []v1.Container{ @@ -438,7 +439,7 @@ func TestInferenceServiceWithDefaultAndCanaryPredictor(t *testing.T) { updateDefault.Status.LatestCreatedRevisionName = "revision-v1" updateDefault.Status.LatestReadyRevisionName = "revision-v1" updateDefault.Status.URL, _ = apis.ParseURL("http://revision-v1.myns.myingress.com") - updateDefault.Status.Conditions = duckv1beta1.Conditions{ + updateDefault.Status.Conditions = duckv1.Conditions{ { Type: knservingv1alpha1.ServiceConditionReady, Status: "True", @@ -451,7 +452,7 @@ func TestInferenceServiceWithDefaultAndCanaryPredictor(t *testing.T) { updateCanary.Status.LatestCreatedRevisionName = "revision-v2" updateCanary.Status.LatestReadyRevisionName = "revision-v2" updateCanary.Status.URL, _ = apis.ParseURL("http://revision-v2.myns.myingress.com") - updateCanary.Status.Conditions = duckv1beta1.Conditions{ + updateCanary.Status.Conditions = duckv1.Conditions{ { Type: knservingv1alpha1.ServiceConditionReady, Status: "True", @@ -664,7 +665,7 @@ func TestCanaryDelete(t *testing.T) { updateDefault.Status.LatestCreatedRevisionName = "revision-v1" updateDefault.Status.LatestReadyRevisionName = "revision-v1" updateDefault.Status.URL, _ = apis.ParseURL("http://revision-v1.myns.myingress.com") - updateDefault.Status.Conditions = duckv1beta1.Conditions{ + updateDefault.Status.Conditions = duckv1.Conditions{ { Type: knservingv1alpha1.ServiceConditionReady, Status: "True", @@ -677,7 +678,7 @@ func TestCanaryDelete(t *testing.T) { updateCanary.Status.LatestCreatedRevisionName = "revision-v2" updateCanary.Status.LatestReadyRevisionName = "revision-v2" updateCanary.Status.URL, _ = apis.ParseURL("http://revision-v2.myns.myingress.com") - updateCanary.Status.Conditions = duckv1beta1.Conditions{ + updateCanary.Status.Conditions = duckv1.Conditions{ { Type: knservingv1alpha1.ServiceConditionReady, Status: "True", @@ -962,7 +963,7 @@ func TestInferenceServiceWithTransformer(t *testing.T) { }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultTransformerTimeout, PodSpec: v1.PodSpec{ Containers: []v1.Container{ @@ -995,7 +996,7 @@ func TestInferenceServiceWithTransformer(t *testing.T) { updateDefault.Status.LatestCreatedRevisionName = "revision-v1" updateDefault.Status.LatestReadyRevisionName = "revision-v1" updateDefault.Status.URL, _ = apis.ParseURL("http://revision-v1.myns.myingress.com") - updateDefault.Status.Conditions = duckv1beta1.Conditions{ + updateDefault.Status.Conditions = duckv1.Conditions{ { Type: knservingv1alpha1.ServiceConditionReady, Status: "True", @@ -1008,7 +1009,7 @@ func TestInferenceServiceWithTransformer(t *testing.T) { updateCanary.Status.LatestCreatedRevisionName = "revision-v2" updateCanary.Status.LatestReadyRevisionName = "revision-v2" updateCanary.Status.URL, _ = apis.ParseURL("http://revision-v2.myns.myingress.com") - updateCanary.Status.Conditions = duckv1beta1.Conditions{ + updateCanary.Status.Conditions = duckv1.Conditions{ { Type: knservingv1alpha1.ServiceConditionReady, Status: "True", @@ -1024,7 +1025,7 @@ func TestInferenceServiceWithTransformer(t *testing.T) { updateDefault.Status.LatestCreatedRevisionName = "t-revision-v1" updateDefault.Status.LatestReadyRevisionName = "t-revision-v1" updateDefault.Status.URL, _ = apis.ParseURL("http://t-revision-v1.myns.myingress.com") - updateDefault.Status.Conditions = duckv1beta1.Conditions{ + updateDefault.Status.Conditions = duckv1.Conditions{ { Type: knservingv1alpha1.ServiceConditionReady, Status: "True", @@ -1037,7 +1038,7 @@ func TestInferenceServiceWithTransformer(t *testing.T) { updateCanary.Status.LatestCreatedRevisionName = "t-revision-v2" updateCanary.Status.LatestReadyRevisionName = "t-revision-v2" updateCanary.Status.URL, _ = apis.ParseURL("http://t-revision-v2.myns.myingress.com") - updateCanary.Status.Conditions = duckv1beta1.Conditions{ + updateCanary.Status.Conditions = duckv1.Conditions{ { Type: knservingv1alpha1.ServiceConditionReady, Status: "True", @@ -1494,7 +1495,7 @@ func TestInferenceServiceWithExplainer(t *testing.T) { }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultExplainerTimeout, PodSpec: v1.PodSpec{ Containers: []v1.Container{ @@ -1529,7 +1530,7 @@ func TestInferenceServiceWithExplainer(t *testing.T) { updateDefault.Status.LatestCreatedRevisionName = "revision-v1" updateDefault.Status.LatestReadyRevisionName = "revision-v1" updateDefault.Status.URL, _ = apis.ParseURL("http://revision-v1.myns.myingress.com") - updateDefault.Status.Conditions = duckv1beta1.Conditions{ + updateDefault.Status.Conditions = duckv1.Conditions{ { Type: knservingv1alpha1.ServiceConditionReady, Status: "True", @@ -1542,7 +1543,7 @@ func TestInferenceServiceWithExplainer(t *testing.T) { updateCanary.Status.LatestCreatedRevisionName = "revision-v2" updateCanary.Status.LatestReadyRevisionName = "revision-v2" updateCanary.Status.URL, _ = apis.ParseURL("http://revision-v2.myns.myingress.com") - updateCanary.Status.Conditions = duckv1beta1.Conditions{ + updateCanary.Status.Conditions = duckv1.Conditions{ { Type: knservingv1alpha1.ServiceConditionReady, Status: "True", @@ -1558,7 +1559,7 @@ func TestInferenceServiceWithExplainer(t *testing.T) { updateDefault.Status.LatestCreatedRevisionName = "e-revision-v1" updateDefault.Status.LatestReadyRevisionName = "e-revision-v1" updateDefault.Status.URL, _ = apis.ParseURL("http://e-revision-v1.myns.myingress.com") - updateDefault.Status.Conditions = duckv1beta1.Conditions{ + updateDefault.Status.Conditions = duckv1.Conditions{ { Type: knservingv1alpha1.ServiceConditionReady, Status: "True", @@ -1571,7 +1572,7 @@ func TestInferenceServiceWithExplainer(t *testing.T) { updateCanary.Status.LatestCreatedRevisionName = "e-revision-v2" updateCanary.Status.LatestReadyRevisionName = "e-revision-v2" updateCanary.Status.URL, _ = apis.ParseURL("http://e-revision-v2.myns.myingress.com") - updateCanary.Status.Conditions = duckv1beta1.Conditions{ + updateCanary.Status.Conditions = duckv1.Conditions{ { Type: knservingv1alpha1.ServiceConditionReady, Status: "True", diff --git a/pkg/controller/inferenceservice/reconcilers/knative/service_reconciler_test.go b/pkg/controller/inferenceservice/reconcilers/knative/service_reconciler_test.go index 42321ea4263..0d7f5be087d 100644 --- a/pkg/controller/inferenceservice/reconcilers/knative/service_reconciler_test.go +++ b/pkg/controller/inferenceservice/reconcilers/knative/service_reconciler_test.go @@ -31,8 +31,8 @@ import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + knservingv1 "knative.dev/serving/pkg/apis/serving/v1" knservingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1" - "knative.dev/serving/pkg/apis/serving/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" ) @@ -125,7 +125,7 @@ func TestKnativeServiceReconcile(t *testing.T) { }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultPredictorTimeout, PodSpec: v1.PodSpec{ Containers: []v1.Container{ @@ -166,7 +166,7 @@ func TestKnativeServiceReconcile(t *testing.T) { }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultPredictorTimeout, PodSpec: v1.PodSpec{ Containers: []v1.Container{ @@ -225,7 +225,7 @@ func TestKnativeServiceReconcile(t *testing.T) { }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultPredictorTimeout, PodSpec: v1.PodSpec{ Containers: []v1.Container{ diff --git a/pkg/controller/inferenceservice/resources/credentials/service_account_credentials_test.go b/pkg/controller/inferenceservice/resources/credentials/service_account_credentials_test.go index 153ea181a42..a5d73b304a8 100644 --- a/pkg/controller/inferenceservice/resources/credentials/service_account_credentials_test.go +++ b/pkg/controller/inferenceservice/resources/credentials/service_account_credentials_test.go @@ -28,8 +28,8 @@ import ( "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + knservingv1 "knative.dev/serving/pkg/apis/serving/v1" "knative.dev/serving/pkg/apis/serving/v1alpha1" - "knative.dev/serving/pkg/apis/serving/v1beta1" ) var configMap = &v1.ConfigMap{ @@ -83,7 +83,7 @@ func TestS3CredentialBuilder(t *testing.T) { Spec: v1alpha1.ConfigurationSpec{ Template: &v1alpha1.RevisionTemplateSpec{ Spec: v1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ PodSpec: v1.PodSpec{ Containers: []v1.Container{ {}, @@ -98,7 +98,7 @@ func TestS3CredentialBuilder(t *testing.T) { Spec: v1alpha1.ConfigurationSpec{ Template: &v1alpha1.RevisionTemplateSpec{ Spec: v1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ PodSpec: v1.PodSpec{ Containers: []v1.Container{ { @@ -208,7 +208,7 @@ func TestGCSCredentialBuilder(t *testing.T) { Spec: v1alpha1.ConfigurationSpec{ Template: &v1alpha1.RevisionTemplateSpec{ Spec: v1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ PodSpec: v1.PodSpec{ Containers: []v1.Container{ {}, @@ -223,7 +223,7 @@ func TestGCSCredentialBuilder(t *testing.T) { Spec: v1alpha1.ConfigurationSpec{ Template: &v1alpha1.RevisionTemplateSpec{ Spec: v1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ PodSpec: v1.PodSpec{ Containers: []v1.Container{ { @@ -328,7 +328,7 @@ func TestAzureCredentialBuilder(t *testing.T) { Spec: v1alpha1.ConfigurationSpec{ Template: &v1alpha1.RevisionTemplateSpec{ Spec: v1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ PodSpec: v1.PodSpec{ Containers: []v1.Container{ {}, @@ -343,7 +343,7 @@ func TestAzureCredentialBuilder(t *testing.T) { Spec: v1alpha1.ConfigurationSpec{ Template: &v1alpha1.RevisionTemplateSpec{ Spec: v1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ PodSpec: v1.PodSpec{ Containers: []v1.Container{ { diff --git a/pkg/controller/inferenceservice/resources/knative/service.go b/pkg/controller/inferenceservice/resources/knative/service.go index 40e27ea74c8..b255032bbd7 100644 --- a/pkg/controller/inferenceservice/resources/knative/service.go +++ b/pkg/controller/inferenceservice/resources/knative/service.go @@ -29,8 +29,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/serving/pkg/apis/autoscaling" "knative.dev/serving/pkg/apis/serving" + knservingv1 "knative.dev/serving/pkg/apis/serving/v1" knservingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1" - "knative.dev/serving/pkg/apis/serving/v1beta1" ) var serviceAnnotationDisallowedList = []string{ @@ -143,7 +143,7 @@ func (c *ServiceBuilder) CreatePredictorService(name string, metadata metav1.Obj Annotations: annotations, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ // Defaulting here since this always shows a diff with nil vs 300s(knative default) // we may need to expose this field in future TimeoutSeconds: &constants.DefaultPredictorTimeout, @@ -200,7 +200,7 @@ func (c *ServiceBuilder) CreateTransformerService(name string, metadata metav1.O Annotations: annotations, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ // Defaulting here since this always shows a diff with nil vs 300s(knative default) // we may need to expose this field in future TimeoutSeconds: &constants.DefaultTransformerTimeout, @@ -261,7 +261,7 @@ func (c *ServiceBuilder) CreateExplainerService(name string, metadata metav1.Obj Annotations: annotations, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ // Defaulting here since this always shows a diff with nil vs 300s(knative default) // we may need to expose this field in future TimeoutSeconds: &constants.DefaultExplainerTimeout, diff --git a/pkg/controller/inferenceservice/resources/knative/service_test.go b/pkg/controller/inferenceservice/resources/knative/service_test.go index 2c158c17943..746a77bd204 100644 --- a/pkg/controller/inferenceservice/resources/knative/service_test.go +++ b/pkg/controller/inferenceservice/resources/knative/service_test.go @@ -19,7 +19,7 @@ package knative import ( "testing" - "knative.dev/serving/pkg/apis/serving/v1beta1" + knservingv1 "knative.dev/serving/pkg/apis/serving/v1" "github.com/google/go-cmp/cmp" "github.com/kubeflow/kfserving/pkg/apis/serving/v1alpha2" @@ -99,7 +99,7 @@ var defaultService = &knservingv1alpha1.Service{ }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultPredictorTimeout, PodSpec: v1.PodSpec{ ServiceAccountName: "testsvcacc", @@ -145,7 +145,7 @@ var canaryService = &knservingv1alpha1.Service{ }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultPredictorTimeout, PodSpec: v1.PodSpec{ Containers: []v1.Container{ @@ -264,7 +264,7 @@ func TestInferenceServiceToKnativeService(t *testing.T) { }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultPredictorTimeout, PodSpec: v1.PodSpec{ Containers: []v1.Container{ @@ -321,7 +321,7 @@ func TestInferenceServiceToKnativeService(t *testing.T) { }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultPredictorTimeout, PodSpec: v1.PodSpec{ Containers: []v1.Container{ @@ -379,7 +379,7 @@ func TestInferenceServiceToKnativeService(t *testing.T) { }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultPredictorTimeout, PodSpec: v1.PodSpec{ Containers: []v1.Container{ @@ -452,7 +452,7 @@ func TestInferenceServiceToKnativeService(t *testing.T) { }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultPredictorTimeout, PodSpec: v1.PodSpec{ Containers: []v1.Container{ @@ -592,7 +592,7 @@ func TestTransformerToKnativeService(t *testing.T) { }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultTransformerTimeout, PodSpec: v1.PodSpec{ ServiceAccountName: "testsvcacc", @@ -636,7 +636,7 @@ func TestTransformerToKnativeService(t *testing.T) { }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultTransformerTimeout, PodSpec: v1.PodSpec{ ServiceAccountName: "testsvcacc", @@ -779,7 +779,7 @@ func TestExplainerToKnativeService(t *testing.T) { }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultExplainerTimeout, PodSpec: v1.PodSpec{ Containers: []v1.Container{ @@ -822,7 +822,7 @@ func TestExplainerToKnativeService(t *testing.T) { }, }, Spec: knservingv1alpha1.RevisionSpec{ - RevisionSpec: v1beta1.RevisionSpec{ + RevisionSpec: knservingv1.RevisionSpec{ TimeoutSeconds: &constants.DefaultExplainerTimeout, PodSpec: v1.PodSpec{ Containers: []v1.Container{ diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/ref.go b/vendor/github.com/google/go-containerregistry/pkg/name/ref.go index cca3034053f..c02d82e5df4 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/ref.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/ref.go @@ -15,7 +15,6 @@ package name import ( - "errors" "fmt" ) @@ -46,5 +45,5 @@ func ParseReference(s string, opts ...Option) (Reference, error) { return d, nil } // TODO: Combine above errors into something more useful? - return nil, errors.New("could not parse reference") + return nil, NewErrBadName("could not parse reference") } diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/repository.go b/vendor/github.com/google/go-containerregistry/pkg/name/repository.go index f3337798849..5eeb8ace978 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/repository.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/repository.go @@ -50,6 +50,7 @@ func (r Repository) Name() string { if regName != "" { return regName + regRepoDelimiter + r.RepositoryStr() } + // TODO: As far as I can tell, this is unreachable. return r.RepositoryStr() } diff --git a/vendor/knative.dev/pkg/apis/condition_types.go b/vendor/knative.dev/pkg/apis/condition_types.go index 31c566807f8..c90438648b0 100644 --- a/vendor/knative.dev/pkg/apis/condition_types.go +++ b/vendor/knative.dev/pkg/apis/condition_types.go @@ -53,7 +53,7 @@ const ( ) // Conditions defines a readiness condition for a Knative resource. -// See: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#typical-status-properties +// See: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties // +k8s:deepcopy-gen=true // +k8s:openapi-gen=true type Condition struct { diff --git a/vendor/knative.dev/pkg/apis/duck/v1/addressable_types.go b/vendor/knative.dev/pkg/apis/duck/v1/addressable_types.go new file mode 100644 index 00000000000..7d804ea8859 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/duck/v1/addressable_types.go @@ -0,0 +1,114 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "context" + "fmt" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" +) + +// Addressable provides a generic mechanism for a custom resource +// definition to indicate a destination for message delivery. + +// Addressable is the schema for the destination information. This is +// typically stored in the object's `status`, as this information may +// be generated by the controller. +type Addressable struct { + URL *apis.URL `json:"url,omitempty"` +} + +var ( + // Addressable is an Implementable "duck type". + _ duck.Implementable = (*Addressable)(nil) + // Addressable is a Convertible type. + _ apis.Convertible = (*Addressable)(nil) +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// AddressableType is a skeleton type wrapping Addressable in the manner we expect +// resource writers defining compatible resources to embed it. We will +// typically use this type to deserialize Addressable ObjectReferences and +// access the Addressable data. This is not a real resource. +type AddressableType struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Status AddressStatus `json:"status"` +} + +// AddressStatus shows how we expect folks to embed Addressable in +// their Status field. +type AddressStatus struct { + Address *Addressable `json:"address,omitempty"` +} + +var ( + // Verify AddressableType resources meet duck contracts. + _ duck.Populatable = (*AddressableType)(nil) + _ apis.Listable = (*AddressableType)(nil) +) + +// GetFullType implements duck.Implementable +func (*Addressable) GetFullType() duck.Populatable { + return &AddressableType{} +} + +// ConvertUp implements apis.Convertible +func (a *Addressable) ConvertUp(ctx context.Context, to apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", to) +} + +// ConvertDown implements apis.Convertible +func (a *Addressable) ConvertDown(ctx context.Context, from apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", from) +} + +// Populate implements duck.Populatable +func (t *AddressableType) Populate() { + t.Status = AddressStatus{ + &Addressable{ + // Populate ALL fields + URL: &apis.URL{ + Scheme: "http", + Host: "foo.com", + }, + }, + } +} + +// GetListType implements apis.Listable +func (*AddressableType) GetListType() runtime.Object { + return &AddressableTypeList{} +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// AddressableTypeList is a list of AddressableType resources +type AddressableTypeList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []AddressableType `json:"items"` +} diff --git a/vendor/knative.dev/pkg/apis/duck/v1/doc.go b/vendor/knative.dev/pkg/apis/duck/v1/doc.go new file mode 100644 index 00000000000..161005b0807 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/duck/v1/doc.go @@ -0,0 +1,23 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Api versions allow the api contract for a resource to be changed while keeping +// backward compatibility by support multiple concurrent versions +// of the same resource + +// +k8s:deepcopy-gen=package +// +groupName=duck.knative.dev +package v1 diff --git a/vendor/knative.dev/pkg/apis/duck/v1/register.go b/vendor/knative.dev/pkg/apis/duck/v1/register.go new file mode 100644 index 00000000000..43f5e89ad2a --- /dev/null +++ b/vendor/knative.dev/pkg/apis/duck/v1/register.go @@ -0,0 +1,55 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis/duck" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: duck.GroupName, Version: "v1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes( + SchemeGroupVersion, + &KResource{}, + (&KResource{}).GetListType(), + &AddressableType{}, + (&AddressableType{}).GetListType(), + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/knative.dev/pkg/apis/duck/v1/source_types.go b/vendor/knative.dev/pkg/apis/duck/v1/source_types.go new file mode 100644 index 00000000000..da217c59c77 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/duck/v1/source_types.go @@ -0,0 +1,157 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "time" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" + apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" +) + +// Source is an Implementable "duck type". +var _ duck.Implementable = (*Source)(nil) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Source is the minimum resource shape to adhere to the Source Specification. +// This duck type is intended to allow implementors of Sources and +// Importers to verify their own resources meet the expectations. +// This is not a real resource. +// NOTE: The Source Specification is in progress and the shape and names could +// be modified until it has been accepted. +type Source struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec SourceSpec `json:"spec"` + Status SourceStatus `json:"status"` +} + +type SourceSpec struct { + // Sink is a reference to an object that will resolve to a domain name or a + // URI directly to use as the sink. + Sink apisv1alpha1.Destination `json:"sink,omitempty"` + + // CloudEventOverrides defines overrides to control the output format and + // modifications of the event sent to the sink. + // +optional + CloudEventOverrides *CloudEventOverrides `json:"ceOverrides,omitempty"` +} + +// CloudEventOverrides defines arguments for a Source that control the output +// format of the CloudEvents produced by the Source. +type CloudEventOverrides struct { + // Extensions specify what attribute are added or overridden on the + // outbound event. Each `Extensions` key-value pair are set on the event as + // an attribute extension independently. + // +optional + Extensions map[string]string `json:"extensions,omitempty"` +} + +// SourceStatus shows how we expect folks to embed Addressable in +// their Status field. +type SourceStatus struct { + // inherits duck/v1beta1 Status, which currently provides: + // * ObservedGeneration - the 'Generation' of the Service that was last + // processed by the controller. + // * Conditions - the latest available observations of a resource's current + // state. + Status `json:",inline"` + + // SinkURI is the current active sink URI that has been configured for the + // Source. + // +optional + SinkURI *apis.URL `json:"sinkUri,omitempty"` +} + +// IsReady returns true if the resource is ready overall. +func (ss *SourceStatus) IsReady() bool { + for _, c := range ss.Conditions { + switch c.Type { + // Look for the "happy" condition, which is the only condition that + // we can reliably understand to be the overall state of the resource. + case apis.ConditionReady, apis.ConditionSucceeded: + return c.IsTrue() + } + } + return false +} + +var ( + // Verify Source resources meet duck contracts. + _ duck.Populatable = (*Source)(nil) + _ apis.Listable = (*Source)(nil) +) + +const ( + // SourceConditionSinkProvided has status True when the Source + // has been configured with a sink target that is resolvable. + SourceConditionSinkProvided apis.ConditionType = "SinkProvided" +) + +// GetFullType implements duck.Implementable +func (*Source) GetFullType() duck.Populatable { + return &Source{} +} + +// Populate implements duck.Populatable +func (s *Source) Populate() { + s.Spec.Sink = apisv1alpha1.Destination{ + URI: &apis.URL{ + Scheme: "https", + Host: "tableflip.dev", + RawQuery: "flip=mattmoor", + }, + } + s.Spec.CloudEventOverrides = &CloudEventOverrides{ + Extensions: map[string]string{"boosh": "kakow"}, + } + s.Status.ObservedGeneration = 42 + s.Status.Conditions = Conditions{{ + // Populate ALL fields + Type: SourceConditionSinkProvided, + Status: corev1.ConditionTrue, + LastTransitionTime: apis.VolatileTime{Inner: metav1.NewTime(time.Date(1984, 02, 28, 18, 52, 00, 00, time.UTC))}, + }} + s.Status.SinkURI = &apis.URL{ + Scheme: "https", + Host: "tableflip.dev", + RawQuery: "flip=mattmoor", + } +} + +// GetListType implements apis.Listable +func (*Source) GetListType() runtime.Object { + return &SourceList{} +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SourceList is a list of Source resources +type SourceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Source `json:"items"` +} diff --git a/vendor/knative.dev/pkg/apis/duck/v1/status_types.go b/vendor/knative.dev/pkg/apis/duck/v1/status_types.go new file mode 100644 index 00000000000..68a6b476939 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/duck/v1/status_types.go @@ -0,0 +1,141 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "context" + "time" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" +) + +// Conditions is a simple wrapper around apis.Conditions to implement duck.Implementable. +type Conditions apis.Conditions + +// Conditions is an Implementable "duck type". +var _ duck.Implementable = (*Conditions)(nil) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:openapi-gen=true + +// KResource is a skeleton type wrapping Conditions in the manner we expect +// resource writers defining compatible resources to embed it. We will +// typically use this type to deserialize Conditions ObjectReferences and +// access the Conditions data. This is not a real resource. +type KResource struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Status Status `json:"status"` +} + +// Status shows how we expect folks to embed Conditions in +// their Status field. +// WARNING: Adding fields to this struct will add them to all Knative resources. +type Status struct { + // ObservedGeneration is the 'Generation' of the Service that + // was last processed by the controller. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + + // Conditions the latest available observations of a resource's current state. + // +optional + // +patchMergeKey=type + // +patchStrategy=merge + Conditions Conditions `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` +} + +var _ apis.ConditionsAccessor = (*Status)(nil) + +// GetConditions implements apis.ConditionsAccessor +func (s *Status) GetConditions() apis.Conditions { + return apis.Conditions(s.Conditions) +} + +// SetConditions implements apis.ConditionsAccessor +func (s *Status) SetConditions(c apis.Conditions) { + s.Conditions = Conditions(c) +} + +// In order for Conditions to be Implementable, KResource must be Populatable. +var _ duck.Populatable = (*KResource)(nil) + +// Ensure KResource satisfies apis.Listable +var _ apis.Listable = (*KResource)(nil) + +// GetFullType implements duck.Implementable +func (*Conditions) GetFullType() duck.Populatable { + return &KResource{} +} + +// GetCondition fetches the condition of the specified type. +func (s *Status) GetCondition(t apis.ConditionType) *apis.Condition { + for _, cond := range s.Conditions { + if cond.Type == t { + return &cond + } + } + return nil +} + +// ConvertTo helps implement apis.Convertible for types embedding this Status. +func (source *Status) ConvertTo(ctx context.Context, sink *Status) { + sink.ObservedGeneration = source.ObservedGeneration + for _, c := range source.Conditions { + switch c.Type { + // Copy over the "happy" condition, which is the only condition that + // we can reliably transfer. + case apis.ConditionReady, apis.ConditionSucceeded: + sink.SetConditions(apis.Conditions{c}) + return + } + } +} + +// Populate implements duck.Populatable +func (t *KResource) Populate() { + t.Status.ObservedGeneration = 42 + t.Status.Conditions = Conditions{{ + // Populate ALL fields + Type: "Birthday", + Status: corev1.ConditionTrue, + LastTransitionTime: apis.VolatileTime{Inner: metav1.NewTime(time.Date(1984, 02, 28, 18, 52, 00, 00, time.UTC))}, + Reason: "Celebrate", + Message: "n3wScott, find your party hat :tada:", + }} +} + +// GetListType implements apis.Listable +func (*KResource) GetListType() runtime.Object { + return &KResourceList{} +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// KResourceList is a list of KResource resources +type KResourceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []KResource `json:"items"` +} diff --git a/vendor/knative.dev/pkg/apis/duck/v1/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/apis/duck/v1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..7c2c8cc0935 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/duck/v1/zz_generated.deepcopy.go @@ -0,0 +1,361 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" + apis "knative.dev/pkg/apis" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddressStatus) DeepCopyInto(out *AddressStatus) { + *out = *in + if in.Address != nil { + in, out := &in.Address, &out.Address + *out = new(Addressable) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddressStatus. +func (in *AddressStatus) DeepCopy() *AddressStatus { + if in == nil { + return nil + } + out := new(AddressStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Addressable) DeepCopyInto(out *Addressable) { + *out = *in + if in.URL != nil { + in, out := &in.URL, &out.URL + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Addressable. +func (in *Addressable) DeepCopy() *Addressable { + if in == nil { + return nil + } + out := new(Addressable) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddressableType) DeepCopyInto(out *AddressableType) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddressableType. +func (in *AddressableType) DeepCopy() *AddressableType { + if in == nil { + return nil + } + out := new(AddressableType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AddressableType) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddressableTypeList) DeepCopyInto(out *AddressableTypeList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]AddressableType, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddressableTypeList. +func (in *AddressableTypeList) DeepCopy() *AddressableTypeList { + if in == nil { + return nil + } + out := new(AddressableTypeList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AddressableTypeList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CloudEventOverrides) DeepCopyInto(out *CloudEventOverrides) { + *out = *in + if in.Extensions != nil { + in, out := &in.Extensions, &out.Extensions + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudEventOverrides. +func (in *CloudEventOverrides) DeepCopy() *CloudEventOverrides { + if in == nil { + return nil + } + out := new(CloudEventOverrides) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in Conditions) DeepCopyInto(out *Conditions) { + { + in := &in + *out = make(Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Conditions. +func (in Conditions) DeepCopy() Conditions { + if in == nil { + return nil + } + out := new(Conditions) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KResource) DeepCopyInto(out *KResource) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KResource. +func (in *KResource) DeepCopy() *KResource { + if in == nil { + return nil + } + out := new(KResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KResource) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KResourceList) DeepCopyInto(out *KResourceList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]KResource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KResourceList. +func (in *KResourceList) DeepCopy() *KResourceList { + if in == nil { + return nil + } + out := new(KResourceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KResourceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Source) DeepCopyInto(out *Source) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Source. +func (in *Source) DeepCopy() *Source { + if in == nil { + return nil + } + out := new(Source) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Source) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SourceList) DeepCopyInto(out *SourceList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Source, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SourceList. +func (in *SourceList) DeepCopy() *SourceList { + if in == nil { + return nil + } + out := new(SourceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SourceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SourceSpec) DeepCopyInto(out *SourceSpec) { + *out = *in + in.Sink.DeepCopyInto(&out.Sink) + if in.CloudEventOverrides != nil { + in, out := &in.CloudEventOverrides, &out.CloudEventOverrides + *out = new(CloudEventOverrides) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SourceSpec. +func (in *SourceSpec) DeepCopy() *SourceSpec { + if in == nil { + return nil + } + out := new(SourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SourceStatus) DeepCopyInto(out *SourceStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + if in.SinkURI != nil { + in, out := &in.SinkURI, &out.SinkURI + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SourceStatus. +func (in *SourceStatus) DeepCopy() *SourceStatus { + if in == nil { + return nil + } + out := new(SourceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Status) DeepCopyInto(out *Status) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Status. +func (in *Status) DeepCopy() *Status { + if in == nil { + return nil + } + out := new(Status) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/pkg/apis/duck/v1alpha1/addressable_types.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/addressable_types.go index 2b5fcbd9e2e..e0b3300111d 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1alpha1/addressable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1alpha1/addressable_types.go @@ -17,11 +17,15 @@ limitations under the License. package v1alpha1 import ( + "context" + "fmt" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "knative.dev/pkg/apis" "knative.dev/pkg/apis/duck" + v1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/apis/duck/v1beta1" ) @@ -37,8 +41,12 @@ type Addressable struct { Hostname string `json:"hostname,omitempty"` } -// Addressable is an Implementable "duck type". -var _ duck.Implementable = (*Addressable)(nil) +var ( + // Addressable is an Implementable "duck type". + _ duck.Implementable = (*Addressable)(nil) + // Addressable is a Convertible type. + _ apis.Convertible = (*Addressable)(nil) +) // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -71,6 +79,35 @@ func (*Addressable) GetFullType() duck.Populatable { return &AddressableType{} } +// ConvertUp implements apis.Convertible +func (a *Addressable) ConvertUp(ctx context.Context, to apis.Convertible) error { + url := a.GetURL() + switch sink := to.(type) { + case *v1.Addressable: + sink.URL = url.DeepCopy() + return nil + case *v1beta1.Addressable: + sink.URL = url.DeepCopy() + return nil + default: + return fmt.Errorf("unknown version, got: %T", to) + } +} + +// ConvertDown implements apis.Convertible +func (a *Addressable) ConvertDown(ctx context.Context, from apis.Convertible) error { + switch source := from.(type) { + case *v1.Addressable: + a.URL = source.URL.DeepCopy() + return nil + case *v1beta1.Addressable: + a.URL = source.URL.DeepCopy() + return nil + default: + return fmt.Errorf("unknown version, got: %T", from) + } +} + // Populate implements duck.Populatable func (t *AddressableType) Populate() { t.Status = AddressStatus{ @@ -87,6 +124,7 @@ func (t *AddressableType) Populate() { } } +// GetURL returns the URL type for the Addressable. func (a Addressable) GetURL() apis.URL { if a.URL != nil { return *a.URL diff --git a/vendor/knative.dev/pkg/apis/duck/v1alpha1/conditions_types.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/conditions_types.go index 12003a58633..043ad5e8a68 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1alpha1/conditions_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1alpha1/conditions_types.go @@ -60,7 +60,7 @@ const ( ) // Conditions defines a readiness condition for a Knative resource. -// See: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#typical-status-properties +// See: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties // +k8s:deepcopy-gen=true type Condition struct { // Type of condition. diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go index 817585a3b31..2aa9de0d2e7 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go @@ -17,11 +17,15 @@ limitations under the License. package v1beta1 import ( + "context" + "fmt" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "knative.dev/pkg/apis" "knative.dev/pkg/apis/duck" + v1 "knative.dev/pkg/apis/duck/v1" ) // Addressable provides a generic mechanism for a custom resource @@ -34,8 +38,12 @@ type Addressable struct { URL *apis.URL `json:"url,omitempty"` } -// Addressable is an Implementable "duck type". -var _ duck.Implementable = (*Addressable)(nil) +var ( + // Addressable is an Implementable "duck type". + _ duck.Implementable = (*Addressable)(nil) + // Addressable is a Convertible type. + _ apis.Convertible = (*Addressable)(nil) +) // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -68,6 +76,28 @@ func (*Addressable) GetFullType() duck.Populatable { return &AddressableType{} } +// ConvertUp implements apis.Convertible +func (a *Addressable) ConvertUp(ctx context.Context, to apis.Convertible) error { + switch sink := to.(type) { + case *v1.Addressable: + sink.URL = a.URL.DeepCopy() + return nil + default: + return fmt.Errorf("unknown version, got: %T", to) + } +} + +// ConvertDown implements apis.Convertible +func (a *Addressable) ConvertDown(ctx context.Context, from apis.Convertible) error { + switch source := from.(type) { + case *v1.Addressable: + a.URL = source.URL.DeepCopy() + return nil + default: + return fmt.Errorf("unknown version, got: %T", from) + } +} + // Populate implements duck.Populatable func (t *AddressableType) Populate() { t.Status = AddressStatus{ diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/source_types.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/source_types.go new file mode 100644 index 00000000000..9358e35318c --- /dev/null +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/source_types.go @@ -0,0 +1,157 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "time" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" + apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" +) + +// Source is an Implementable "duck type". +var _ duck.Implementable = (*Source)(nil) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Source is the minimum resource shape to adhere to the Source Specification. +// This duck type is intended to allow implementors of Sources and +// Importers to verify their own resources meet the expectations. +// This is not a real resource. +// NOTE: The Source Specification is in progress and the shape and names could +// be modified until it has been accepted. +type Source struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec SourceSpec `json:"spec"` + Status SourceStatus `json:"status"` +} + +type SourceSpec struct { + // Sink is a reference to an object that will resolve to a domain name or a + // URI directly to use as the sink. + Sink apisv1alpha1.Destination `json:"sink,omitempty"` + + // CloudEventOverrides defines overrides to control the output format and + // modifications of the event sent to the sink. + // +optional + CloudEventOverrides *CloudEventOverrides `json:"ceOverrides,omitempty"` +} + +// CloudEventOverrides defines arguments for a Source that control the output +// format of the CloudEvents produced by the Source. +type CloudEventOverrides struct { + // Extensions specify what attribute are added or overridden on the + // outbound event. Each `Extensions` key-value pair are set on the event as + // an attribute extension independently. + // +optional + Extensions map[string]string `json:"extensions,omitempty"` +} + +// SourceStatus shows how we expect folks to embed Addressable in +// their Status field. +type SourceStatus struct { + // inherits duck/v1beta1 Status, which currently provides: + // * ObservedGeneration - the 'Generation' of the Service that was last + // processed by the controller. + // * Conditions - the latest available observations of a resource's current + // state. + Status `json:",inline"` + + // SinkURI is the current active sink URI that has been configured for the + // Source. + // +optional + SinkURI *apis.URL `json:"sinkUri,omitempty"` +} + +// IsReady returns true if the resource is ready overall. +func (ss *SourceStatus) IsReady() bool { + for _, c := range ss.Conditions { + switch c.Type { + // Look for the "happy" condition, which is the only condition that + // we can reliably understand to be the overall state of the resource. + case apis.ConditionReady, apis.ConditionSucceeded: + return c.IsTrue() + } + } + return false +} + +var ( + // Verify Source resources meet duck contracts. + _ duck.Populatable = (*Source)(nil) + _ apis.Listable = (*Source)(nil) +) + +const ( + // SourceConditionSinkProvided has status True when the Source + // has been configured with a sink target that is resolvable. + SourceConditionSinkProvided apis.ConditionType = "SinkProvided" +) + +// GetFullType implements duck.Implementable +func (*Source) GetFullType() duck.Populatable { + return &Source{} +} + +// Populate implements duck.Populatable +func (s *Source) Populate() { + s.Spec.Sink = apisv1alpha1.Destination{ + URI: &apis.URL{ + Scheme: "https", + Host: "tableflip.dev", + RawQuery: "flip=mattmoor", + }, + } + s.Spec.CloudEventOverrides = &CloudEventOverrides{ + Extensions: map[string]string{"boosh": "kakow"}, + } + s.Status.ObservedGeneration = 42 + s.Status.Conditions = Conditions{{ + // Populate ALL fields + Type: SourceConditionSinkProvided, + Status: corev1.ConditionTrue, + LastTransitionTime: apis.VolatileTime{Inner: metav1.NewTime(time.Date(1984, 02, 28, 18, 52, 00, 00, time.UTC))}, + }} + s.Status.SinkURI = &apis.URL{ + Scheme: "https", + Host: "tableflip.dev", + RawQuery: "flip=mattmoor", + } +} + +// GetListType implements apis.Listable +func (*Source) GetListType() runtime.Object { + return &SourceList{} +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SourceList is a list of Source resources +type SourceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Source `json:"items"` +} diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go index 329aabb64b6..da817c52b1e 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go @@ -127,6 +127,29 @@ func (in *AddressableTypeList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CloudEventOverrides) DeepCopyInto(out *CloudEventOverrides) { + *out = *in + if in.Extensions != nil { + in, out := &in.Extensions, &out.Extensions + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudEventOverrides. +func (in *CloudEventOverrides) DeepCopy() *CloudEventOverrides { + if in == nil { + return nil + } + out := new(CloudEventOverrides) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in Conditions) DeepCopyInto(out *Conditions) { { @@ -209,6 +232,111 @@ func (in *KResourceList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Source) DeepCopyInto(out *Source) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Source. +func (in *Source) DeepCopy() *Source { + if in == nil { + return nil + } + out := new(Source) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Source) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SourceList) DeepCopyInto(out *SourceList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Source, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SourceList. +func (in *SourceList) DeepCopy() *SourceList { + if in == nil { + return nil + } + out := new(SourceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SourceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SourceSpec) DeepCopyInto(out *SourceSpec) { + *out = *in + in.Sink.DeepCopyInto(&out.Sink) + if in.CloudEventOverrides != nil { + in, out := &in.CloudEventOverrides, &out.CloudEventOverrides + *out = new(CloudEventOverrides) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SourceSpec. +func (in *SourceSpec) DeepCopy() *SourceSpec { + if in == nil { + return nil + } + out := new(SourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SourceStatus) DeepCopyInto(out *SourceStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + if in.SinkURI != nil { + in, out := &in.SinkURI, &out.SinkURI + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SourceStatus. +func (in *SourceStatus) DeepCopy() *SourceStatus { + if in == nil { + return nil + } + out := new(SourceStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Status) DeepCopyInto(out *Status) { *out = *in diff --git a/vendor/knative.dev/pkg/apis/field_error.go b/vendor/knative.dev/pkg/apis/field_error.go index 59b281d6ee3..c3bb68bf2d8 100644 --- a/vendor/knative.dev/pkg/apis/field_error.go +++ b/vendor/knative.dev/pkg/apis/field_error.go @@ -312,13 +312,13 @@ func ErrDisallowedUpdateDeprecatedFields(fieldPaths ...string) *FieldError { } // ErrInvalidArrayValue constructs a FieldError for a repetetive `field` -// at `index` that has received an invalid string value. +// at `index` that has received an invalid value. func ErrInvalidArrayValue(value interface{}, field string, index int) *FieldError { return ErrInvalidValue(value, CurrentField).ViaFieldIndex(field, index) } // ErrInvalidValue constructs a FieldError for a field that has received an -// invalid string value. +// invalid value. func ErrInvalidValue(value interface{}, fieldPath string) *FieldError { return &FieldError{ Message: fmt.Sprintf("invalid value: %v", value), @@ -326,6 +326,15 @@ func ErrInvalidValue(value interface{}, fieldPath string) *FieldError { } } +// ErrGeneric constructs a FieldError to allow for the different error strings for the +// the different cases. +func ErrGeneric(diagnostic string, fieldPaths ...string) *FieldError { + return &FieldError{ + Message: diagnostic, + Paths: fieldPaths, + } +} + // ErrMissingOneOf is a variadic helper method for constructing a FieldError for // not having at least one field in a mutually exclusive field group. func ErrMissingOneOf(fieldPaths ...string) *FieldError { diff --git a/vendor/knative.dev/pkg/apis/istio/v1alpha3/destinationrule_types.go b/vendor/knative.dev/pkg/apis/istio/v1alpha3/destinationrule_types.go index 54a43b35477..820a85b6e65 100644 --- a/vendor/knative.dev/pkg/apis/istio/v1alpha3/destinationrule_types.go +++ b/vendor/knative.dev/pkg/apis/istio/v1alpha3/destinationrule_types.go @@ -125,6 +125,25 @@ type DestinationRuleSpec struct { // One or more named sets that represent individual versions of a // service. Traffic policies can be overridden at subset level. Subsets []Subset `json:"subsets,omitempty"` + + // A list of namespaces to which this destination rule is exported. + // The resolution of a destination rule to apply to a service occurs in the + // context of a hierarchy of namespaces. Exporting a destination rule allows + // it to be included in the resolution hierarchy for services in + // other namespaces. This feature provides a mechanism for service owners + // and mesh administrators to control the visibility of destination rules + // across namespace boundaries. + // + // If no namespaces are specified then the destination rule is exported to all + // namespaces by default. + // + // The value "." is reserved and defines an export to the same namespace that + // the destination rule is declared in. Similarly, the value "*" is reserved and + // defines an export to all namespaces. + // + // NOTE: in the current release, the `exportTo` value is restricted to + // "." or "*" (i.e., the current namespace or all namespaces). + ExportTo []string `json:"exportTo,omitempty"` } // Traffic policies to apply for a specific destination, across all diff --git a/vendor/knative.dev/pkg/apis/istio/v1alpha3/virtualservice_types.go b/vendor/knative.dev/pkg/apis/istio/v1alpha3/virtualservice_types.go index adb41d9e888..65d83f50258 100644 --- a/vendor/knative.dev/pkg/apis/istio/v1alpha3/virtualservice_types.go +++ b/vendor/knative.dev/pkg/apis/istio/v1alpha3/virtualservice_types.go @@ -141,6 +141,25 @@ type VirtualServiceSpec struct { TCP []TCPRoute `json:"tcp,omitempty"` TLS []TLSRoute `json:"tls,omitempty"` + + // A list of namespaces to which this destination rule is exported. + // The resolution of a destination rule to apply to a service occurs in the + // context of a hierarchy of namespaces. Exporting a destination rule allows + // it to be included in the resolution hierarchy for services in + // other namespaces. This feature provides a mechanism for service owners + // and mesh administrators to control the visibility of destination rules + // across namespace boundaries. + // + // If no namespaces are specified then the destination rule is exported to all + // namespaces by default. + // + // The value "." is reserved and defines an export to the same namespace that + // the destination rule is declared in. Similarly, the value "*" is reserved and + // defines an export to all namespaces. + // + // NOTE: in the current release, the `exportTo` value is restricted to + // "." or "*" (i.e., the current namespace or all namespaces). + ExportTo []string `json:"exportTo,omitempty"` } // Describes match conditions and actions for routing HTTP/1.1, HTTP2, and diff --git a/vendor/knative.dev/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go index b503c307ae8..24e3fa6ac39 100644 --- a/vendor/knative.dev/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go +++ b/vendor/knative.dev/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go @@ -200,6 +200,11 @@ func (in *DestinationRuleSpec) DeepCopyInto(out *DestinationRuleSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.ExportTo != nil { + in, out := &in.ExportTo, &out.ExportTo + *out = make([]string, len(*in)) + copy(*out, *in) + } return } @@ -1145,6 +1150,11 @@ func (in *VirtualServiceSpec) DeepCopyInto(out *VirtualServiceSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.ExportTo != nil { + in, out := &in.ExportTo, &out.ExportTo + *out = make([]string, len(*in)) + copy(*out, *in) + } return } diff --git a/vendor/knative.dev/pkg/apis/url.go b/vendor/knative.dev/pkg/apis/url.go index c0402016f1c..181685cd380 100644 --- a/vendor/knative.dev/pkg/apis/url.go +++ b/vendor/knative.dev/pkg/apis/url.go @@ -28,6 +28,8 @@ import ( type URL url.URL // ParseURL attempts to parse the given string as a URL. +// Compatible with net/url.Parse except in the case of an empty string, where +// the resulting *URL will be nil with no error. func ParseURL(u string) (*URL, error) { if u == "" { return nil, nil @@ -55,11 +57,14 @@ func (u *URL) UnmarshalJSON(b []byte) error { if err := json.Unmarshal(b, &ref); err != nil { return err } - r, err := ParseURL(ref) - if err != nil { + if r, err := ParseURL(ref); err != nil { return err + } else if r != nil { + *u = *r + } else { + *u = URL{} } - *u = *r + return nil } diff --git a/vendor/knative.dev/pkg/apis/v1alpha1/destination.go b/vendor/knative.dev/pkg/apis/v1alpha1/destination.go new file mode 100644 index 00000000000..0f9ee409c91 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/v1alpha1/destination.go @@ -0,0 +1,163 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "context" + "net/url" + "path" + "strings" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/equality" + + "knative.dev/pkg/apis" +) + +// Destination represents a target of an invocation over HTTP. +type Destination struct { + // ObjectReference points to an Addressable. + *corev1.ObjectReference `json:",inline"` + + // URI is for direct URI Designations. + URI *apis.URL `json:"uri,omitempty"` + + // Path is used with the resulting URL from Addressable ObjectReference or URI. Must start + // with `/`. An empty path should be represented as the nil value, not `` or `/`. Will be + // appended to the path of the resulting URL from the Addressable, or URI. + Path *string `json:"path,omitempty"` +} + +// NewDestination constructs a Destination from an object reference as a convenience. +func NewDestination(obj *corev1.ObjectReference, paths ...string) (*Destination, error) { + dest := &Destination{ + ObjectReference: obj, + } + err := dest.AppendPath(paths...) + if err != nil { + return nil, err + } + return dest, nil +} + +// NewDestinationURI constructs a Destination from a URI. +func NewDestinationURI(uri *apis.URL, paths ...string) (*Destination, error) { + dest := &Destination{ + URI: uri, + } + err := dest.AppendPath(paths...) + if err != nil { + return nil, err + } + return dest, nil +} + +// AppendPath iteratively appends paths to the Destination. +// The path will always begin with "/" unless it is empty. +// An empty path ("" or "/") will always resolve to nil. +func (current *Destination) AppendPath(paths ...string) error { + // Start with empty string or existing path + var fullpath string + if current.Path != nil { + fullpath = *current.Path + } + + // Intelligently join all the paths provided + fullpath = path.Join("/", fullpath, path.Join(paths...)) + + // Parse the URL to trim garbage + urlpath, err := apis.ParseURL(fullpath) + if err != nil { + return err + } + + // apis.ParseURL returns nil if our path was empty, then our path + // should reflect that it is not set. + if urlpath == nil { + current.Path = nil + return nil + } + + // A path of "/" adds no information, just toss it + // Note that urlpath.Path == "" is always false here (joined with "/" above). + if urlpath.Path == "/" { + current.Path = nil + return nil + } + + // Only use the plain path from the URL + current.Path = &urlpath.Path + return nil +} + +func (current *Destination) Validate(ctx context.Context) *apis.FieldError { + if current != nil { + errs := validateDestination(*current).ViaField(apis.CurrentField) + if current.Path != nil { + errs = errs.Also(validateDestinationPath(*current.Path).ViaField("path")) + } + return errs + } else { + return nil + } +} + +func validateDestination(dest Destination) *apis.FieldError { + if dest.URI != nil { + if dest.ObjectReference != nil { + return apis.ErrMultipleOneOf("uri", "[apiVersion, kind, name]") + } + if dest.URI.Host == "" || dest.URI.Scheme == "" { + return apis.ErrInvalidValue(dest.URI.String(), "uri") + } + } else if dest.ObjectReference == nil { + return apis.ErrMissingOneOf("uri", "[apiVersion, kind, name]") + } else { + return validateDestinationRef(*dest.ObjectReference) + } + return nil +} + +func validateDestinationPath(path string) *apis.FieldError { + if strings.HasPrefix(path, "/") { + if pu, err := url.Parse(path); err != nil { + return apis.ErrInvalidValue(path, apis.CurrentField) + } else if !equality.Semantic.DeepEqual(pu, &url.URL{Path: pu.Path}) { + return apis.ErrInvalidValue(path, apis.CurrentField) + } + } else { + return apis.ErrInvalidValue(path, apis.CurrentField) + } + return nil +} + +func validateDestinationRef(ref corev1.ObjectReference) *apis.FieldError { + // Check the object. + var errs *apis.FieldError + // Required Fields + if ref.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } + if ref.APIVersion == "" { + errs = errs.Also(apis.ErrMissingField("apiVersion")) + } + if ref.Kind == "" { + errs = errs.Also(apis.ErrMissingField("kind")) + } + + return errs +} diff --git a/vendor/knative.dev/pkg/apis/v1alpha1/doc.go b/vendor/knative.dev/pkg/apis/v1alpha1/doc.go new file mode 100644 index 00000000000..9fb4a2a85e7 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/v1alpha1/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:deepcopy-gen=package +package v1alpha1 diff --git a/vendor/knative.dev/pkg/apis/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/apis/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..a54dcace806 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,57 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" + apis "knative.dev/pkg/apis" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Destination) DeepCopyInto(out *Destination) { + *out = *in + if in.ObjectReference != nil { + in, out := &in.ObjectReference, &out.ObjectReference + *out = new(v1.ObjectReference) + **out = **in + } + if in.URI != nil { + in, out := &in.URI, &out.URI + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + if in.Path != nil { + in, out := &in.Path, &out.Path + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Destination. +func (in *Destination) DeepCopy() *Destination { + if in == nil { + return nil + } + out := new(Destination) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/pkg/configmap/informed_watcher.go b/vendor/knative.dev/pkg/configmap/informed_watcher.go index 5903d59d7e7..0189a9a235b 100644 --- a/vendor/knative.dev/pkg/configmap/informed_watcher.go +++ b/vendor/knative.dev/pkg/configmap/informed_watcher.go @@ -18,9 +18,9 @@ package configmap import ( "errors" - "time" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/equality" k8serrors "k8s.io/apimachinery/pkg/api/errors" informers "k8s.io/client-go/informers" corev1informers "k8s.io/client-go/informers/core/v1" @@ -51,8 +51,9 @@ func NewInformedWatcherFromFactory(sif informers.SharedInformerFactory, namespac func NewInformedWatcher(kc kubernetes.Interface, namespace string) *InformedWatcher { return NewInformedWatcherFromFactory(informers.NewSharedInformerFactoryWithOptions( kc, - // This is the default resync period from controller-runtime. - 10*time.Hour, + // We noticed that we're getting updates all the time anyway, due to the + // watches being terminated and re-spawned. + 0, informers.WithNamespace(namespace), ), namespace) } @@ -79,7 +80,7 @@ var _ Watcher = (*InformedWatcher)(nil) var _ DefaultingWatcher = (*InformedWatcher)(nil) // WatchWithDefault implements DefaultingWatcher. -func (i *InformedWatcher) WatchWithDefault(cm corev1.ConfigMap, o Observer) { +func (i *InformedWatcher) WatchWithDefault(cm corev1.ConfigMap, o ...Observer) { i.defaults[cm.Name] = &cm i.m.Lock() @@ -94,7 +95,7 @@ func (i *InformedWatcher) WatchWithDefault(cm corev1.ConfigMap, o Observer) { panic("cannot WatchWithDefault after the InformedWatcher has started") } - i.Watch(cm.Name, o) + i.Watch(cm.Name, o...) } // Start implements Watcher. @@ -140,17 +141,14 @@ func (i *InformedWatcher) registerCallbackAndStartInformer(stopCh <-chan struct{ } func (i *InformedWatcher) checkObservedResourcesExist() error { - i.m.Lock() - defer i.m.Unlock() + i.m.RLock() + defer i.m.RUnlock() // Check that all objects with Observers exist in our informers. for k := range i.observers { - _, err := i.informer.Lister().ConfigMaps(i.Namespace).Get(k) - if err != nil { - if k8serrors.IsNotFound(err) { - if _, ok := i.defaults[k]; ok { - // It is defaulted, so it is OK that it doesn't exist. - continue - } + if _, err := i.informer.Lister().ConfigMaps(i.Namespace).Get(k); err != nil { + if _, ok := i.defaults[k]; ok && k8serrors.IsNotFound(err) { + // It is defaulted, so it is OK that it doesn't exist. + continue } return err } @@ -163,8 +161,13 @@ func (i *InformedWatcher) addConfigMapEvent(obj interface{}) { i.OnChange(configMap) } -func (i *InformedWatcher) updateConfigMapEvent(old, new interface{}) { - configMap := new.(*corev1.ConfigMap) +func (i *InformedWatcher) updateConfigMapEvent(o, n interface{}) { + // Ignore updates that are idempotent. We are seeing those + // periodically. + if equality.Semantic.DeepEqual(o, n) { + return + } + configMap := n.(*corev1.ConfigMap) i.OnChange(configMap) } diff --git a/vendor/knative.dev/pkg/configmap/manual_watcher.go b/vendor/knative.dev/pkg/configmap/manual_watcher.go index ad243de55dc..4774e5227ff 100644 --- a/vendor/knative.dev/pkg/configmap/manual_watcher.go +++ b/vendor/knative.dev/pkg/configmap/manual_watcher.go @@ -27,7 +27,7 @@ type ManualWatcher struct { Namespace string // Guards mutations to defaultImpl fields - m sync.Mutex + m sync.RWMutex observers map[string][]Observer } @@ -35,14 +35,14 @@ type ManualWatcher struct { var _ Watcher = (*ManualWatcher)(nil) // Watch implements Watcher -func (w *ManualWatcher) Watch(name string, o Observer) { +func (w *ManualWatcher) Watch(name string, o ...Observer) { w.m.Lock() defer w.m.Unlock() if w.observers == nil { w.observers = make(map[string][]Observer, 1) } - w.observers[name] = append(w.observers[name], o) + w.observers[name] = append(w.observers[name], o...) } func (w *ManualWatcher) Start(<-chan struct{}) error { @@ -54,8 +54,8 @@ func (w *ManualWatcher) OnChange(configMap *corev1.ConfigMap) { return } // Within our namespace, take the lock and see if there are any registered observers. - w.m.Lock() - defer w.m.Unlock() + w.m.RLock() + defer w.m.RUnlock() observers, ok := w.observers[configMap.Name] if !ok { return // No observers. diff --git a/vendor/knative.dev/pkg/configmap/static_watcher.go b/vendor/knative.dev/pkg/configmap/static_watcher.go index 96a01140dbd..43ff9de3cb1 100644 --- a/vendor/knative.dev/pkg/configmap/static_watcher.go +++ b/vendor/knative.dev/pkg/configmap/static_watcher.go @@ -48,10 +48,12 @@ type StaticWatcher struct { var _ Watcher = (*StaticWatcher)(nil) // Watch implements Watcher -func (di *StaticWatcher) Watch(name string, o Observer) { +func (di *StaticWatcher) Watch(name string, o ...Observer) { cm, ok := di.cfgs[name] if ok { - o(cm) + for _, observer := range o { + observer(cm) + } } else { panic(fmt.Sprintf("Tried to watch unknown config with name %q", name)) } diff --git a/vendor/knative.dev/pkg/configmap/watcher.go b/vendor/knative.dev/pkg/configmap/watcher.go index 71a18f4953f..ff703dbc75c 100644 --- a/vendor/knative.dev/pkg/configmap/watcher.go +++ b/vendor/knative.dev/pkg/configmap/watcher.go @@ -28,8 +28,8 @@ type Observer func(*corev1.ConfigMap) // Watcher defines the interface that a configmap implementation must implement. type Watcher interface { - // Watch is called to register a callback to be notified when a named ConfigMap changes. - Watch(string, Observer) + // Watch is called to register callbacks to be notified when a named ConfigMap changes. + Watch(string, ...Observer) // Start is called to initiate the watches and provide a channel to signal when we should // stop watching. When Start returns, all registered Observers will be called with the @@ -42,8 +42,8 @@ type Watcher interface { type DefaultingWatcher interface { Watcher - // WatchWithDefault is called to register a callback to be notified when a named ConfigMap + // WatchWithDefault is called to register callbacks to be notified when a named ConfigMap // changes. The provided default value is always observed before any real ConfigMap with that // name is. If the real ConfigMap with that name is deleted, then the default value is observed. - WatchWithDefault(cm corev1.ConfigMap, o Observer) + WatchWithDefault(cm corev1.ConfigMap, o ...Observer) } diff --git a/vendor/knative.dev/pkg/kmeta/names.go b/vendor/knative.dev/pkg/kmeta/names.go index 6d5b21841d3..0e6bea26391 100644 --- a/vendor/knative.dev/pkg/kmeta/names.go +++ b/vendor/knative.dev/pkg/kmeta/names.go @@ -26,15 +26,35 @@ import ( const ( longest = 63 md5Len = 32 - head = longest - md5Len + head = longest - md5Len // How much to truncate to fit the hash. ) // ChildName generates a name for the resource based upon the parent resource and suffix. // If the concatenated name is longer than K8s permits the name is hashed and truncated to permit // construction of the resource, but still keeps it unique. +// If the suffix itself is longer than 31 characters, then the whole string will be hashed +// and `parent|hash|suffix` will be returned, where parent and suffix will be trimmed to +// fit (prefix of parent at most of length 31, and prefix of suffix at most length 30). func ChildName(parent, suffix string) string { n := parent if len(parent) > (longest - len(suffix)) { + // If the suffix is longer than the longest allowed suffix, then + // we hash the whole combined string and use that as the suffix. + if head-len(suffix) <= 0 { + h := md5.Sum([]byte(parent + suffix)) + // 1. trim parent, if needed + if head < len(parent) { + parent = parent[:head] + } + // Format the return string, if it's shorter than longest: pad with + // beginning of the suffix. This happens, for example, when parent is + // short, but the suffix is very long. + ret := parent + fmt.Sprintf("%x", h) + if d := longest - len(ret); d > 0 { + ret += suffix[:d] + } + return ret + } n = fmt.Sprintf("%s%x", parent[:head-len(suffix)], md5.Sum([]byte(parent))) } return n + suffix diff --git a/vendor/knative.dev/pkg/network/doc.go b/vendor/knative.dev/pkg/network/doc.go new file mode 100644 index 00000000000..133ce55ea84 --- /dev/null +++ b/vendor/knative.dev/pkg/network/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package network holds the typed objects that define the schemas for +// configuring the knative networking layer. +package network diff --git a/vendor/knative.dev/serving/pkg/network/domain.go b/vendor/knative.dev/pkg/network/domain.go similarity index 100% rename from vendor/knative.dev/serving/pkg/network/domain.go rename to vendor/knative.dev/pkg/network/domain.go diff --git a/vendor/knative.dev/pkg/third_party/mako/LICENSE b/vendor/knative.dev/pkg/third_party/mako/LICENSE new file mode 100644 index 00000000000..fef7d967815 --- /dev/null +++ b/vendor/knative.dev/pkg/third_party/mako/LICENSE @@ -0,0 +1,204 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/activator/kodata/refs b/vendor/knative.dev/serving/cmd/activator/kodata/refs new file mode 120000 index 00000000000..739d35bf96a --- /dev/null +++ b/vendor/knative.dev/serving/cmd/activator/kodata/refs @@ -0,0 +1 @@ +../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/refs b/vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/refs new file mode 120000 index 00000000000..739d35bf96a --- /dev/null +++ b/vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/refs @@ -0,0 +1 @@ +../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/autoscaler/kodata/refs b/vendor/knative.dev/serving/cmd/autoscaler/kodata/refs new file mode 120000 index 00000000000..739d35bf96a --- /dev/null +++ b/vendor/knative.dev/serving/cmd/autoscaler/kodata/refs @@ -0,0 +1 @@ +../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/controller/kodata/refs b/vendor/knative.dev/serving/cmd/controller/kodata/refs new file mode 120000 index 00000000000..739d35bf96a --- /dev/null +++ b/vendor/knative.dev/serving/cmd/controller/kodata/refs @@ -0,0 +1 @@ +../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/certmanager/kodata/refs b/vendor/knative.dev/serving/cmd/networking/certmanager/kodata/refs new file mode 120000 index 00000000000..fe164fe40f7 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/certmanager/kodata/refs @@ -0,0 +1 @@ +../../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/istio/kodata/refs b/vendor/knative.dev/serving/cmd/networking/istio/kodata/refs new file mode 120000 index 00000000000..fe164fe40f7 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/istio/kodata/refs @@ -0,0 +1 @@ +../../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/nscert/kodata/HEAD b/vendor/knative.dev/serving/cmd/networking/nscert/kodata/HEAD new file mode 120000 index 00000000000..481bd4eff49 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/nscert/kodata/HEAD @@ -0,0 +1 @@ +../../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/nscert/kodata/LICENSE b/vendor/knative.dev/serving/cmd/networking/nscert/kodata/LICENSE new file mode 120000 index 00000000000..14776154326 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/nscert/kodata/LICENSE @@ -0,0 +1 @@ +../../../../LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/nscert/kodata/VENDOR-LICENSE b/vendor/knative.dev/serving/cmd/networking/nscert/kodata/VENDOR-LICENSE new file mode 120000 index 00000000000..7322c09d957 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/nscert/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/queue/kodata/refs b/vendor/knative.dev/serving/cmd/queue/kodata/refs new file mode 120000 index 00000000000..739d35bf96a --- /dev/null +++ b/vendor/knative.dev/serving/cmd/queue/kodata/refs @@ -0,0 +1 @@ +../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/webhook/kodata/refs b/vendor/knative.dev/serving/cmd/webhook/kodata/refs new file mode 120000 index 00000000000..739d35bf96a --- /dev/null +++ b/vendor/knative.dev/serving/cmd/webhook/kodata/refs @@ -0,0 +1 @@ +../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/annotation_validation.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/annotation_validation.go index b7d18518c07..db573d343de 100644 --- a/vendor/knative.dev/serving/pkg/apis/autoscaling/annotation_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/annotation_validation.go @@ -41,7 +41,7 @@ func ValidateAnnotations(anns map[string]string) *apis.FieldError { if len(anns) == 0 { return nil } - return validateMinMaxScale(anns).Also(validateFloats(anns)).Also(validateWindows(anns)) + return validateMinMaxScale(anns).Also(validateFloats(anns)).Also(validateWindows(anns).Also(validateMetric(anns))) } func validateFloats(annotations map[string]string) *apis.FieldError { @@ -115,3 +115,29 @@ func validateMinMaxScale(annotations map[string]string) *apis.FieldError { } return errs } + +func validateMetric(annotations map[string]string) *apis.FieldError { + if metric, ok := annotations[MetricAnnotationKey]; ok { + classValue := KPA + if c, ok := annotations[ClassAnnotationKey]; ok { + classValue = c + } + switch classValue { + case KPA: + switch metric { + case Concurrency, RPS: + return nil + } + case HPA: + switch metric { + case CPU, Concurrency, RPS: + return nil + } + default: + // Leave other classes of PodAutoscaler alone. + return nil + } + return apis.ErrInvalidValue(metric, MetricAnnotationKey) + } + return nil +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/register.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/register.go index a9bbce86651..88526ce583b 100644 --- a/vendor/knative.dev/serving/pkg/apis/autoscaling/register.go +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/register.go @@ -19,8 +19,10 @@ package autoscaling import "time" const ( + // The internal autoscaling group name. This is used for CRDs. InternalGroupName = "autoscaling.internal.knative.dev" + // The publuc autoscaling group name. This is used for annotations, labels, etc. GroupName = "autoscaling.knative.dev" // ClassAnnotationKey is the annotation for the explicit class of autoscaler @@ -50,6 +52,8 @@ const ( Concurrency = "concurrency" // CPU is the amount of the requested cpu actually being consumed by the Pod. CPU = "cpu" + // RPS is the requests per second reaching the Pod. + RPS = "rps" // TargetAnnotationKey is the annotation to specify what metric value the // PodAutoscaler should attempt to maintain. For example, diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/doc.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/doc.go new file mode 100644 index 00000000000..bcdf80570a8 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2018 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:deepcopy-gen=package +// +groupName=autoscaling.internal.knative.dev +package v1alpha1 diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_defaults.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_defaults.go new file mode 100644 index 00000000000..635297923aa --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_defaults.go @@ -0,0 +1,31 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "context" + + "knative.dev/pkg/apis" +) + +// SetDefaults sets defaults on the entire Metric if applicable. +func (m *Metric) SetDefaults(ctx context.Context) { + m.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +// SetDefaults sets defaults on the Metric's Spec if applicable. +func (ms *MetricSpec) SetDefaults(ctx context.Context) {} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_lifecycle.go new file mode 100644 index 00000000000..838577a5b9f --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_lifecycle.go @@ -0,0 +1,73 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +const ( + // MetricConditionReady is set when the Metric's latest + // underlying revision has reported readiness. + MetricConditionReady = apis.ConditionReady +) + +var condSet = apis.NewLivingConditionSet( + MetricConditionReady, +) + +// GetGroupVersionKind implements OwnerRefable. +func (m *Metric) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Metric") +} + +// GetCondition gets the condition `t`. +func (ms *MetricStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return condSet.Manage(ms).GetCondition(t) +} + +// InitializeConditions initializes the conditions of the Metric. +func (ms *MetricStatus) InitializeConditions() { + condSet.Manage(ms).InitializeConditions() +} + +// MarkMetricReady marks the metric status as ready +func (ms *MetricStatus) MarkMetricReady() { + condSet.Manage(ms).MarkTrue(MetricConditionReady) +} + +// MarkMetricNotReady marks the metric status as ready == Unknown +func (ms *MetricStatus) MarkMetricNotReady(reason, message string) { + condSet.Manage(ms).MarkUnknown(MetricConditionReady, reason, message) +} + +// MarkMetricFailed marks the metric status as failed +func (ms *MetricStatus) MarkMetricFailed(reason, message string) { + condSet.Manage(ms).MarkFalse(MetricConditionReady, reason, message) +} + +// IsReady looks at the conditions and if the condition MetricConditionReady +// is true +func (ms *MetricStatus) IsReady() bool { + return condSet.Manage(ms.duck()).IsHappy() +} + +func (ms *MetricStatus) duck() *duckv1.Status { + return (*duckv1.Status)(&ms.Status) +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_types.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_types.go new file mode 100644 index 00000000000..dca3e6d7c74 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_types.go @@ -0,0 +1,79 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "time" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" +) + +// Metric represents a resource to configure the metric collector with. +// +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type Metric struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the Metric (from the client). + // +optional + Spec MetricSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the Metric (from the controller). + // +optional + Status MetricStatus `json:"status,omitempty"` +} + +// Verify that Metric adheres to the appropriate interfaces. +var ( + // Check that Metric can be validated and can be defaulted. + _ apis.Validatable = (*Metric)(nil) + _ apis.Defaultable = (*Metric)(nil) + + // Check that we can create OwnerReferences to a Metric. + _ kmeta.OwnerRefable = (*Metric)(nil) +) + +// MetricSpec contains all values a metric collector needs to operate. +type MetricSpec struct { + // StableWindow is the aggregation window for metrics in a stable state. + StableWindow time.Duration `json:"stableWindow"` + // PanicWindow is the aggregation window for metrics where quick reactions are needed. + PanicWindow time.Duration `json:"panicWindow"` + // ScrapeTarget is the K8s service that publishes the metric endpoint. + ScrapeTarget string `json:"scrapeTarget"` +} + +// MetricStatus reflects the status of metric collection for this specific entity. +type MetricStatus struct { + duckv1.Status `json:",inline"` +} + +// MetricList is a list of Metric resources +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type MetricList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Metric `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_validation.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_validation.go new file mode 100644 index 00000000000..e0c8d182d95 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_validation.go @@ -0,0 +1,39 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "context" + + "k8s.io/apimachinery/pkg/api/equality" + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" +) + +// Validate validates the entire Metric. +func (m *Metric) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidateObjectMetadata(m.GetObjectMeta()).ViaField("metadata") + return errs.Also(m.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) +} + +// Validate validates Metric's Spec. +func (ms *MetricSpec) Validate(ctx context.Context) *apis.FieldError { + if equality.Semantic.DeepEqual(ms, &MetricSpec{}) { + return apis.ErrMissingField(apis.CurrentField) + } + return nil +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_defaults.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_defaults.go new file mode 100644 index 00000000000..92131163519 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_defaults.go @@ -0,0 +1,52 @@ +/* +Copyright 2018 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "context" + + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/autoscaling" +) + +func defaultMetric(class string) string { + switch class { + case autoscaling.KPA: + return autoscaling.Concurrency + case autoscaling.HPA: + return autoscaling.CPU + default: + return "" + } +} + +func (r *PodAutoscaler) SetDefaults(ctx context.Context) { + r.Spec.SetDefaults(apis.WithinSpec(ctx)) + if r.Annotations == nil { + r.Annotations = make(map[string]string) + } + if _, ok := r.Annotations[autoscaling.ClassAnnotationKey]; !ok { + // Default class to KPA. + r.Annotations[autoscaling.ClassAnnotationKey] = autoscaling.KPA + } + // Default metric per class + if _, ok := r.Annotations[autoscaling.MetricAnnotationKey]; !ok { + r.Annotations[autoscaling.MetricAnnotationKey] = defaultMetric(r.Class()) + } +} + +func (rs *PodAutoscalerSpec) SetDefaults(ctx context.Context) {} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_lifecycle.go new file mode 100644 index 00000000000..53203e56fb0 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_lifecycle.go @@ -0,0 +1,237 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "fmt" + "strconv" + "time" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/serving/pkg/apis/autoscaling" +) + +var podCondSet = apis.NewLivingConditionSet( + PodAutoscalerConditionActive, +) + +func (pa *PodAutoscaler) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("PodAutoscaler") +} + +func (pa *PodAutoscaler) Class() string { + if c, ok := pa.Annotations[autoscaling.ClassAnnotationKey]; ok { + return c + } + // Default to "kpa" class for backward compatibility. + return autoscaling.KPA +} + +// Metric returns the contents of the metric annotation or a default. +func (pa *PodAutoscaler) Metric() string { + if m, ok := pa.Annotations[autoscaling.MetricAnnotationKey]; ok { + return m + } + // TODO: defaulting here is awkward and is already taken care of by defaulting logic. + return defaultMetric(pa.Class()) +} + +func (pa *PodAutoscaler) annotationInt32(key string) int32 { + if s, ok := pa.Annotations[key]; ok { + // no error check: relying on validation + i, _ := strconv.ParseInt(s, 10, 32) + if i < 0 { + return 0 + } + return int32(i) + } + return 0 +} + +func (pa *PodAutoscaler) annotationFloat64(key string) (float64, bool) { + if s, ok := pa.Annotations[key]; ok { + f, err := strconv.ParseFloat(s, 64) + return f, err == nil + } + return 0.0, false +} + +// ScaleBounds returns scale bounds annotations values as a tuple: +// `(min, max int32)`. The value of 0 for any of min or max means the bound is +// not set. +// Note: min will be ignored if the PA is not reachable +func (pa *PodAutoscaler) ScaleBounds() (min, max int32) { + if pa.Spec.Reachability != ReachabilityUnreachable { + min = pa.annotationInt32(autoscaling.MinScaleAnnotationKey) + } + max = pa.annotationInt32(autoscaling.MaxScaleAnnotationKey) + + return +} + +// Target returns the target annotation value or false if not present, or invalid. +func (pa *PodAutoscaler) Target() (float64, bool) { + return pa.annotationFloat64(autoscaling.TargetAnnotationKey) +} + +// TargetUtilization returns the target capacity utilization as a fraction, +// if the corresponding annotation is set. +func (pa *PodAutoscaler) TargetUtilization() (float64, bool) { + if tu, ok := pa.annotationFloat64(autoscaling.TargetUtilizationPercentageKey); ok { + return tu / 100, true + } + return 0, false +} + +// TargetBC returns the target burst capacity, +// if the corresponding annotation is set. +func (pa *PodAutoscaler) TargetBC() (float64, bool) { + // The value is validated in the webhook. + return pa.annotationFloat64(autoscaling.TargetBurstCapacityKey) +} + +// Window returns the window annotation value or false if not present. +func (pa *PodAutoscaler) Window() (window time.Duration, ok bool) { + // The value is validated in the webhook. + if s, ok := pa.Annotations[autoscaling.WindowAnnotationKey]; ok { + d, err := time.ParseDuration(s) + return d, err == nil + } + return 0, false +} + +// PanicWindowPercentage returns panic window annotation value or false if not present. +func (pa *PodAutoscaler) PanicWindowPercentage() (percentage float64, ok bool) { + // The value is validated in the webhook. + return pa.annotationFloat64(autoscaling.PanicWindowPercentageAnnotationKey) +} + +// PanicThresholdPercentage return the panic target annotation value or false if not present. +func (pa *PodAutoscaler) PanicThresholdPercentage() (percentage float64, ok bool) { + // The value is validated in the webhook. + return pa.annotationFloat64(autoscaling.PanicThresholdPercentageAnnotationKey) +} + +// IsReady looks at the conditions and if the Status has a condition +// PodAutoscalerConditionReady returns true if ConditionStatus is True +func (pas *PodAutoscalerStatus) IsReady() bool { + return podCondSet.Manage(pas.duck()).IsHappy() +} + +// IsActivating returns true if the pod autoscaler is Activating if it is neither +// Active nor Inactive +func (pas *PodAutoscalerStatus) IsActivating() bool { + cond := pas.GetCondition(PodAutoscalerConditionActive) + return cond != nil && cond.Status == corev1.ConditionUnknown +} + +// IsInactive returns true if the pod autoscaler is Inactive. +func (pas *PodAutoscalerStatus) IsInactive() bool { + cond := pas.GetCondition(PodAutoscalerConditionActive) + return cond != nil && cond.Status == corev1.ConditionFalse +} + +// GetCondition gets the condition `t`. +func (pas *PodAutoscalerStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return podCondSet.Manage(pas.duck()).GetCondition(t) +} + +// InitializeConditions initializes the conditionhs of the PA. +func (pas *PodAutoscalerStatus) InitializeConditions() { + podCondSet.Manage(pas.duck()).InitializeConditions() +} + +// MarkActive marks the PA active. +func (pas *PodAutoscalerStatus) MarkActive() { + podCondSet.Manage(pas.duck()).MarkTrue(PodAutoscalerConditionActive) +} + +// MarkActivating marks the PA as activating. +func (pas *PodAutoscalerStatus) MarkActivating(reason, message string) { + podCondSet.Manage(pas.duck()).MarkUnknown(PodAutoscalerConditionActive, reason, message) +} + +// MarkInactive marks the PA as inactive. +func (pas *PodAutoscalerStatus) MarkInactive(reason, message string) { + podCondSet.Manage(pas.duck()).MarkFalse(PodAutoscalerConditionActive, reason, message) +} + +// MarkResourceNotOwned changes the "Active" condition to false to reflect that the +// resource of the given kind and name has already been created, and we do not own it. +func (pas *PodAutoscalerStatus) MarkResourceNotOwned(kind, name string) { + pas.MarkInactive("NotOwned", + fmt.Sprintf("There is an existing %s %q that we do not own.", kind, name)) +} + +// MarkResourceFailedCreation changes the "Active" condition to false to reflect that a +// critical resource of the given kind and name was unable to be created. +func (pas *PodAutoscalerStatus) MarkResourceFailedCreation(kind, name string) { + pas.MarkInactive("FailedCreate", + fmt.Sprintf("Failed to create %s %q.", kind, name)) +} + +// CanScaleToZero checks whether the pod autoscaler has been in an inactive state +// for at least the specified grace period. +func (pas *PodAutoscalerStatus) CanScaleToZero(now time.Time, gracePeriod time.Duration) bool { + return pas.inStatusFor(corev1.ConditionFalse, now, gracePeriod) > 0 +} + +// ActiveFor returns the time PA spent being active. +func (pas *PodAutoscalerStatus) ActiveFor(now time.Time) time.Duration { + return pas.inStatusFor(corev1.ConditionTrue, now, 0) +} + +// CanFailActivation checks whether the pod autoscaler has been activating +// for at least the specified idle period. +func (pas *PodAutoscalerStatus) CanFailActivation(now time.Time, idlePeriod time.Duration) bool { + return pas.inStatusFor(corev1.ConditionUnknown, now, idlePeriod) > 0 +} + +// inStatusFor returns positive duration if the PodAutoscalerStatus's Active condition has stayed in +// the specified status for at least the specified duration. Otherwise it returns negative duration, +// including when the status is undetermined (Active condition is not found.) +func (pas *PodAutoscalerStatus) inStatusFor(status corev1.ConditionStatus, now time.Time, dur time.Duration) time.Duration { + cond := pas.GetCondition(PodAutoscalerConditionActive) + if cond == nil || cond.Status != status { + return -1 + } + return now.Sub(cond.LastTransitionTime.Inner.Add(dur)) +} + +func (pas *PodAutoscalerStatus) duck() *duckv1.Status { + return (*duckv1.Status)(&pas.Status) +} + +// GetDesiredScale returns the desired scale if ever set, or -1. +func (pas *PodAutoscalerStatus) GetDesiredScale() int32 { + if pas.DesiredScale != nil { + return *pas.DesiredScale + } + return -1 +} + +// GetActualScale returns the desired scale if ever set, or -1. +func (pas *PodAutoscalerStatus) GetActualScale() int32 { + if pas.ActualScale != nil { + return *pas.ActualScale + } + return -1 +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go new file mode 100644 index 00000000000..7cda594f12c --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go @@ -0,0 +1,146 @@ +/* +Copyright 2018 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" + net "knative.dev/serving/pkg/apis/networking" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PodAutoscaler is a Knative abstraction that encapsulates the interface by which Knative +// components instantiate autoscalers. This definition is an abstraction that may be backed +// by multiple definitions. For more information, see the Knative Pluggability presentation: +// https://docs.google.com/presentation/d/10KWynvAJYuOEWy69VBa6bHJVCqIsz1TNdEKosNvcpPY/edit +type PodAutoscaler struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the PodAutoscaler (from the client). + // +optional + Spec PodAutoscalerSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the PodAutoscaler (from the controller). + // +optional + Status PodAutoscalerStatus `json:"status,omitempty"` +} + +// Verify that PodAutoscaler adheres to the appropriate interfaces. +var ( + // Check that PodAutoscaler can be validated and can be defaulted. + _ apis.Validatable = (*PodAutoscaler)(nil) + _ apis.Defaultable = (*PodAutoscaler)(nil) + + // Check that we can create OwnerReferences to a PodAutoscaler. + _ kmeta.OwnerRefable = (*PodAutoscaler)(nil) +) + +// ReachabilityType is the enumeration type for the different states of reachability +// to the `ScaleTarget` of a `PodAutoscaler` +type ReachabilityType string + +const ( + // ReachabilityUnknown means the reachability of the `ScaleTarget` is unknown. + // Used when the reachability cannot be determined, eg. during activation. + ReachabilityUnknown ReachabilityType = "" + + // ReachabilityReachable means the `ScaleTarget` is reachable, ie. it has an active route. + ReachabilityReachable ReachabilityType = "Reachable" + + // ReachabilityReachable means the `ScaleTarget` is not reachable, ie. it does not have an active route. + ReachabilityUnreachable ReachabilityType = "Unreachable" +) + +// PodAutoscalerSpec holds the desired state of the PodAutoscaler (from the client). +type PodAutoscalerSpec struct { + // DeprecatedGeneration was used prior in Kubernetes versions <1.11 + // when metadata.generation was not being incremented by the api server + // + // This property will be dropped in future Knative releases and should + // not be used - use metadata.generation + // + // Tracking issue: https://knative.dev/serving/issues/643 + // + // +optional + DeprecatedGeneration int64 `json:"generation,omitempty"` + + // ContainerConcurrency specifies the maximum allowed + // in-flight (concurrent) requests per container of the Revision. + // Defaults to `0` which means unlimited concurrency. + // +optional + ContainerConcurrency int64 `json:"containerConcurrency,omitempty"` + + // ScaleTargetRef defines the /scale-able resource that this PodAutoscaler + // is responsible for quickly right-sizing. + ScaleTargetRef corev1.ObjectReference `json:"scaleTargetRef"` + + // Reachable specifies whether or not the `ScaleTargetRef` can be reached (ie. has a route). + // Defaults to `ReachabilityUnknown` + // +optional + Reachability ReachabilityType `json:"reachability,omitempty"` + + // DeprecatedServiceName holds the name of a core Kubernetes Service resource that + // load balances over the pods referenced by the ScaleTargetRef. + DeprecatedServiceName string `json:"serviceName"` + + // The application-layer protocol. Matches `ProtocolType` inferred from the revision spec. + ProtocolType net.ProtocolType `json:"protocolType"` +} + +const ( + // PodAutoscalerConditionReady is set when the revision is starting to materialize + // runtime resources, and becomes true when those resources are ready. + PodAutoscalerConditionReady = apis.ConditionReady + // PodAutoscalerConditionActive is set when the PodAutoscaler's ScaleTargetRef is receiving traffic. + PodAutoscalerConditionActive apis.ConditionType = "Active" +) + +// PodAutoscalerStatus communicates the observed state of the PodAutoscaler (from the controller). +type PodAutoscalerStatus struct { + duckv1.Status `json:",inline"` + + // ServiceName is the K8s Service name that serves the revision, scaled by this PA. + // The service is created and owned by the ServerlessService object owned by this PA. + ServiceName string `json:"serviceName"` + + // MetricsServiceName is the K8s Service name that provides revision metrics. + // The service is managed by the PA object. + MetricsServiceName string `json:"metricsServiceName"` + + // DesiredScale shows the current desired number of replicas for the revision. + DesiredScale *int32 `json:"desiredScale,omitempty"` + + // ActualScale shows the actual number of replicas for the revision. + ActualScale *int32 `json:"actualScale,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PodAutoscalerList is a list of PodAutoscaler resources +type PodAutoscalerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []PodAutoscaler `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go new file mode 100644 index 00000000000..31b2bb957a5 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go @@ -0,0 +1,42 @@ +/* +Copyright 2018 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "context" + + "k8s.io/apimachinery/pkg/api/equality" + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" +) + +func (pa *PodAutoscaler) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidateObjectMetadata(pa.GetObjectMeta()).ViaField("metadata") + return errs.Also(pa.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) +} + +// Validate validates PodAutoscaler Spec. +func (pa *PodAutoscalerSpec) Validate(ctx context.Context) *apis.FieldError { + if equality.Semantic.DeepEqual(pa, &PodAutoscalerSpec{}) { + return apis.ErrMissingField(apis.CurrentField) + } + return serving.ValidateNamespacedObjectReference(&pa.ScaleTargetRef).ViaField("scaleTargetRef").Also(serving.ValidateContainerConcurrency(&pa.ContainerConcurrency).ViaField("containerConcurrency")).Also(validateSKSFields(ctx, pa)) +} + +func validateSKSFields(ctx context.Context, rs *PodAutoscalerSpec) (errs *apis.FieldError) { + return errs.Also(rs.ProtocolType.Validate(ctx)).ViaField("protocolType") +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/podscalable_types.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/podscalable_types.go new file mode 100644 index 00000000000..54d67929c95 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/podscalable_types.go @@ -0,0 +1,112 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PodScalable is a duck type that the resources referenced by the +// PodAutoscaler's ScaleTargetRef must implement. They must also +// implement the `/scale` sub-resource for use with `/scale` based +// implementations (e.g. HPA), but this further constrains the shape +// the referenced resources may take. +type PodScalable struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec PodScalableSpec `json:"spec"` + Status PodScalableStatus `json:"status"` +} + +// PodScalableSpec is the specification for the desired state of a +// PodScalable (or at least our shared portion). +type PodScalableSpec struct { + Replicas *int32 `json:"replicas,omitempty"` + Selector *metav1.LabelSelector `json:"selector"` + Template corev1.PodTemplateSpec `json:"template"` +} + +// PodScalableStatus is the observed state of a PodScalable (or at +// least our shared portion). +type PodScalableStatus struct { + Replicas int32 `json:"replicas,omitempty"` +} + +var _ duck.Populatable = (*PodScalable)(nil) +var _ duck.Implementable = (*PodScalable)(nil) +var _ apis.Listable = (*PodScalable)(nil) + +// GetFullType implements duck.Implementable +func (*PodScalable) GetFullType() duck.Populatable { + return &PodScalable{} +} + +// Populate implements duck.Populatable +func (t *PodScalable) Populate() { + twelve := int32(12) + t.Spec = PodScalableSpec{ + Replicas: &twelve, + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "foo": "bar", + }, + MatchExpressions: []metav1.LabelSelectorRequirement{{ + Key: "foo", + Operator: "In", + Values: []string{"baz", "blah"}, + }}, + }, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + "foo": "bar", + }, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Name: "container-name", + Image: "container-image:latest", + }}, + }, + }, + } + t.Status = PodScalableStatus{ + Replicas: 42, + } +} + +// GetListType implements apis.Listable +func (*PodScalable) GetListType() runtime.Object { + return &PodScalableList{} +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PodScalableList is a list of PodScalable resources +type PodScalableList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []PodScalable `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/register.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/register.go new file mode 100644 index 00000000000..1a90e867e22 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/register.go @@ -0,0 +1,55 @@ +/* +Copyright 2018 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "knative.dev/serving/pkg/apis/autoscaling" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: autoscaling.InternalGroupName, Version: "v1alpha1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &PodAutoscaler{}, + &PodAutoscalerList{}, + &Metric{}, + &MetricList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..435a5a8642e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,329 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metric) DeepCopyInto(out *Metric) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metric. +func (in *Metric) DeepCopy() *Metric { + if in == nil { + return nil + } + out := new(Metric) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metric) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricList) DeepCopyInto(out *MetricList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metric, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricList. +func (in *MetricList) DeepCopy() *MetricList { + if in == nil { + return nil + } + out := new(MetricList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MetricList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricSpec) DeepCopyInto(out *MetricSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricSpec. +func (in *MetricSpec) DeepCopy() *MetricSpec { + if in == nil { + return nil + } + out := new(MetricSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricStatus) DeepCopyInto(out *MetricStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricStatus. +func (in *MetricStatus) DeepCopy() *MetricStatus { + if in == nil { + return nil + } + out := new(MetricStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodAutoscaler) DeepCopyInto(out *PodAutoscaler) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodAutoscaler. +func (in *PodAutoscaler) DeepCopy() *PodAutoscaler { + if in == nil { + return nil + } + out := new(PodAutoscaler) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodAutoscaler) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodAutoscalerList) DeepCopyInto(out *PodAutoscalerList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PodAutoscaler, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodAutoscalerList. +func (in *PodAutoscalerList) DeepCopy() *PodAutoscalerList { + if in == nil { + return nil + } + out := new(PodAutoscalerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodAutoscalerList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodAutoscalerSpec) DeepCopyInto(out *PodAutoscalerSpec) { + *out = *in + out.ScaleTargetRef = in.ScaleTargetRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodAutoscalerSpec. +func (in *PodAutoscalerSpec) DeepCopy() *PodAutoscalerSpec { + if in == nil { + return nil + } + out := new(PodAutoscalerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodAutoscalerStatus) DeepCopyInto(out *PodAutoscalerStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + if in.DesiredScale != nil { + in, out := &in.DesiredScale, &out.DesiredScale + *out = new(int32) + **out = **in + } + if in.ActualScale != nil { + in, out := &in.ActualScale, &out.ActualScale + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodAutoscalerStatus. +func (in *PodAutoscalerStatus) DeepCopy() *PodAutoscalerStatus { + if in == nil { + return nil + } + out := new(PodAutoscalerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodScalable) DeepCopyInto(out *PodScalable) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodScalable. +func (in *PodScalable) DeepCopy() *PodScalable { + if in == nil { + return nil + } + out := new(PodScalable) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodScalable) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodScalableList) DeepCopyInto(out *PodScalableList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PodScalable, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodScalableList. +func (in *PodScalableList) DeepCopy() *PodScalableList { + if in == nil { + return nil + } + out := new(PodScalableList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodScalableList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodScalableSpec) DeepCopyInto(out *PodScalableSpec) { + *out = *in + if in.Replicas != nil { + in, out := &in.Replicas, &out.Replicas + *out = new(int32) + **out = **in + } + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + in.Template.DeepCopyInto(&out.Template) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodScalableSpec. +func (in *PodScalableSpec) DeepCopy() *PodScalableSpec { + if in == nil { + return nil + } + out := new(PodScalableSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodScalableStatus) DeepCopyInto(out *PodScalableStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodScalableStatus. +func (in *PodScalableStatus) DeepCopy() *PodScalableStatus { + if in == nil { + return nil + } + out := new(PodScalableStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/serving/pkg/apis/config/defaults.go b/vendor/knative.dev/serving/pkg/apis/config/defaults.go index 5799eb62e41..df27f9aed06 100644 --- a/vendor/knative.dev/serving/pkg/apis/config/defaults.go +++ b/vendor/knative.dev/serving/pkg/apis/config/defaults.go @@ -44,6 +44,13 @@ const ( // DefaultUserContainerName is the default name we give to the container // specified by the user, if `name:` is omitted. DefaultUserContainerName = "user-container" + + // DefaultContainerConcurrency is the default container concurrency. It will be set if ContainerConcurrency is not specified. + DefaultContainerConcurrency int64 = 0 + + // DefaultMaxRevisionContainerConcurrency is the maximum configurable + // container concurrency. + DefaultMaxRevisionContainerConcurrency int64 = 1000 ) // NewDefaultsConfigFromMap creates a Defaults from the supplied Map @@ -64,6 +71,10 @@ func NewDefaultsConfigFromMap(data map[string]string) (*Defaults, error) { key: "max-revision-timeout-seconds", field: &nc.MaxRevisionTimeoutSeconds, defaultValue: DefaultMaxRevisionTimeoutSeconds, + }, { + key: "container-concurrency", + field: &nc.ContainerConcurrency, + defaultValue: DefaultContainerConcurrency, }} { if raw, ok := data[i64.key]; !ok { *i64.field = i64.defaultValue @@ -78,6 +89,10 @@ func NewDefaultsConfigFromMap(data map[string]string) (*Defaults, error) { return nil, fmt.Errorf("revision-timeout-seconds (%d) cannot be greater than max-revision-timeout-seconds (%d)", nc.RevisionTimeoutSeconds, nc.MaxRevisionTimeoutSeconds) } + if nc.ContainerConcurrency < 0 || nc.ContainerConcurrency > DefaultMaxRevisionContainerConcurrency { + return nil, apis.ErrOutOfBoundsValue(nc.ContainerConcurrency, 0, DefaultMaxRevisionContainerConcurrency, "containerConcurrency") + } + // Process resource quantity fields for _, rsrc := range []struct { key string @@ -137,6 +152,8 @@ type Defaults struct { UserContainerNameTemplate string + ContainerConcurrency int64 + RevisionCPURequest *resource.Quantity RevisionCPULimit *resource.Quantity RevisionMemoryRequest *resource.Quantity diff --git a/vendor/knative.dev/serving/pkg/apis/networking/register.go b/vendor/knative.dev/serving/pkg/apis/networking/register.go index f255f88c867..11ded7d685d 100644 --- a/vendor/knative.dev/serving/pkg/apis/networking/register.go +++ b/vendor/knative.dev/serving/pkg/apis/networking/register.go @@ -73,6 +73,17 @@ const ( // value a different reconciliation logic may be used (for examples, // Cert-Manager-based Certificate will reconcile into a Cert-Manager Certificate). CertificateClassAnnotationKey = GroupName + "/certificate.class" + + // ActivatorServiceName is the name of the activator Kubernetes service. + ActivatorServiceName = "activator-service" + + // DisableWildcardCertLabelKey is the label key attached to a namespace to indicate that + // a wildcard certificate should be not created for it. + DisableWildcardCertLabelKey = GroupName + "/disableWildcardCert" + + // WildcardCertDomainLabelKey is the label key attached to a certificate to indicate the + // domain for which it was issued. + WildcardCertDomainLabelKey = "networking.knative.dev/wildcardDomain" ) // ServiceType is the enumeration type for the Kubernetes services diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_lifecycle.go index 2a734b597e0..38b77a9615e 100644 --- a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_lifecycle.go +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_lifecycle.go @@ -20,9 +20,8 @@ import ( "fmt" "k8s.io/apimachinery/pkg/runtime/schema" - "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + duckv1 "knative.dev/pkg/apis/duck/v1" ) // InitializeConditions initializes the certificate conditions. @@ -35,13 +34,13 @@ func (cs *CertificateStatus) MarkReady() { certificateCondSet.Manage(cs).MarkTrue(CertificateConditionReady) } -// MarkUnknown marks the certificate status as unknown. -func (cs *CertificateStatus) MarkUnknown(reason, message string) { +// MarkNotReady marks the certificate status as unknown. +func (cs *CertificateStatus) MarkNotReady(reason, message string) { certificateCondSet.Manage(cs).MarkUnknown(CertificateConditionReady, reason, message) } -// MarkNotReady marks the certificate as not ready. -func (cs *CertificateStatus) MarkNotReady(reason, message string) { +// MarkFailed marks the certificate as not ready. +func (cs *CertificateStatus) MarkFailed(reason, message string) { certificateCondSet.Manage(cs).MarkFalse(CertificateConditionReady, reason, message) } @@ -76,6 +75,6 @@ func (c *Certificate) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind("Certificate") } -func (cs *CertificateStatus) duck() *duckv1beta1.Status { +func (cs *CertificateStatus) duck() *duckv1.Status { return &cs.Status } diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_types.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_types.go index 9738faf0163..9bf98cce46f 100644 --- a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_types.go +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_types.go @@ -20,7 +20,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/kmeta" ) @@ -88,7 +88,7 @@ type CertificateStatus struct { // - The target secret exists // - The target secret contains a certificate that has not expired // - The target secret contains a private key valid for the certificate - duckv1beta1.Status `json:",inline"` + duckv1.Status `json:",inline"` // The expiration time of the TLS certificate stored in the secret named // by this resource in spec.secretName. diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_lifecycle.go index 22a2255c2f2..f227e75afeb 100644 --- a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_lifecycle.go +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_lifecycle.go @@ -21,7 +21,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + duckv1 "knative.dev/pkg/apis/duck/v1" ) var ingressCondSet = apis.NewLivingConditionSet( @@ -78,12 +78,17 @@ func (is *IngressStatus) MarkLoadBalancerPending() { "Waiting for VirtualService to be ready") } +// MarkIngressNotReady marks the "IngressConditionReady" condition to unknown. +func (is *IngressStatus) MarkIngressNotReady(reason, message string) { + ingressCondSet.Manage(is).MarkUnknown(IngressConditionReady, reason, message) +} + // IsReady looks at the conditions and if the Status has a condition // IngressConditionReady returns true if ConditionStatus is True func (is *IngressStatus) IsReady() bool { return ingressCondSet.Manage(is).IsHappy() } -func (is *IngressStatus) duck() *duckv1beta1.Status { +func (is *IngressStatus) duck() *duckv1.Status { return &is.Status } diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_types.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_types.go index 68cc25e1a37..8b9e8425ab0 100644 --- a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_types.go +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_types.go @@ -20,7 +20,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/kmeta" ) @@ -276,7 +276,7 @@ type HTTPRetry struct { // IngressStatus describe the current state of the Ingress. type IngressStatus struct { - duckv1beta1.Status `json:",inline"` + duckv1.Status `json:",inline"` // LoadBalancer contains the current status of the load-balancer. // This is to be superseded by the combination of `PublicLoadBalancer` and `PrivateLoadBalancer` diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_lifecycle.go index b9dcd2eea77..e8ad84fdc5f 100644 --- a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_lifecycle.go +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_lifecycle.go @@ -23,7 +23,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + duckv1 "knative.dev/pkg/apis/duck/v1" ) var serverlessServiceCondSet = apis.NewLivingConditionSet( @@ -91,7 +91,7 @@ func (sss *ServerlessServiceStatus) IsReady() bool { return serverlessServiceCondSet.Manage(sss).IsHappy() } -func (sss *ServerlessServiceStatus) duck() *duckv1beta1.Status { +func (sss *ServerlessServiceStatus) duck() *duckv1.Status { return &sss.Status } diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go index 80ae00675f8..689bf43146d 100644 --- a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go @@ -20,7 +20,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/kmeta" networking "knative.dev/serving/pkg/apis/networking" ) @@ -104,7 +104,7 @@ type ServerlessServiceSpec struct { // ServerlessServiceStatus describes the current state of the ServerlessService. type ServerlessServiceStatus struct { - duckv1beta1.Status `json:",inline"` + duckv1.Status `json:",inline"` // ServiceName holds the name of a core K8s Service resource that // load balances over the pods backing this Revision (activator or revision). diff --git a/vendor/knative.dev/serving/pkg/apis/serving/k8s_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/k8s_lifecycle.go new file mode 100644 index 00000000000..f40bfbf9fd1 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/k8s_lifecycle.go @@ -0,0 +1,78 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package serving + +import ( + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +var depCondSet = apis.NewLivingConditionSet( + DeploymentConditionProgressing, + DeploymentConditionReplicaSetReady, +) + +const ( + // DeploymentConditionReady means the underlying deployment is ready. + DeploymentConditionReady = apis.ConditionReady + // DeploymentConditionReplicaSetready inverts the underlying deployment's + // ReplicaSetFailure condition. + DeploymentConditionReplicaSetReady apis.ConditionType = "ReplicaSetReady" + // DeploymentConditionProgressing reflects the underlying deployment's + // Progressing condition. + DeploymentConditionProgressing apis.ConditionType = "Progressing" +) + +// transformDeploymentStatus transforms the kubernetes DeploymentStatus into a +// duckv1.Status that uses ConditionSets to propagate failures and expose +// a top-level happy state, per our condition conventions. +func TransformDeploymentStatus(ds *appsv1.DeploymentStatus) *duckv1.Status { + s := &duckv1.Status{} + + depCondSet.Manage(s).InitializeConditions() + // The absence of this condition means no failure has occurred. If we find it + // below, we'll ovewrwrite this. + depCondSet.Manage(s).MarkTrue(DeploymentConditionReplicaSetReady) + + for _, cond := range ds.Conditions { + // TODO(jonjohnsonjr): Should we care about appsv1.DeploymentAvailable here? + switch cond.Type { + case appsv1.DeploymentProgressing: + switch cond.Status { + case corev1.ConditionUnknown: + depCondSet.Manage(s).MarkUnknown(DeploymentConditionProgressing, cond.Reason, cond.Message) + case corev1.ConditionTrue: + depCondSet.Manage(s).MarkTrue(DeploymentConditionProgressing) + case corev1.ConditionFalse: + depCondSet.Manage(s).MarkFalse(DeploymentConditionProgressing, cond.Reason, cond.Message) + } + case appsv1.DeploymentReplicaFailure: + switch cond.Status { + case corev1.ConditionUnknown: + depCondSet.Manage(s).MarkUnknown(DeploymentConditionReplicaSetReady, cond.Reason, cond.Message) + case corev1.ConditionTrue: + depCondSet.Manage(s).MarkFalse(DeploymentConditionReplicaSetReady, cond.Reason, cond.Message) + case corev1.ConditionFalse: + depCondSet.Manage(s).MarkTrue(DeploymentConditionReplicaSetReady) + } + } + } + return s +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/k8s_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/k8s_validation.go index b55cd9e04e6..4ad54433308 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/k8s_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/k8s_validation.go @@ -97,9 +97,15 @@ func validateVolume(volume corev1.Volume) *apis.FieldError { specified := []string{} if vs.Secret != nil { specified = append(specified, "secret") + for i, item := range vs.Secret.Items { + errs = errs.Also(validateKeyToPath(item).ViaFieldIndex("items", i)) + } } if vs.ConfigMap != nil { specified = append(specified, "configMap") + for i, item := range vs.ConfigMap.Items { + errs = errs.Also(validateKeyToPath(item).ViaFieldIndex("items", i)) + } } if vs.Projected != nil { specified = append(specified, "projected") @@ -143,7 +149,7 @@ func validateConfigMapProjection(cmp *corev1.ConfigMapProjection) *apis.FieldErr errs = errs.Also(apis.ErrMissingField("name")) } for i, item := range cmp.Items { - errs = errs.Also(apis.CheckDisallowedFields(item, *KeyToPathMask(&item)).ViaIndex(i)) + errs = errs.Also(validateKeyToPath(item).ViaFieldIndex("items", i)) } return errs } @@ -156,7 +162,18 @@ func validateSecretProjection(sp *corev1.SecretProjection) *apis.FieldError { errs = errs.Also(apis.ErrMissingField("name")) } for i, item := range sp.Items { - errs = errs.Also(apis.CheckDisallowedFields(item, *KeyToPathMask(&item)).ViaIndex(i)) + errs = errs.Also(validateKeyToPath(item).ViaFieldIndex("items", i)) + } + return errs +} + +func validateKeyToPath(k2p corev1.KeyToPath) *apis.FieldError { + errs := apis.CheckDisallowedFields(k2p, *KeyToPathMask(&k2p)) + if k2p.Key == "" { + errs = errs.Also(apis.ErrMissingField("key")) + } + if k2p.Path == "" { + errs = errs.Also(apis.ErrMissingField("path")) } return errs } @@ -439,11 +456,17 @@ func validateReadinessProbe(p *corev1.Probe) *apis.FieldError { // PeriodSeconds == 0 indicates Knative's special probe with aggressive retries if p.PeriodSeconds == 0 { if p.FailureThreshold != 0 { - errs = errs.Also(apis.ErrDisallowedFields("failureThreshold")) + errs = errs.Also(&apis.FieldError{ + Message: "failureThreshold is disallowed when periodSeconds is zero", + Paths: []string{"failureThreshold"}, + }) } if p.TimeoutSeconds != 0 { - errs = errs.Also(apis.ErrDisallowedFields("timeoutSeconds")) + errs = errs.Also(&apis.FieldError{ + Message: "timeoutSeconds is disallowed when periodSeconds is zero", + Paths: []string{"timeoutSeconds"}, + }) } } else { if p.TimeoutSeconds < 1 { diff --git a/vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go index c569babc2ca..96c8b453eab 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go @@ -19,18 +19,40 @@ package serving import ( "context" "strconv" + "strings" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" "knative.dev/serving/pkg/apis/autoscaling" "knative.dev/serving/pkg/apis/config" + routeconfig "knative.dev/serving/pkg/reconciler/route/config" +) + +var ( + allowedAnnotations = map[string]struct{}{ + UpdaterAnnotation: {}, + CreatorAnnotation: {}, + RevisionLastPinnedAnnotationKey: {}, + GroupNamePrefix + "forceUpgrade": {}, + } ) // ValidateObjectMetadata validates that `metadata` stanza of the // resources is correct. func ValidateObjectMetadata(meta metav1.Object) *apis.FieldError { return apis.ValidateObjectMetadata(meta). - Also(autoscaling.ValidateAnnotations(meta.GetAnnotations()).ViaField("annotations")) + Also(autoscaling.ValidateAnnotations(meta.GetAnnotations()). + Also(validateKnativeAnnotations(meta.GetAnnotations())). + ViaField("annotations")) +} + +func validateKnativeAnnotations(annotations map[string]string) (errs *apis.FieldError) { + for key := range annotations { + if _, ok := allowedAnnotations[key]; !ok && strings.HasPrefix(key, GroupNamePrefix) { + errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField)) + } + } + return } // ValidateQueueSidecarAnnotation validates QueueSideCarResourcePercentageAnnotation @@ -64,3 +86,23 @@ func ValidateTimeoutSeconds(ctx context.Context, timeoutSeconds int64) *apis.Fie } return nil } + +// ValidateContainerConcurrency function validates the ContainerConcurrency field +// TODO(#5007): Move this to autoscaling. +func ValidateContainerConcurrency(containerConcurrency *int64) *apis.FieldError { + if containerConcurrency != nil { + if *containerConcurrency < 0 || *containerConcurrency > config.DefaultMaxRevisionContainerConcurrency { + return apis.ErrOutOfBoundsValue( + *containerConcurrency, 0, config.DefaultMaxRevisionContainerConcurrency, apis.CurrentField) + } + } + return nil +} + +// ValidateClusterVisibilityLabel function validates the visibility label on a Route +func ValidateClusterVisibilityLabel(label string) (errs *apis.FieldError) { + if label != routeconfig.VisibilityClusterLocal { + errs = apis.ErrInvalidValue(label, routeconfig.VisibilityLabelKey) + } + return +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/register.go b/vendor/knative.dev/serving/pkg/apis/serving/register.go index 35c8677e870..ba8264063c2 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/register.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/register.go @@ -20,6 +20,9 @@ const ( // GroupName is the group name for knative labels and annotations GroupName = "serving.knative.dev" + // GroupNamePrefix is the prefix for label key and annotation key + GroupNamePrefix = GroupName + "/" + // ConfigurationLabelKey is the label key attached to a Revision indicating by // which Configuration it is created. ConfigurationLabelKey = GroupName + "/configuration" diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_conversion.go new file mode 100644 index 00000000000..05d012ce555 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_conversion.go @@ -0,0 +1,34 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Configuration) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Configuration) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", source) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_defaults.go new file mode 100644 index 00000000000..db1170d3fb7 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_defaults.go @@ -0,0 +1,34 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "context" + + "knative.dev/pkg/apis" +) + +// SetDefaults implements apis.Defaultable +func (c *Configuration) SetDefaults(ctx context.Context) { + ctx = apis.WithinParent(ctx, c.ObjectMeta) + c.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +// SetDefaults implements apis.Defaultable +func (cs *ConfigurationSpec) SetDefaults(ctx context.Context) { + cs.Template.SetDefaults(ctx) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_lifecycle.go new file mode 100644 index 00000000000..93057dacf56 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_lifecycle.go @@ -0,0 +1,35 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" +) + +var configurationCondSet = apis.NewLivingConditionSet() + +// GetGroupVersionKind returns the GroupVersionKind. +func (r *Configuration) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Configuration") +} + +// IsReady returns if the configuration is ready to serve the requested configuration. +func (cs *ConfigurationStatus) IsReady() bool { + return configurationCondSet.Manage(cs).IsHappy() +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_types.go new file mode 100644 index 00000000000..7c2c4a2bf23 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_types.go @@ -0,0 +1,102 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Configuration represents the "floating HEAD" of a linear history of Revisions. +// Users create new Revisions by updating the Configuration's spec. +// The "latest created" revision's name is available under status, as is the +// "latest ready" revision's name. +// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#configuration +type Configuration struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec ConfigurationSpec `json:"spec,omitempty"` + + // +optional + Status ConfigurationStatus `json:"status,omitempty"` +} + +// Verify that Configuration adheres to the appropriate interfaces. +var ( + // Check that Configuration may be validated and defaulted. + _ apis.Validatable = (*Configuration)(nil) + _ apis.Defaultable = (*Configuration)(nil) + + // Check that Configuration can be converted to higher versions. + _ apis.Convertible = (*Configuration)(nil) + + // Check that we can create OwnerReferences to a Configuration. + _ kmeta.OwnerRefable = (*Configuration)(nil) +) + +// ConfigurationSpec holds the desired state of the Configuration (from the client). +type ConfigurationSpec struct { + // Template holds the latest specification for the Revision to be stamped out. + // +optional + Template RevisionTemplateSpec `json:"template"` +} + +const ( + // ConfigurationConditionReady is set when the configuration's latest + // underlying revision has reported readiness. + ConfigurationConditionReady = apis.ConditionReady +) + +// ConfigurationStatusFields holds the fields of Configuration's status that +// are not generally shared. This is defined separately and inlined so that +// other types can readily consume these fields via duck typing. +type ConfigurationStatusFields struct { + // LatestReadyRevisionName holds the name of the latest Revision stamped out + // from this Configuration that has had its "Ready" condition become "True". + // +optional + LatestReadyRevisionName string `json:"latestReadyRevisionName,omitempty"` + + // LatestCreatedRevisionName is the last revision that was created from this + // Configuration. It might not be ready yet, for that use LatestReadyRevisionName. + // +optional + LatestCreatedRevisionName string `json:"latestCreatedRevisionName,omitempty"` +} + +// ConfigurationStatus communicates the observed state of the Configuration (from the controller). +type ConfigurationStatus struct { + duckv1.Status `json:",inline"` + + ConfigurationStatusFields `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ConfigurationList is a list of Configuration resources +type ConfigurationList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Configuration `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_validation.go new file mode 100644 index 00000000000..8e3f56d3889 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_validation.go @@ -0,0 +1,93 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "context" + "strings" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" + "knative.dev/serving/pkg/reconciler/route/config" +) + +// Validate makes sure that Configuration is properly configured. +func (c *Configuration) Validate(ctx context.Context) (errs *apis.FieldError) { + // If we are in a status sub resource update, the metadata and spec cannot change. + // So, to avoid rejecting controller status updates due to validations that may + // have changed (i.e. due to config-defaults changes), we elide the metadata and + // spec validation. + if !apis.IsInStatusUpdate(ctx) { + errs = errs.Also(serving.ValidateObjectMetadata(c.GetObjectMeta()).Also( + c.validateLabels().ViaField("labels")).ViaField("metadata")) + ctx = apis.WithinParent(ctx, c.ObjectMeta) + errs = errs.Also(c.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + errs = errs.Also(c.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Configuration) + + err := c.Spec.Template.VerifyNameChange(ctx, original.Spec.Template) + errs = errs.Also(err.ViaField("spec.template")) + } + + return errs +} + +// Validate implements apis.Validatable +func (cs *ConfigurationSpec) Validate(ctx context.Context) *apis.FieldError { + return cs.Template.Validate(ctx).ViaField("template") +} + +// Validate implements apis.Validatable +func (cs *ConfigurationStatus) Validate(ctx context.Context) *apis.FieldError { + return cs.ConfigurationStatusFields.Validate(ctx) +} + +// Validate implements apis.Validatable +func (csf *ConfigurationStatusFields) Validate(ctx context.Context) *apis.FieldError { + return nil +} + +// validateLabels function validates configuration labels +func (c *Configuration) validateLabels() (errs *apis.FieldError) { + for key, val := range c.GetLabels() { + switch { + case key == config.VisibilityLabelKey: + errs = errs.Also(validateClusterVisibilityLabel(val)) + case key == serving.RouteLabelKey: + case key == serving.ServiceLabelKey: + errs = errs.Also(verifyLabelOwnerRef(val, serving.ServiceLabelKey, "Service", c.GetOwnerReferences())) + case strings.HasPrefix(key, serving.GroupNamePrefix): + errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField)) + } + } + return +} + +// verifyLabelOwnerRef function verifies the owner references of resource with label key has val value. +func verifyLabelOwnerRef(val, label, resource string, ownerRefs []metav1.OwnerReference) (errs *apis.FieldError) { + for _, ref := range ownerRefs { + if ref.Kind == resource && val == ref.Name { + return + } + } + return errs.Also(apis.ErrMissingField(label)) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/contexts.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/contexts.go similarity index 96% rename from vendor/knative.dev/serving/pkg/apis/serving/v1beta1/contexts.go rename to vendor/knative.dev/serving/pkg/apis/serving/v1/contexts.go index 9cc23937ad5..2b1076cf333 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/contexts.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/contexts.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1 import "context" @@ -40,13 +40,13 @@ func HasDefaultConfigurationName(ctx context.Context) bool { type lemonadeKey struct{} // WithUpgradeViaDefaulting notes on the context that we want defaulting to rewrite -// from v1alpha1 to v1beta1. +// from v1alpha1 to v1. func WithUpgradeViaDefaulting(ctx context.Context) context.Context { return context.WithValue(ctx, lemonadeKey{}, struct{}{}) } // IsUpgradeViaDefaulting checks whether we should be "defaulting" from v1alpha1 to -// the v1beta1 subset. +// the v1 subset. func IsUpgradeViaDefaulting(ctx context.Context) bool { return ctx.Value(lemonadeKey{}) != nil } diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/doc.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/doc.go new file mode 100644 index 00000000000..fab9a24e65b --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/doc.go @@ -0,0 +1,21 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package v1 contains the Serving v1 API types. + +// +k8s:deepcopy-gen=package +// +groupName=serving.knative.dev +package v1 diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/register.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/register.go new file mode 100644 index 00000000000..479507d511b --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/register.go @@ -0,0 +1,61 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "knative.dev/serving/pkg/apis/serving" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects. +var SchemeGroupVersion = schema.GroupVersion{Group: serving.GroupName, Version: "v1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind. +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource. +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder registers the addKnownTypes function. + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme applies all the stored functions to the scheme. + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &Revision{}, + &RevisionList{}, + &Configuration{}, + &ConfigurationList{}, + &Route{}, + &RouteList{}, + &Service{}, + &ServiceList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_conversion.go new file mode 100644 index 00000000000..89ed8e5a040 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_conversion.go @@ -0,0 +1,34 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Revision) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Revision) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", source) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_defaults.go new file mode 100644 index 00000000000..01df5b62620 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_defaults.go @@ -0,0 +1,102 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "context" + + corev1 "k8s.io/api/core/v1" + "knative.dev/pkg/apis" + "knative.dev/pkg/ptr" + "knative.dev/serving/pkg/apis/config" +) + +// SetDefaults implements apis.Defaultable +func (r *Revision) SetDefaults(ctx context.Context) { + r.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +// SetDefaults implements apis.Defaultable +func (rts *RevisionTemplateSpec) SetDefaults(ctx context.Context) { + rts.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +// SetDefaults implements apis.Defaultable +func (rs *RevisionSpec) SetDefaults(ctx context.Context) { + cfg := config.FromContextOrDefaults(ctx) + + // Default TimeoutSeconds based on our configmap + if rs.TimeoutSeconds == nil || *rs.TimeoutSeconds == 0 { + rs.TimeoutSeconds = ptr.Int64(cfg.Defaults.RevisionTimeoutSeconds) + } + + // Default ContainerConcurrency based on our configmap + if rs.ContainerConcurrency == nil { + rs.ContainerConcurrency = ptr.Int64(cfg.Defaults.ContainerConcurrency) + } + + for idx := range rs.PodSpec.Containers { + if rs.PodSpec.Containers[idx].Name == "" { + rs.PodSpec.Containers[idx].Name = cfg.Defaults.UserContainerName(ctx) + } + + if rs.PodSpec.Containers[idx].Resources.Requests == nil { + rs.PodSpec.Containers[idx].Resources.Requests = corev1.ResourceList{} + } + if _, ok := rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceCPU]; !ok { + if rsrc := cfg.Defaults.RevisionCPURequest; rsrc != nil { + rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceCPU] = *rsrc + } + } + if _, ok := rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceMemory]; !ok { + if rsrc := cfg.Defaults.RevisionMemoryRequest; rsrc != nil { + rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceMemory] = *rsrc + } + } + + if rs.PodSpec.Containers[idx].Resources.Limits == nil { + rs.PodSpec.Containers[idx].Resources.Limits = corev1.ResourceList{} + } + if _, ok := rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceCPU]; !ok { + if rsrc := cfg.Defaults.RevisionCPULimit; rsrc != nil { + rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceCPU] = *rsrc + } + } + if _, ok := rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceMemory]; !ok { + if rsrc := cfg.Defaults.RevisionMemoryLimit; rsrc != nil { + rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceMemory] = *rsrc + } + } + if rs.PodSpec.Containers[idx].ReadinessProbe == nil { + rs.PodSpec.Containers[idx].ReadinessProbe = &corev1.Probe{} + } + if rs.PodSpec.Containers[idx].ReadinessProbe.TCPSocket == nil && + rs.PodSpec.Containers[idx].ReadinessProbe.HTTPGet == nil && + rs.PodSpec.Containers[idx].ReadinessProbe.Exec == nil { + rs.PodSpec.Containers[idx].ReadinessProbe.TCPSocket = &corev1.TCPSocketAction{} + } + + if rs.PodSpec.Containers[idx].ReadinessProbe.SuccessThreshold == 0 { + rs.PodSpec.Containers[idx].ReadinessProbe.SuccessThreshold = 1 + } + + vms := rs.PodSpec.Containers[idx].VolumeMounts + for i := range vms { + vms[i].ReadOnly = true + } + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_lifecycle.go new file mode 100644 index 00000000000..a178edf3538 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_lifecycle.go @@ -0,0 +1,55 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/config" +) + +const ( + // DefaultUserPort is the system default port value exposed on the user-container. + DefaultUserPort = 8080 +) + +var revisionCondSet = apis.NewLivingConditionSet() + +// GetGroupVersionKind returns the GroupVersionKind. +func (r *Revision) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Revision") +} + +// IsReady returns if the revision is ready to serve the requested configuration. +func (rs *RevisionStatus) IsReady() bool { + return revisionCondSet.Manage(rs).IsHappy() +} + +// GetContainerConcurrency returns the container concurrency. If +// container concurrency is not set, the default value will be returned. +// We use the original default (0) here for backwards compatibility. +// Previous versions of Knative equated unspecified and zero, so to avoid +// changing the value used by Revisions with unspecified values when a different +// default is configured, we use the original default instead of the configured +// default to remain safe across upgrades. +func (rs *RevisionSpec) GetContainerConcurrency() int64 { + if rs.ContainerConcurrency == nil { + return config.DefaultContainerConcurrency + } + return *rs.ContainerConcurrency +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_types.go new file mode 100644 index 00000000000..8eb83f7b2a7 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_types.go @@ -0,0 +1,125 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Revision is an immutable snapshot of code and configuration. A revision +// references a container image. Revisions are created by updates to a +// Configuration. +// +// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#revision +type Revision struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec RevisionSpec `json:"spec,omitempty"` + + // +optional + Status RevisionStatus `json:"status,omitempty"` +} + +// Verify that Revision adheres to the appropriate interfaces. +var ( + // Check that Revision can be validated, can be defaulted, and has immutable fields. + _ apis.Validatable = (*Revision)(nil) + _ apis.Defaultable = (*Revision)(nil) + + // Check that Revision can be converted to higher versions. + _ apis.Convertible = (*Revision)(nil) + + // Check that we can create OwnerReferences to a Revision. + _ kmeta.OwnerRefable = (*Revision)(nil) +) + +// RevisionTemplateSpec describes the data a revision should have when created from a template. +// Based on: https://github.com/kubernetes/api/blob/e771f807/core/v1/types.go#L3179-L3190 +type RevisionTemplateSpec struct { + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec RevisionSpec `json:"spec,omitempty"` +} + +// RevisionSpec holds the desired state of the Revision (from the client). +type RevisionSpec struct { + corev1.PodSpec `json:",inline"` + + // ContainerConcurrency specifies the maximum allowed in-flight (concurrent) + // requests per container of the Revision. Defaults to `0` which means + // concurrency to the application is not limited, and the system decides the + // target concurrency for the autoscaler. + // +optional + ContainerConcurrency *int64 `json:"containerConcurrency,omitempty"` + + // TimeoutSeconds holds the max duration the instance is allowed for + // responding to a request. If unspecified, a system default will + // be provided. + // +optional + TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"` +} + +const ( + // RevisionConditionReady is set when the revision is starting to materialize + // runtime resources, and becomes true when those resources are ready. + RevisionConditionReady = apis.ConditionReady +) + +// RevisionStatus communicates the observed state of the Revision (from the controller). +type RevisionStatus struct { + duckv1.Status `json:",inline"` + + // ServiceName holds the name of a core Kubernetes Service resource that + // load balances over the pods backing this Revision. + // +optional + ServiceName string `json:"serviceName,omitempty"` + + // LogURL specifies the generated logging url for this particular revision + // based on the revision url template specified in the controller's config. + // +optional + LogURL string `json:"logUrl,omitempty"` + + // ImageDigest holds the resolved digest for the image specified + // within .Spec.Container.Image. The digest is resolved during the creation + // of Revision. This field holds the digest value regardless of whether + // a tag or digest was originally specified in the Container object. It + // may be empty if the image comes from a registry listed to skip resolution. + // +optional + ImageDigest string `json:"imageDigest,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// RevisionList is a list of Revision resources +type RevisionList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Revision `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_validation.go new file mode 100644 index 00000000000..4662c595a79 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_validation.go @@ -0,0 +1,144 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "context" + "fmt" + "strings" + + "knative.dev/pkg/apis" + "knative.dev/pkg/kmp" + "knative.dev/serving/pkg/apis/autoscaling" + "knative.dev/serving/pkg/apis/serving" +) + +// Validate ensures Revision is properly configured. +func (r *Revision) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidateObjectMetadata(r.GetObjectMeta()).Also( + r.ValidateLabels().ViaField("labels")).ViaField("metadata") + errs = errs.Also(r.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Revision) + if diff, err := kmp.ShortDiff(original.Spec, r.Spec); err != nil { + return &apis.FieldError{ + Message: "Failed to diff Revision", + Paths: []string{"spec"}, + Details: err.Error(), + } + } else if diff != "" { + return &apis.FieldError{ + Message: "Immutable fields changed (-old +new)", + Paths: []string{"spec"}, + Details: diff, + } + } + } else { + errs = errs.Also(r.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + return errs +} + +// Validate implements apis.Validatable +func (rts *RevisionTemplateSpec) Validate(ctx context.Context) *apis.FieldError { + errs := rts.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec") + errs = errs.Also(autoscaling.ValidateAnnotations(rts.GetAnnotations()).ViaField("metadata.annotations")) + + // If the RevisionTemplateSpec has a name specified, then check that + // it follows the requirements on the name. + if rts.Name != "" { + var prefix string + if om := apis.ParentMeta(ctx); om.Name == "" { + prefix = om.GenerateName + } else { + prefix = om.Name + "-" + } + + if !strings.HasPrefix(rts.Name, prefix) { + errs = errs.Also(apis.ErrInvalidValue( + fmt.Sprintf("%q must have prefix %q", rts.Name, prefix), + "metadata.name")) + } + } + + errs = errs.Also(serving.ValidateQueueSidecarAnnotation(rts.Annotations).ViaField("metadata.annotations")) + return errs +} + +// VerifyNameChange checks that if a user brought their own name previously that it +// changes at the appropriate times. +func (current *RevisionTemplateSpec) VerifyNameChange(ctx context.Context, og RevisionTemplateSpec) *apis.FieldError { + if current.Name == "" { + // We only check that Name changes when the RevisionTemplate changes. + return nil + } + if current.Name != og.Name { + // The name changed, so we're good. + return nil + } + + if diff, err := kmp.ShortDiff(&og, current); err != nil { + return &apis.FieldError{ + Message: "Failed to diff RevisionTemplate", + Paths: []string{apis.CurrentField}, + Details: err.Error(), + } + } else if diff != "" { + return &apis.FieldError{ + Message: "Saw the following changes without a name change (-old +new)", + Paths: []string{apis.CurrentField}, + Details: diff, + } + } + return nil +} + +// Validate implements apis.Validatable +func (rs *RevisionSpec) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidatePodSpec(rs.PodSpec) + + if rs.TimeoutSeconds != nil { + errs = errs.Also(serving.ValidateTimeoutSeconds(ctx, *rs.TimeoutSeconds)) + } + + if rs.ContainerConcurrency != nil { + errs = errs.Also(serving.ValidateContainerConcurrency(rs.ContainerConcurrency).ViaField("containerConcurrency")) + } + + return errs +} + +// Validate implements apis.Validatable +func (rs *RevisionStatus) Validate(ctx context.Context) *apis.FieldError { + return nil +} + +// ValidateLabels function validates service labels +func (r *Revision) ValidateLabels() (errs *apis.FieldError) { + for key, val := range r.GetLabels() { + switch { + case key == serving.RouteLabelKey || key == serving.ServiceLabelKey || key == serving.ConfigurationGenerationLabelKey: + case key == serving.ConfigurationLabelKey: + errs = errs.Also(verifyLabelOwnerRef(val, serving.ConfigurationLabelKey, "Configuration", r.GetOwnerReferences())) + case strings.HasPrefix(key, serving.GroupNamePrefix): + errs = errs.Also(apis.ErrInvalidKeyName(key, "")) + } + } + return +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/route_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_conversion.go new file mode 100644 index 00000000000..7ef3cb1ae51 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_conversion.go @@ -0,0 +1,34 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Route) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Route) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", source) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/route_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_defaults.go new file mode 100644 index 00000000000..327281fa6e0 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_defaults.go @@ -0,0 +1,50 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "context" + + "knative.dev/pkg/apis" + "knative.dev/pkg/ptr" +) + +// SetDefaults implements apis.Defaultable +func (r *Route) SetDefaults(ctx context.Context) { + r.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +// SetDefaults implements apis.Defaultable +func (rs *RouteSpec) SetDefaults(ctx context.Context) { + if len(rs.Traffic) == 0 && HasDefaultConfigurationName(ctx) { + rs.Traffic = []TrafficTarget{{ + Percent: ptr.Int64(100), + LatestRevision: ptr.Bool(true), + }} + } + + for idx := range rs.Traffic { + rs.Traffic[idx].SetDefaults(ctx) + } +} + +// SetDefaults implements apis.Defaultable +func (tt *TrafficTarget) SetDefaults(ctx context.Context) { + if tt.LatestRevision == nil { + tt.LatestRevision = ptr.Bool(tt.RevisionName == "") + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/route_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_lifecycle.go new file mode 100644 index 00000000000..7b4094b12fa --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_lifecycle.go @@ -0,0 +1,35 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" +) + +var routeCondSet = apis.NewLivingConditionSet() + +// GetGroupVersionKind returns the GroupVersionKind. +func (r *Route) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Route") +} + +// IsReady returns if the route is ready to serve the requested configuration. +func (rs *RouteStatus) IsReady() bool { + return routeCondSet.Manage(rs).IsHappy() +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/route_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_types.go new file mode 100644 index 00000000000..0d470ea5b19 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_types.go @@ -0,0 +1,159 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Route is responsible for configuring ingress over a collection of Revisions. +// Some of the Revisions a Route distributes traffic over may be specified by +// referencing the Configuration responsible for creating them; in these cases +// the Route is additionally responsible for monitoring the Configuration for +// "latest ready revision" changes, and smoothly rolling out latest revisions. +// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#route +type Route struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the Route (from the client). + // +optional + Spec RouteSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the Route (from the controller). + // +optional + Status RouteStatus `json:"status,omitempty"` +} + +// Verify that Route adheres to the appropriate interfaces. +var ( + // Check that Route may be validated and defaulted. + _ apis.Validatable = (*Route)(nil) + _ apis.Defaultable = (*Route)(nil) + + // Check that Route can be converted to higher versions. + _ apis.Convertible = (*Route)(nil) + + // Check that we can create OwnerReferences to a Route. + _ kmeta.OwnerRefable = (*Route)(nil) +) + +// TrafficTarget holds a single entry of the routing table for a Route. +type TrafficTarget struct { + // Tag is optionally used to expose a dedicated url for referencing + // this target exclusively. + // +optional + Tag string `json:"tag,omitempty"` + + // RevisionName of a specific revision to which to send this portion of + // traffic. This is mutually exclusive with ConfigurationName. + // +optional + RevisionName string `json:"revisionName,omitempty"` + + // ConfigurationName of a configuration to whose latest revision we will send + // this portion of traffic. When the "status.latestReadyRevisionName" of the + // referenced configuration changes, we will automatically migrate traffic + // from the prior "latest ready" revision to the new one. This field is never + // set in Route's status, only its spec. This is mutually exclusive with + // RevisionName. + // +optional + ConfigurationName string `json:"configurationName,omitempty"` + + // LatestRevision may be optionally provided to indicate that the latest + // ready Revision of the Configuration should be used for this traffic + // target. When provided LatestRevision must be true if RevisionName is + // empty; it must be false when RevisionName is non-empty. + // +optional + LatestRevision *bool `json:"latestRevision,omitempty"` + + // Percent indicates that percentage based routing should be used and + // the value indicates the percent of traffic that is be routed to this + // Revision or Configuration. `0` (zero) mean no traffic, `100` means all + // traffic. + // When percentage based routing is being used the follow rules apply: + // - the sum of all percent values must equal 100 + // - when not specified, the implied value for `percent` is zero for + // that particular Revision or Configuration + // +optional + Percent *int64 `json:"percent,omitempty"` + + // URL displays the URL for accessing named traffic targets. URL is displayed in + // status, and is disallowed on spec. URL must contain a scheme (e.g. http://) and + // a hostname, but may not contain anything else (e.g. basic auth, url path, etc.) + // +optional + URL *apis.URL `json:"url,omitempty"` +} + +// RouteSpec holds the desired state of the Route (from the client). +type RouteSpec struct { + // Traffic specifies how to distribute traffic over a collection of + // revisions and configurations. + // +optional + Traffic []TrafficTarget `json:"traffic,omitempty"` +} + +const ( + // RouteConditionReady is set when the service is configured + // and has available backends ready to receive traffic. + RouteConditionReady = apis.ConditionReady +) + +// RouteStatusFields holds the fields of Route's status that +// are not generally shared. This is defined separately and inlined so that +// other types can readily consume these fields via duck typing. +type RouteStatusFields struct { + // URL holds the url that will distribute traffic over the provided traffic targets. + // It generally has the form http[s]://{route-name}.{route-namespace}.{cluster-level-suffix} + // +optional + URL *apis.URL `json:"url,omitempty"` + + // Address holds the information needed for a Route to be the target of an event. + // +optional + Address *duckv1.Addressable `json:"address,omitempty"` + + // Traffic holds the configured traffic distribution. + // These entries will always contain RevisionName references. + // When ConfigurationName appears in the spec, this will hold the + // LatestReadyRevisionName that we last observed. + // +optional + Traffic []TrafficTarget `json:"traffic,omitempty"` +} + +// RouteStatus communicates the observed state of the Route (from the controller). +type RouteStatus struct { + duckv1.Status `json:",inline"` + + RouteStatusFields `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// RouteList is a list of Route resources +type RouteList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Route `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/route_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_validation.go new file mode 100644 index 00000000000..e79c740cd1f --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_validation.go @@ -0,0 +1,211 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "context" + "fmt" + "strings" + + "k8s.io/apimachinery/pkg/util/validation" + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" + "knative.dev/serving/pkg/reconciler/route/config" +) + +// Validate makes sure that Route is properly configured. +func (r *Route) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidateObjectMetadata(r.GetObjectMeta()).Also( + r.validateLabels().ViaField("labels")).ViaField("metadata") + errs = errs.Also(r.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + errs = errs.Also(r.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + return errs +} + +func validateTrafficList(ctx context.Context, traffic []TrafficTarget) *apis.FieldError { + var errs *apis.FieldError + + // Track the targets of named TrafficTarget entries (to detect duplicates). + trafficMap := make(map[string]int) + + sum := int64(0) + for i, tt := range traffic { + errs = errs.Also(tt.Validate(ctx).ViaIndex(i)) + + if idx, ok := trafficMap[tt.Tag]; ok { + // We want only single definition of the route, even if it points + // to the same config or revision. + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("Multiple definitions for %q", tt.Tag), + Paths: []string{ + fmt.Sprintf("[%d].tag", i), + fmt.Sprintf("[%d].tag", idx), + }, + }) + } else { + trafficMap[tt.Tag] = i + } + if tt.Percent != nil { + sum += *tt.Percent + } + } + + if sum != 100 { + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("Traffic targets sum to %d, want 100", sum), + Paths: []string{apis.CurrentField}, + }) + } + return errs +} + +// Validate implements apis.Validatable +func (rs *RouteSpec) Validate(ctx context.Context) *apis.FieldError { + return validateTrafficList(ctx, rs.Traffic).ViaField("traffic") +} + +// Validate verifies that TrafficTarget is properly configured. +func (tt *TrafficTarget) Validate(ctx context.Context) *apis.FieldError { + errs := tt.validateLatestRevision(ctx) + errs = tt.validateRevisionAndConfiguration(ctx, errs) + errs = tt.validateTrafficPercentage(errs) + return tt.validateURL(ctx, errs) +} + +func (tt *TrafficTarget) validateRevisionAndConfiguration(ctx context.Context, errs *apis.FieldError) *apis.FieldError { + // We only validate the sense of latestRevision in the context of a Spec, + // and only when it is specified. + switch { + // When we have a default configurationName, we don't + // allow one to be specified. + case HasDefaultConfigurationName(ctx) && tt.ConfigurationName != "": + errs = errs.Also(apis.ErrDisallowedFields("configurationName")) + + // Both revisionName and configurationName are never allowed to + // appear concurrently. + case tt.RevisionName != "" && tt.ConfigurationName != "": + errs = errs.Also(apis.ErrMultipleOneOf( + "revisionName", "configurationName")) + + // When a revisionName appears, we must check that the name is valid. + case tt.RevisionName != "": + if el := validation.IsQualifiedName(tt.RevisionName); len(el) > 0 { + errs = errs.Also(apis.ErrInvalidKeyName( + tt.RevisionName, "revisionName", el...)) + } + + // When revisionName is missing in Status report an error. + case apis.IsInStatus(ctx): + errs = errs.Also(apis.ErrMissingField("revisionName")) + + // When configurationName is specified, we must check that the name is valid. + case tt.ConfigurationName != "": + if el := validation.IsQualifiedName(tt.ConfigurationName); len(el) > 0 { + errs = errs.Also(apis.ErrInvalidKeyName( + tt.ConfigurationName, "configurationName", el...)) + } + + // When we are using a default configurationName, it must be a valid name already. + case HasDefaultConfigurationName(ctx): + + // All other cases are missing one of revisionName or configurationName. + default: + errs = errs.Also(apis.ErrMissingOneOf( + "revisionName", "configurationName")) + } + return errs +} + +func (tt *TrafficTarget) validateTrafficPercentage(errs *apis.FieldError) *apis.FieldError { + // Check that the traffic Percentage is within bounds. + if tt.Percent != nil && (*tt.Percent < 0 || *tt.Percent > 100) { + errs = errs.Also(apis.ErrOutOfBoundsValue( + *tt.Percent, 0, 100, "percent")) + } + return errs +} + +func (tt *TrafficTarget) validateLatestRevision(ctx context.Context) *apis.FieldError { + if apis.IsInSpec(ctx) && tt.LatestRevision != nil { + lr := *tt.LatestRevision + pinned := tt.RevisionName != "" + if pinned == lr { + // The senses for whether to pin to a particular revision or + // float forward to the latest revision must match. + return apis.ErrInvalidValue(lr, "latestRevision") + } + } + return nil +} + +func (tt *TrafficTarget) validateURL(ctx context.Context, errs *apis.FieldError) *apis.FieldError { + // Check that we set the URL appropriately. + if tt.URL.String() != "" { + // URL is not allowed in traffic under spec. + if apis.IsInSpec(ctx) { + errs = errs.Also(apis.ErrDisallowedFields("url")) + } + + // URL is not allowed in any traffic target without a name. + if tt.Tag == "" { + errs = errs.Also(apis.ErrDisallowedFields("url")) + } + } else if tt.Tag != "" { + // URL must be specified in status when name is specified. + if apis.IsInStatus(ctx) { + errs = errs.Also(apis.ErrMissingField("url")) + } + } + return errs +} + +// Validate implements apis.Validatable. +func (rs *RouteStatus) Validate(ctx context.Context) *apis.FieldError { + return rs.RouteStatusFields.Validate(ctx) +} + +// Validate implements apis.Validatable. +func (rsf *RouteStatusFields) Validate(ctx context.Context) *apis.FieldError { + // TODO(mattmoor): Validate other status fields. + + if len(rsf.Traffic) != 0 { + return validateTrafficList(ctx, rsf.Traffic).ViaField("traffic") + } + return nil +} + +func validateClusterVisibilityLabel(label string) (errs *apis.FieldError) { + if label != config.VisibilityClusterLocal { + errs = apis.ErrInvalidValue(label, config.VisibilityLabelKey) + } + return +} + +// validateLabels function validates route labels. +func (r *Route) validateLabels() (errs *apis.FieldError) { + for key, val := range r.GetLabels() { + switch { + case key == config.VisibilityLabelKey: + errs = errs.Also(validateClusterVisibilityLabel(val)) + case key == serving.ServiceLabelKey: + errs = errs.Also(verifyLabelOwnerRef(val, serving.ServiceLabelKey, "Service", r.GetOwnerReferences())) + case strings.HasPrefix(key, serving.GroupNamePrefix): + errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField)) + } + } + return +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/service_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_conversion.go new file mode 100644 index 00000000000..efb6605f338 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_conversion.go @@ -0,0 +1,34 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Service) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Service) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", source) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/service_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_defaults.go new file mode 100644 index 00000000000..72468790a72 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_defaults.go @@ -0,0 +1,57 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "context" + + "k8s.io/apimachinery/pkg/api/equality" + + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" +) + +// SetDefaults implements apis.Defaultable +func (s *Service) SetDefaults(ctx context.Context) { + ctx = apis.WithinParent(ctx, s.ObjectMeta) + s.Spec.SetDefaults(apis.WithinSpec(ctx)) + + if ui := apis.GetUserInfo(ctx); ui != nil { + ans := s.GetAnnotations() + if ans == nil { + ans = map[string]string{} + s.SetAnnotations(ans) + } + + if apis.IsInUpdate(ctx) { + old := apis.GetBaseline(ctx).(*Service) + if equality.Semantic.DeepEqual(old.Spec, s.Spec) { + return + } + ans[serving.UpdaterAnnotation] = ui.Username + } else { + ans[serving.CreatorAnnotation] = ui.Username + ans[serving.UpdaterAnnotation] = ui.Username + } + } +} + +// SetDefaults implements apis.Defaultable +func (ss *ServiceSpec) SetDefaults(ctx context.Context) { + ss.ConfigurationSpec.SetDefaults(ctx) + ss.RouteSpec.SetDefaults(WithDefaultConfigurationName(ctx)) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/service_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_lifecycle.go new file mode 100644 index 00000000000..f842245478a --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_lifecycle.go @@ -0,0 +1,35 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" +) + +var serviceCondSet = apis.NewLivingConditionSet() + +// GetGroupVersionKind returns the GroupVersionKind. +func (s *Service) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Service") +} + +// IsReady returns if the service is ready to serve the requested configuration. +func (ss *ServiceStatus) IsReady() bool { + return serviceCondSet.Manage(ss).IsHappy() +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/service_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_types.go new file mode 100644 index 00000000000..19c4758ac4e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_types.go @@ -0,0 +1,113 @@ +/* +Copyright 2019 The Knative Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Service acts as a top-level container that manages a Route and Configuration +// which implement a network service. Service exists to provide a singular +// abstraction which can be access controlled, reasoned about, and which +// encapsulates software lifecycle decisions such as rollout policy and +// team resource ownership. Service acts only as an orchestrator of the +// underlying Routes and Configurations (much as a kubernetes Deployment +// orchestrates ReplicaSets), and its usage is optional but recommended. +// +// The Service's controller will track the statuses of its owned Configuration +// and Route, reflecting their statuses and conditions as its own. +// +// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#service +type Service struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec ServiceSpec `json:"spec,omitempty"` + + // +optional + Status ServiceStatus `json:"status,omitempty"` +} + +// Verify that Service adheres to the appropriate interfaces. +var ( + // Check that Service may be validated and defaulted. + _ apis.Validatable = (*Service)(nil) + _ apis.Defaultable = (*Service)(nil) + + // Check that Service can be converted to higher versions. + _ apis.Convertible = (*Service)(nil) + + // Check that we can create OwnerReferences to a Service. + _ kmeta.OwnerRefable = (*Service)(nil) +) + +// ServiceSpec represents the configuration for the Service object. +// A Service's specification is the union of the specifications for a Route +// and Configuration. The Service restricts what can be expressed in these +// fields, e.g. the Route must reference the provided Configuration; +// however, these limitations also enable friendlier defaulting, +// e.g. Route never needs a Configuration name, and may be defaulted to +// the appropriate "run latest" spec. +type ServiceSpec struct { + // ServiceSpec inlines an unrestricted ConfigurationSpec. + ConfigurationSpec `json:",inline"` + + // ServiceSpec inlines RouteSpec and restricts/defaults its fields + // via webhook. In particular, this spec can only reference this + // Service's configuration and revisions (which also influences + // defaults). + RouteSpec `json:",inline"` +} + +// ConditionType represents a Service condition value +const ( + // ServiceConditionReady is set when the service is configured + // and has available backends ready to receive traffic. + ServiceConditionReady = apis.ConditionReady +) + +// ServiceStatus represents the Status stanza of the Service resource. +type ServiceStatus struct { + duckv1.Status `json:",inline"` + + // In addition to inlining ConfigurationSpec, we also inline the fields + // specific to ConfigurationStatus. + ConfigurationStatusFields `json:",inline"` + + // In addition to inlining RouteSpec, we also inline the fields + // specific to RouteStatus. + RouteStatusFields `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ServiceList is a list of Service resources +type ServiceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Service `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/service_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_validation.go new file mode 100644 index 00000000000..bbe5477bc8c --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_validation.go @@ -0,0 +1,79 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "context" + "strings" + + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" + "knative.dev/serving/pkg/reconciler/route/config" +) + +// Validate makes sure that Service is properly configured. +func (s *Service) Validate(ctx context.Context) (errs *apis.FieldError) { + // If we are in a status sub resource update, the metadata and spec cannot change. + // So, to avoid rejecting controller status updates due to validations that may + // have changed (i.e. due to config-defaults changes), we elide the metadata and + // spec validation. + if !apis.IsInStatusUpdate(ctx) { + errs = errs.Also(serving.ValidateObjectMetadata(s.GetObjectMeta()).Also( + s.validateLabels().ViaField("labels")).ViaField("metadata")) + ctx = apis.WithinParent(ctx, s.ObjectMeta) + errs = errs.Also(s.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + errs = errs.Also(s.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Service) + errs = errs.Also(apis.ValidateCreatorAndModifier(original.Spec, s.Spec, original.GetAnnotations(), + s.GetAnnotations(), serving.GroupName).ViaField("metadata.annotations")) + err := s.Spec.ConfigurationSpec.Template.VerifyNameChange(ctx, + original.Spec.ConfigurationSpec.Template) + errs = errs.Also(err.ViaField("spec.template")) + } + return errs +} + +// Validate implements apis.Validatable +func (ss *ServiceSpec) Validate(ctx context.Context) *apis.FieldError { + return ss.ConfigurationSpec.Validate(ctx).Also( + // Within the context of Service, the RouteSpec has a default + // configurationName. + ss.RouteSpec.Validate(WithDefaultConfigurationName(ctx))) +} + +// Validate implements apis.Validatable +func (ss *ServiceStatus) Validate(ctx context.Context) *apis.FieldError { + return ss.ConfigurationStatusFields.Validate(ctx).Also( + ss.RouteStatusFields.Validate(ctx)) +} + +// validateLabels function validates service labels +func (s *Service) validateLabels() (errs *apis.FieldError) { + for key, val := range s.GetLabels() { + switch { + case key == config.VisibilityLabelKey: + errs = errs.Also(validateClusterVisibilityLabel(val)) + case strings.HasPrefix(key, serving.GroupNamePrefix): + errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField)) + } + } + return +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/zz_generated.deepcopy.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..efdd513f96f --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/zz_generated.deepcopy.go @@ -0,0 +1,526 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" + apis "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Configuration) DeepCopyInto(out *Configuration) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Configuration. +func (in *Configuration) DeepCopy() *Configuration { + if in == nil { + return nil + } + out := new(Configuration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Configuration) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigurationList) DeepCopyInto(out *ConfigurationList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Configuration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationList. +func (in *ConfigurationList) DeepCopy() *ConfigurationList { + if in == nil { + return nil + } + out := new(ConfigurationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ConfigurationList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigurationSpec) DeepCopyInto(out *ConfigurationSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationSpec. +func (in *ConfigurationSpec) DeepCopy() *ConfigurationSpec { + if in == nil { + return nil + } + out := new(ConfigurationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigurationStatus) DeepCopyInto(out *ConfigurationStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + out.ConfigurationStatusFields = in.ConfigurationStatusFields + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationStatus. +func (in *ConfigurationStatus) DeepCopy() *ConfigurationStatus { + if in == nil { + return nil + } + out := new(ConfigurationStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigurationStatusFields) DeepCopyInto(out *ConfigurationStatusFields) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationStatusFields. +func (in *ConfigurationStatusFields) DeepCopy() *ConfigurationStatusFields { + if in == nil { + return nil + } + out := new(ConfigurationStatusFields) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Revision) DeepCopyInto(out *Revision) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Revision. +func (in *Revision) DeepCopy() *Revision { + if in == nil { + return nil + } + out := new(Revision) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Revision) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RevisionList) DeepCopyInto(out *RevisionList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Revision, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionList. +func (in *RevisionList) DeepCopy() *RevisionList { + if in == nil { + return nil + } + out := new(RevisionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RevisionList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RevisionSpec) DeepCopyInto(out *RevisionSpec) { + *out = *in + in.PodSpec.DeepCopyInto(&out.PodSpec) + if in.ContainerConcurrency != nil { + in, out := &in.ContainerConcurrency, &out.ContainerConcurrency + *out = new(int64) + **out = **in + } + if in.TimeoutSeconds != nil { + in, out := &in.TimeoutSeconds, &out.TimeoutSeconds + *out = new(int64) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionSpec. +func (in *RevisionSpec) DeepCopy() *RevisionSpec { + if in == nil { + return nil + } + out := new(RevisionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RevisionStatus) DeepCopyInto(out *RevisionStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionStatus. +func (in *RevisionStatus) DeepCopy() *RevisionStatus { + if in == nil { + return nil + } + out := new(RevisionStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RevisionTemplateSpec) DeepCopyInto(out *RevisionTemplateSpec) { + *out = *in + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionTemplateSpec. +func (in *RevisionTemplateSpec) DeepCopy() *RevisionTemplateSpec { + if in == nil { + return nil + } + out := new(RevisionTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Route) DeepCopyInto(out *Route) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Route. +func (in *Route) DeepCopy() *Route { + if in == nil { + return nil + } + out := new(Route) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Route) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RouteList) DeepCopyInto(out *RouteList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Route, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteList. +func (in *RouteList) DeepCopy() *RouteList { + if in == nil { + return nil + } + out := new(RouteList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RouteList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RouteSpec) DeepCopyInto(out *RouteSpec) { + *out = *in + if in.Traffic != nil { + in, out := &in.Traffic, &out.Traffic + *out = make([]TrafficTarget, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteSpec. +func (in *RouteSpec) DeepCopy() *RouteSpec { + if in == nil { + return nil + } + out := new(RouteSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RouteStatus) DeepCopyInto(out *RouteStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + in.RouteStatusFields.DeepCopyInto(&out.RouteStatusFields) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteStatus. +func (in *RouteStatus) DeepCopy() *RouteStatus { + if in == nil { + return nil + } + out := new(RouteStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RouteStatusFields) DeepCopyInto(out *RouteStatusFields) { + *out = *in + if in.URL != nil { + in, out := &in.URL, &out.URL + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + if in.Address != nil { + in, out := &in.Address, &out.Address + *out = new(duckv1.Addressable) + (*in).DeepCopyInto(*out) + } + if in.Traffic != nil { + in, out := &in.Traffic, &out.Traffic + *out = make([]TrafficTarget, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteStatusFields. +func (in *RouteStatusFields) DeepCopy() *RouteStatusFields { + if in == nil { + return nil + } + out := new(RouteStatusFields) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Service) DeepCopyInto(out *Service) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Service. +func (in *Service) DeepCopy() *Service { + if in == nil { + return nil + } + out := new(Service) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Service) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceList) DeepCopyInto(out *ServiceList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Service, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceList. +func (in *ServiceList) DeepCopy() *ServiceList { + if in == nil { + return nil + } + out := new(ServiceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ServiceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) { + *out = *in + in.ConfigurationSpec.DeepCopyInto(&out.ConfigurationSpec) + in.RouteSpec.DeepCopyInto(&out.RouteSpec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceSpec. +func (in *ServiceSpec) DeepCopy() *ServiceSpec { + if in == nil { + return nil + } + out := new(ServiceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceStatus) DeepCopyInto(out *ServiceStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + out.ConfigurationStatusFields = in.ConfigurationStatusFields + in.RouteStatusFields.DeepCopyInto(&out.RouteStatusFields) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceStatus. +func (in *ServiceStatus) DeepCopy() *ServiceStatus { + if in == nil { + return nil + } + out := new(ServiceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TrafficTarget) DeepCopyInto(out *TrafficTarget) { + *out = *in + if in.LatestRevision != nil { + in, out := &in.LatestRevision, &out.LatestRevision + *out = new(bool) + **out = **in + } + if in.Percent != nil { + in, out := &in.Percent, &out.Percent + *out = new(int64) + **out = **in + } + if in.URL != nil { + in, out := &in.URL, &out.URL + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficTarget. +func (in *TrafficTarget) DeepCopy() *TrafficTarget { + if in == nil { + return nil + } + out := new(TrafficTarget) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_conversion.go index e9b42793138..a7d804a293c 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_conversion.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_conversion.go @@ -21,6 +21,7 @@ import ( "fmt" "knative.dev/pkg/apis" + v1 "knative.dev/serving/pkg/apis/serving/v1" "knative.dev/serving/pkg/apis/serving/v1beta1" ) @@ -33,13 +34,19 @@ func (source *Configuration) ConvertUp(ctx context.Context, obj apis.Convertible return err } return source.Status.ConvertUp(ctx, &sink.Status) + case *v1.Configuration: + sink.ObjectMeta = source.ObjectMeta + if err := source.Spec.ConvertUp(ctx, &sink.Spec); err != nil { + return err + } + return source.Status.ConvertUp(ctx, &sink.Status) default: return fmt.Errorf("unknown version, got: %T", sink) } } // ConvertUp helps implement apis.Convertible -func (source *ConfigurationSpec) ConvertUp(ctx context.Context, sink *v1beta1.ConfigurationSpec) error { +func (source *ConfigurationSpec) ConvertUp(ctx context.Context, sink *v1.ConfigurationSpec) error { if source.DeprecatedBuild != nil { return ConvertErrorf("build", "build cannot be migrated forward.") } @@ -56,14 +63,14 @@ func (source *ConfigurationSpec) ConvertUp(ctx context.Context, sink *v1beta1.Co } // ConvertUp helps implement apis.Convertible -func (source *ConfigurationStatus) ConvertUp(ctx context.Context, sink *v1beta1.ConfigurationStatus) error { +func (source *ConfigurationStatus) ConvertUp(ctx context.Context, sink *v1.ConfigurationStatus) error { source.Status.ConvertTo(ctx, &sink.Status) return source.ConfigurationStatusFields.ConvertUp(ctx, &sink.ConfigurationStatusFields) } // ConvertUp helps implement apis.Convertible -func (source *ConfigurationStatusFields) ConvertUp(ctx context.Context, sink *v1beta1.ConfigurationStatusFields) error { +func (source *ConfigurationStatusFields) ConvertUp(ctx context.Context, sink *v1.ConfigurationStatusFields) error { sink.LatestReadyRevisionName = source.LatestReadyRevisionName sink.LatestCreatedRevisionName = source.LatestCreatedRevisionName return nil @@ -78,26 +85,32 @@ func (sink *Configuration) ConvertDown(ctx context.Context, obj apis.Convertible return err } return sink.Status.ConvertDown(ctx, source.Status) + case *v1.Configuration: + sink.ObjectMeta = source.ObjectMeta + if err := sink.Spec.ConvertDown(ctx, source.Spec); err != nil { + return err + } + return sink.Status.ConvertDown(ctx, source.Status) default: return fmt.Errorf("unknown version, got: %T", source) } } // ConvertDown helps implement apis.Convertible -func (sink *ConfigurationSpec) ConvertDown(ctx context.Context, source v1beta1.ConfigurationSpec) error { +func (sink *ConfigurationSpec) ConvertDown(ctx context.Context, source v1.ConfigurationSpec) error { sink.Template = &RevisionTemplateSpec{} return sink.Template.ConvertDown(ctx, source.Template) } // ConvertDown helps implement apis.Convertible -func (sink *ConfigurationStatus) ConvertDown(ctx context.Context, source v1beta1.ConfigurationStatus) error { +func (sink *ConfigurationStatus) ConvertDown(ctx context.Context, source v1.ConfigurationStatus) error { source.Status.ConvertTo(ctx, &sink.Status) return sink.ConfigurationStatusFields.ConvertDown(ctx, source.ConfigurationStatusFields) } // ConvertDown helps implement apis.Convertible -func (sink *ConfigurationStatusFields) ConvertDown(ctx context.Context, source v1beta1.ConfigurationStatusFields) error { +func (sink *ConfigurationStatusFields) ConvertDown(ctx context.Context, source v1.ConfigurationStatusFields) error { sink.LatestReadyRevisionName = source.LatestReadyRevisionName sink.LatestCreatedRevisionName = source.LatestCreatedRevisionName return nil diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_defaults.go index 0e6795def1b..48e5ac2ff88 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_defaults.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_defaults.go @@ -21,7 +21,7 @@ import ( "knative.dev/pkg/apis" - "knative.dev/serving/pkg/apis/serving/v1beta1" + v1 "knative.dev/serving/pkg/apis/serving/v1" ) func (c *Configuration) SetDefaults(ctx context.Context) { @@ -30,11 +30,11 @@ func (c *Configuration) SetDefaults(ctx context.Context) { } func (cs *ConfigurationSpec) SetDefaults(ctx context.Context) { - if v1beta1.IsUpgradeViaDefaulting(ctx) { - beta := v1beta1.ConfigurationSpec{} - if cs.ConvertUp(ctx, &beta) == nil { + if v1.IsUpgradeViaDefaulting(ctx) { + v1 := v1.ConfigurationSpec{} + if cs.ConvertUp(ctx, &v1) == nil { alpha := ConfigurationSpec{} - if alpha.ConvertDown(ctx, beta) == nil { + if alpha.ConvertDown(ctx, v1) == nil { *cs = alpha } } diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_lifecycle.go index 338022a6874..c0b4a665351 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_lifecycle.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_lifecycle.go @@ -20,7 +20,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + duckv1 "knative.dev/pkg/apis/duck/v1" ) var confCondSet = apis.NewLivingConditionSet() @@ -112,6 +112,6 @@ func (cs *ConfigurationStatus) MarkLatestReadyDeleted() { "Revision %q was deleted.", cs.LatestReadyRevisionName) } -func (cs *ConfigurationStatus) duck() *duckv1beta1.Status { +func (cs *ConfigurationStatus) duck() *duckv1.Status { return &cs.Status } diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_types.go index 3d55854454b..87addf0d524 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_types.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_types.go @@ -20,7 +20,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/kmeta" ) @@ -98,7 +98,7 @@ const ( ConfigurationConditionReady = apis.ConditionReady ) -// ConfigurationStatusFields holds all of the non-duckv1beta1.Status status fields of a Route. +// ConfigurationStatusFields holds all of the non-duckv1.Status status fields of a Route. // These are defined outline so that we can also inline them into Service, and more easily // copy them. type ConfigurationStatusFields struct { @@ -115,7 +115,7 @@ type ConfigurationStatusFields struct { // ConfigurationStatus communicates the observed state of the Configuration (from the controller). type ConfigurationStatus struct { - duckv1beta1.Status `json:",inline"` + duckv1.Status `json:",inline"` ConfigurationStatusFields `json:",inline"` } diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_conversion.go index 7851d8a75d8..5c127e30164 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_conversion.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_conversion.go @@ -23,6 +23,7 @@ import ( corev1 "k8s.io/api/core/v1" "knative.dev/pkg/apis" "knative.dev/pkg/ptr" + v1 "knative.dev/serving/pkg/apis/serving/v1" "knative.dev/serving/pkg/apis/serving/v1beta1" ) @@ -39,18 +40,19 @@ func (source *Revision) ConvertUp(ctx context.Context, obj apis.Convertible) err } // ConvertUp helps implement apis.Convertible -func (source *RevisionTemplateSpec) ConvertUp(ctx context.Context, sink *v1beta1.RevisionTemplateSpec) error { +func (source *RevisionTemplateSpec) ConvertUp(ctx context.Context, sink *v1.RevisionTemplateSpec) error { sink.ObjectMeta = source.ObjectMeta return source.Spec.ConvertUp(ctx, &sink.Spec) } // ConvertUp helps implement apis.Convertible -func (source *RevisionSpec) ConvertUp(ctx context.Context, sink *v1beta1.RevisionSpec) error { - sink.ContainerConcurrency = v1beta1.RevisionContainerConcurrencyType( - source.ContainerConcurrency) +func (source *RevisionSpec) ConvertUp(ctx context.Context, sink *v1.RevisionSpec) error { if source.TimeoutSeconds != nil { sink.TimeoutSeconds = ptr.Int64(*source.TimeoutSeconds) } + if source.ContainerConcurrency != nil { + sink.ContainerConcurrency = ptr.Int64(*source.ContainerConcurrency) + } switch { case source.DeprecatedContainer != nil && len(source.Containers) > 0: return apis.ErrMultipleOneOf("container", "containers") @@ -75,7 +77,7 @@ func (source *RevisionSpec) ConvertUp(ctx context.Context, sink *v1beta1.Revisio } // ConvertUp helps implement apis.Convertible -func (source *RevisionStatus) ConvertUp(ctx context.Context, sink *v1beta1.RevisionStatus) { +func (source *RevisionStatus) ConvertUp(ctx context.Context, sink *v1.RevisionStatus) { source.Status.ConvertTo(ctx, &sink.Status) sink.ServiceName = source.ServiceName @@ -96,19 +98,19 @@ func (sink *Revision) ConvertDown(ctx context.Context, obj apis.Convertible) err } // ConvertDown helps implement apis.Convertible -func (sink *RevisionTemplateSpec) ConvertDown(ctx context.Context, source v1beta1.RevisionTemplateSpec) error { +func (sink *RevisionTemplateSpec) ConvertDown(ctx context.Context, source v1.RevisionTemplateSpec) error { sink.ObjectMeta = source.ObjectMeta return sink.Spec.ConvertDown(ctx, source.Spec) } // ConvertDown helps implement apis.Convertible -func (sink *RevisionSpec) ConvertDown(ctx context.Context, source v1beta1.RevisionSpec) error { +func (sink *RevisionSpec) ConvertDown(ctx context.Context, source v1.RevisionSpec) error { sink.RevisionSpec = *source.DeepCopy() return nil } // ConvertDown helps implement apis.Convertible -func (sink *RevisionStatus) ConvertDown(ctx context.Context, source v1beta1.RevisionStatus) { +func (sink *RevisionStatus) ConvertDown(ctx context.Context, source v1.RevisionStatus) { source.Status.ConvertTo(ctx, &sink.Status) sink.ServiceName = source.ServiceName diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_defaults.go index 035012306cd..904abd8c2fd 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_defaults.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_defaults.go @@ -21,8 +21,8 @@ import ( corev1 "k8s.io/api/core/v1" "knative.dev/pkg/apis" - - "knative.dev/serving/pkg/apis/serving/v1beta1" + "knative.dev/pkg/ptr" + v1 "knative.dev/serving/pkg/apis/serving/v1" ) func (r *Revision) SetDefaults(ctx context.Context) { @@ -30,20 +30,20 @@ func (r *Revision) SetDefaults(ctx context.Context) { } func (rs *RevisionSpec) SetDefaults(ctx context.Context) { - if v1beta1.IsUpgradeViaDefaulting(ctx) { - beta := v1beta1.RevisionSpec{} - if rs.ConvertUp(ctx, &beta) == nil { + if v1.IsUpgradeViaDefaulting(ctx) { + v1 := v1.RevisionSpec{} + if rs.ConvertUp(ctx, &v1) == nil { alpha := RevisionSpec{} - if alpha.ConvertDown(ctx, beta) == nil { + if alpha.ConvertDown(ctx, v1) == nil { *rs = alpha } } } // When ConcurrencyModel is specified but ContainerConcurrency - // is not (0), use the ConcurrencyModel value. - if rs.DeprecatedConcurrencyModel == DeprecatedRevisionRequestConcurrencyModelSingle && rs.ContainerConcurrency == 0 { - rs.ContainerConcurrency = 1 + // is not (`nil`), use the ConcurrencyModel value. + if rs.DeprecatedConcurrencyModel == DeprecatedRevisionRequestConcurrencyModelSingle && rs.ContainerConcurrency == nil { + rs.ContainerConcurrency = ptr.Int64(1) } // When the PodSpec has no containers, move the single Container diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go index 2f84a5da957..13c26c5466f 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go @@ -21,10 +21,13 @@ import ( "strconv" "time" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + duckv1 "knative.dev/pkg/apis/duck/v1" + av1alpha1 "knative.dev/serving/pkg/apis/autoscaling/v1alpha1" + "knative.dev/serving/pkg/apis/config" net "knative.dev/serving/pkg/apis/networking" "knative.dev/serving/pkg/apis/serving" ) @@ -79,6 +82,20 @@ func (rs *RevisionSpec) GetContainer() *corev1.Container { return &corev1.Container{} } +// GetContainerConcurrency returns the container concurrency. If +// container concurrency is not set, the default value will be returned. +// We use the original default (0) here for backwards compatibility. +// Previous versions of Knative equated unspecified and zero, so to avoid +// changing the value used by Revisions with unspecified values when a different +// default is configured, we use the original default instead of the configured +// default to remain safe across upgrades. +func (rs *RevisionSpec) GetContainerConcurrency() int64 { + if rs.ContainerConcurrency == nil { + return config.DefaultContainerConcurrency + } + return *rs.ContainerConcurrency +} + func (r *Revision) DeprecatedBuildRef() *corev1.ObjectReference { if r.Spec.DeprecatedBuildRef != nil { buildRef := r.Spec.DeprecatedBuildRef.DeepCopy() @@ -195,6 +212,33 @@ func (rs *RevisionStatus) MarkContainerMissing(message string) { revCondSet.Manage(rs).MarkFalse(RevisionConditionContainerHealthy, "ContainerMissing", message) } +// PropagateAutoscalerStatus propagates autoscaler's status to the revision's status. +func (rs *RevisionStatus) PropagateAutoscalerStatus(ps *av1alpha1.PodAutoscalerStatus) { + // Propagate the service name from the PA. + rs.ServiceName = ps.ServiceName + + // Reflect the PA status in our own. + cond := ps.GetCondition(av1alpha1.PodAutoscalerConditionReady) + if cond == nil { + rs.MarkActivating("Deploying", "") + return + } + + switch cond.Status { + case corev1.ConditionUnknown: + rs.MarkActivating(cond.Reason, cond.Message) + case corev1.ConditionFalse: + rs.MarkInactive(cond.Reason, cond.Message) + case corev1.ConditionTrue: + rs.MarkActive() + + // Precondition for PA being active is SKS being active and + // that entices that |service.endpoints| > 0. + rs.MarkResourcesAvailable() + rs.MarkContainerHealthy() + } +} + // RevisionContainerMissingMessage constructs the status message if a given image // cannot be pulled correctly. func RevisionContainerMissingMessage(image string, message string) string { @@ -267,6 +311,30 @@ func (r *Revision) GetLastPinned() (time.Time, error) { return time.Unix(secs, 0), nil } -func (rs *RevisionStatus) duck() *duckv1beta1.Status { +// IsReachable returns whether or not the revision can be reached by a route. +func (r *Revision) IsReachable() bool { + return r.ObjectMeta.Labels[serving.RouteLabelKey] != "" +} + +func (rs *RevisionStatus) duck() *duckv1.Status { return &rs.Status } + +// PropagateDeploymentStatus takes the Deployment status and applies its values +// to the Revision status. +func (rs *RevisionStatus) PropagateDeploymentStatus(original *appsv1.DeploymentStatus) { + ds := serving.TransformDeploymentStatus(original) + cond := ds.GetCondition(serving.DeploymentConditionReady) + if cond == nil { + return + } + + switch cond.Status { + case corev1.ConditionUnknown: + revCondSet.Manage(rs).MarkUnknown(RevisionConditionResourcesAvailable, cond.Reason, cond.Message) + case corev1.ConditionTrue: + revCondSet.Manage(rs).MarkTrue(RevisionConditionResourcesAvailable) + case corev1.ConditionFalse: + revCondSet.Manage(rs).MarkFalse(RevisionConditionResourcesAvailable, cond.Reason, cond.Message) + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_types.go index cc1cc1c6974..99704e971df 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_types.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_types.go @@ -20,10 +20,10 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/kmeta" - "knative.dev/serving/pkg/apis/serving/v1beta1" + v1 "knative.dev/serving/pkg/apis/serving/v1" ) // +genclient @@ -93,7 +93,7 @@ const ( // DeprecatedRevisionRequestConcurrencyModelType is an enumeration of the // concurrency models supported by a Revision. -// DEPRECATED in favor of RevisionContainerConcurrencyType. +// DEPRECATED in favor of an integer based ContainerConcurrency setting. // TODO(vagababov): retire completely in 0.9. type DeprecatedRevisionRequestConcurrencyModelType string @@ -110,7 +110,7 @@ const ( // RevisionSpec holds the desired state of the Revision (from the client). type RevisionSpec struct { - v1beta1.RevisionSpec `json:",inline"` + v1.RevisionSpec `json:",inline"` // DeprecatedGeneration was used prior in Kubernetes versions <1.11 // when metadata.generation was not being incremented by the api server @@ -173,7 +173,7 @@ const ( // RevisionStatus communicates the observed state of the Revision (from the controller). type RevisionStatus struct { - duckv1beta1.Status `json:",inline"` + duckv1.Status `json:",inline"` // ServiceName holds the name of a core Kubernetes Service resource that // load balances over the pods backing this Revision. diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_validation.go index 8d6224d9b6c..765ad15b7f7 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_validation.go @@ -146,7 +146,9 @@ func (rs *RevisionSpec) Validate(ctx context.Context) *apis.FieldError { if err := rs.DeprecatedConcurrencyModel.Validate(ctx).ViaField("concurrencyModel"); err != nil { errs = errs.Also(err) } else { - errs = errs.Also(rs.ContainerConcurrency.Validate(ctx).ViaField("containerConcurrency")) + if rs.ContainerConcurrency != nil { + errs = errs.Also(serving.ValidateContainerConcurrency(rs.ContainerConcurrency).ViaField("containerConcurrency")) + } } if rs.TimeoutSeconds != nil { diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_conversion.go index 699fe796562..f7fa0ba3197 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_conversion.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_conversion.go @@ -21,7 +21,9 @@ import ( "fmt" "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + v1 "knative.dev/serving/pkg/apis/serving/v1" "knative.dev/serving/pkg/apis/serving/v1beta1" ) @@ -38,8 +40,8 @@ func (source *Route) ConvertUp(ctx context.Context, obj apis.Convertible) error } // ConvertUp helps implement apis.Convertible -func (source *RouteSpec) ConvertUp(ctx context.Context, sink *v1beta1.RouteSpec) error { - sink.Traffic = make([]v1beta1.TrafficTarget, len(source.Traffic)) +func (source *RouteSpec) ConvertUp(ctx context.Context, sink *v1.RouteSpec) error { + sink.Traffic = make([]v1.TrafficTarget, len(source.Traffic)) for i := range source.Traffic { if err := source.Traffic[i].ConvertUp(ctx, &sink.Traffic[i]); err != nil { return err @@ -49,7 +51,7 @@ func (source *RouteSpec) ConvertUp(ctx context.Context, sink *v1beta1.RouteSpec) } // ConvertUp helps implement apis.Convertible -func (source *TrafficTarget) ConvertUp(ctx context.Context, sink *v1beta1.TrafficTarget) error { +func (source *TrafficTarget) ConvertUp(ctx context.Context, sink *v1.TrafficTarget) error { *sink = source.TrafficTarget switch { case source.Tag != "" && source.DeprecatedName != "": @@ -63,23 +65,26 @@ func (source *TrafficTarget) ConvertUp(ctx context.Context, sink *v1beta1.Traffi } // ConvertUp helps implement apis.Convertible -func (source *RouteStatus) ConvertUp(ctx context.Context, sink *v1beta1.RouteStatus) { +func (source *RouteStatus) ConvertUp(ctx context.Context, sink *v1.RouteStatus) { source.Status.ConvertTo(ctx, &sink.Status) source.RouteStatusFields.ConvertUp(ctx, &sink.RouteStatusFields) } // ConvertUp helps implement apis.Convertible -func (source *RouteStatusFields) ConvertUp(ctx context.Context, sink *v1beta1.RouteStatusFields) { +func (source *RouteStatusFields) ConvertUp(ctx context.Context, sink *v1.RouteStatusFields) { if source.URL != nil { sink.URL = source.URL.DeepCopy() } if source.Address != nil { - sink.Address = source.Address.Addressable.DeepCopy() + if sink.Address == nil { + sink.Address = &duckv1.Addressable{} + } + source.Address.ConvertUp(ctx, sink.Address) } - sink.Traffic = make([]v1beta1.TrafficTarget, len(source.Traffic)) + sink.Traffic = make([]v1.TrafficTarget, len(source.Traffic)) for i := range source.Traffic { source.Traffic[i].ConvertUp(ctx, &sink.Traffic[i]) } @@ -99,7 +104,7 @@ func (sink *Route) ConvertDown(ctx context.Context, obj apis.Convertible) error } // ConvertDown helps implement apis.Convertible -func (sink *RouteSpec) ConvertDown(ctx context.Context, source v1beta1.RouteSpec) { +func (sink *RouteSpec) ConvertDown(ctx context.Context, source v1.RouteSpec) { sink.Traffic = make([]TrafficTarget, len(source.Traffic)) for i := range source.Traffic { sink.Traffic[i].ConvertDown(ctx, source.Traffic[i]) @@ -107,27 +112,28 @@ func (sink *RouteSpec) ConvertDown(ctx context.Context, source v1beta1.RouteSpec } // ConvertDown helps implement apis.Convertible -func (sink *TrafficTarget) ConvertDown(ctx context.Context, source v1beta1.TrafficTarget) { +func (sink *TrafficTarget) ConvertDown(ctx context.Context, source v1.TrafficTarget) { sink.TrafficTarget = source } // ConvertDown helps implement apis.Convertible -func (sink *RouteStatus) ConvertDown(ctx context.Context, source v1beta1.RouteStatus) { +func (sink *RouteStatus) ConvertDown(ctx context.Context, source v1.RouteStatus) { source.Status.ConvertTo(ctx, &sink.Status) sink.RouteStatusFields.ConvertDown(ctx, source.RouteStatusFields) } // ConvertDown helps implement apis.Convertible -func (sink *RouteStatusFields) ConvertDown(ctx context.Context, source v1beta1.RouteStatusFields) { +func (sink *RouteStatusFields) ConvertDown(ctx context.Context, source v1.RouteStatusFields) { if source.URL != nil { sink.URL = source.URL.DeepCopy() } if source.Address != nil { - sink.Address = &duckv1alpha1.Addressable{ - Addressable: *source.Address, + if sink.Address == nil { + sink.Address = &duckv1alpha1.Addressable{} } + sink.Address.ConvertDown(ctx, source.Address) } sink.Traffic = make([]TrafficTarget, len(source.Traffic)) diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_defaults.go index ab089b25284..e4a5ddbd295 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_defaults.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_defaults.go @@ -21,7 +21,7 @@ import ( "knative.dev/pkg/apis" "knative.dev/pkg/ptr" - "knative.dev/serving/pkg/apis/serving/v1beta1" + v1 "knative.dev/serving/pkg/apis/serving/v1" ) func (r *Route) SetDefaults(ctx context.Context) { @@ -29,19 +29,19 @@ func (r *Route) SetDefaults(ctx context.Context) { } func (rs *RouteSpec) SetDefaults(ctx context.Context) { - if v1beta1.IsUpgradeViaDefaulting(ctx) { - beta := v1beta1.RouteSpec{} - if rs.ConvertUp(ctx, &beta) == nil { + if v1.IsUpgradeViaDefaulting(ctx) { + v1 := v1.RouteSpec{} + if rs.ConvertUp(ctx, &v1) == nil { alpha := RouteSpec{} - alpha.ConvertDown(ctx, beta) + alpha.ConvertDown(ctx, v1) *rs = alpha } } - if len(rs.Traffic) == 0 && v1beta1.HasDefaultConfigurationName(ctx) { + if len(rs.Traffic) == 0 && v1.HasDefaultConfigurationName(ctx) { rs.Traffic = []TrafficTarget{{ - TrafficTarget: v1beta1.TrafficTarget{ - Percent: 100, + TrafficTarget: v1.TrafficTarget{ + Percent: ptr.Int64(100), LatestRevision: ptr.Bool(true), }, }} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_lifecycle.go index a38828f8868..401e18791f7 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_lifecycle.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_lifecycle.go @@ -23,7 +23,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/serving/pkg/apis/networking/v1alpha1" ) @@ -170,6 +170,6 @@ func (rs *RouteStatus) PropagateIngressStatus(cs v1alpha1.IngressStatus) { } } -func (rs *RouteStatus) duck() *duckv1beta1.Status { +func (rs *RouteStatus) duck() *duckv1.Status { return &rs.Status } diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_types.go index b7495e97418..3dad80e7cc1 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_types.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_types.go @@ -20,11 +20,11 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmeta" - "knative.dev/serving/pkg/apis/serving/v1beta1" + v1 "knative.dev/serving/pkg/apis/serving/v1" ) // +genclient @@ -70,9 +70,9 @@ type TrafficTarget struct { // +optional DeprecatedName string `json:"name,omitempty"` - // We inherit most of our fields by inlining the v1beta1 type. - // Ultimately all non-v1beta1 fields will be deprecated. - v1beta1.TrafficTarget `json:",inline"` + // We inherit most of our fields by inlining the v1 type. + // Ultimately all non-v1 fields will be deprecated. + v1.TrafficTarget `json:",inline"` } // RouteSpec holds the desired state of the Route (from the client). @@ -112,7 +112,7 @@ const ( RouteConditionCertificateProvisioned apis.ConditionType = "CertificateProvisioned" ) -// RouteStatusFields holds all of the non-duckv1beta1.Status status fields of a Route. +// RouteStatusFields holds all of the non-duckv1.Status status fields of a Route. // These are defined outline so that we can also inline them into Service, and more easily // copy them. type RouteStatusFields struct { @@ -147,7 +147,7 @@ type RouteStatusFields struct { // RouteStatus communicates the observed state of the Route (from the controller). type RouteStatus struct { - duckv1beta1.Status `json:",inline"` + duckv1.Status `json:",inline"` RouteStatusFields `json:",inline"` } diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_validation.go index 685c7f77c79..83cf3aa8d32 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_validation.go @@ -45,12 +45,14 @@ func (rs *RouteSpec) Validate(ctx context.Context) *apis.FieldError { // Track the targets of named TrafficTarget entries (to detect duplicates). trafficMap := make(map[string]diagnostic) - percentSum := 0 + percentSum := int64(0) for i, tt := range rs.Traffic { - // Delegate to the v1beta1 validation. + // Delegate to the v1 validation. errs = errs.Also(tt.TrafficTarget.Validate(ctx).ViaFieldIndex("traffic", i)) - percentSum += tt.Percent + if tt.Percent != nil { + percentSum += *tt.Percent + } if tt.DeprecatedName != "" && tt.Tag != "" { errs = errs.Also(apis.ErrMultipleOneOf("name", "tag"). diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_conversion.go index d4d42aafebe..c4a799a18ee 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_conversion.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_conversion.go @@ -22,6 +22,7 @@ import ( "knative.dev/pkg/apis" "knative.dev/pkg/ptr" + v1 "knative.dev/serving/pkg/apis/serving/v1" "knative.dev/serving/pkg/apis/serving/v1beta1" ) @@ -34,18 +35,24 @@ func (source *Service) ConvertUp(ctx context.Context, obj apis.Convertible) erro return err } return source.Status.ConvertUp(ctx, &sink.Status) + case *v1.Service: + sink.ObjectMeta = source.ObjectMeta + if err := source.Spec.ConvertUp(ctx, &sink.Spec); err != nil { + return err + } + return source.Status.ConvertUp(ctx, &sink.Status) default: return fmt.Errorf("unknown version, got: %T", sink) } } // ConvertUp helps implement apis.Convertible -func (source *ServiceSpec) ConvertUp(ctx context.Context, sink *v1beta1.ServiceSpec) error { +func (source *ServiceSpec) ConvertUp(ctx context.Context, sink *v1.ServiceSpec) error { switch { case source.DeprecatedRunLatest != nil: - sink.RouteSpec = v1beta1.RouteSpec{ - Traffic: []v1beta1.TrafficTarget{{ - Percent: 100, + sink.RouteSpec = v1.RouteSpec{ + Traffic: []v1.TrafficTarget{{ + Percent: ptr.Int64(100), LatestRevision: ptr.Bool(true), }}, } @@ -53,29 +60,29 @@ func (source *ServiceSpec) ConvertUp(ctx context.Context, sink *v1beta1.ServiceS case source.DeprecatedRelease != nil: if len(source.DeprecatedRelease.Revisions) == 2 { - sink.RouteSpec = v1beta1.RouteSpec{ - Traffic: []v1beta1.TrafficTarget{{ + sink.RouteSpec = v1.RouteSpec{ + Traffic: []v1.TrafficTarget{{ RevisionName: source.DeprecatedRelease.Revisions[0], - Percent: 100 - source.DeprecatedRelease.RolloutPercent, + Percent: ptr.Int64(int64(100 - source.DeprecatedRelease.RolloutPercent)), Tag: "current", }, { RevisionName: source.DeprecatedRelease.Revisions[1], - Percent: source.DeprecatedRelease.RolloutPercent, + Percent: ptr.Int64(int64(source.DeprecatedRelease.RolloutPercent)), Tag: "candidate", }, { - Percent: 0, + Percent: nil, Tag: "latest", LatestRevision: ptr.Bool(true), }}, } } else { - sink.RouteSpec = v1beta1.RouteSpec{ - Traffic: []v1beta1.TrafficTarget{{ + sink.RouteSpec = v1.RouteSpec{ + Traffic: []v1.TrafficTarget{{ RevisionName: source.DeprecatedRelease.Revisions[0], - Percent: 100, + Percent: ptr.Int64(100), Tag: "current", }, { - Percent: 0, + Percent: nil, Tag: "latest", LatestRevision: ptr.Bool(true), }}, @@ -90,10 +97,10 @@ func (source *ServiceSpec) ConvertUp(ctx context.Context, sink *v1beta1.ServiceS return source.DeprecatedRelease.Configuration.ConvertUp(ctx, &sink.ConfigurationSpec) case source.DeprecatedPinned != nil: - sink.RouteSpec = v1beta1.RouteSpec{ - Traffic: []v1beta1.TrafficTarget{{ + sink.RouteSpec = v1.RouteSpec{ + Traffic: []v1.TrafficTarget{{ RevisionName: source.DeprecatedPinned.RevisionName, - Percent: 100, + Percent: ptr.Int64(100), }}, } return source.DeprecatedPinned.Configuration.ConvertUp(ctx, &sink.ConfigurationSpec) @@ -108,7 +115,7 @@ func (source *ServiceSpec) ConvertUp(ctx context.Context, sink *v1beta1.ServiceS } // ConvertUp helps implement apis.Convertible -func (source *ServiceStatus) ConvertUp(ctx context.Context, sink *v1beta1.ServiceStatus) error { +func (source *ServiceStatus) ConvertUp(ctx context.Context, sink *v1.ServiceStatus) error { source.Status.ConvertTo(ctx, &sink.Status) source.RouteStatusFields.ConvertUp(ctx, &sink.RouteStatusFields) @@ -124,19 +131,25 @@ func (sink *Service) ConvertDown(ctx context.Context, obj apis.Convertible) erro return err } return sink.Status.ConvertDown(ctx, source.Status) + case *v1.Service: + sink.ObjectMeta = source.ObjectMeta + if err := sink.Spec.ConvertDown(ctx, source.Spec); err != nil { + return err + } + return sink.Status.ConvertDown(ctx, source.Status) default: return fmt.Errorf("unknown version, got: %T", source) } } // ConvertDown helps implement apis.Convertible -func (sink *ServiceSpec) ConvertDown(ctx context.Context, source v1beta1.ServiceSpec) error { +func (sink *ServiceSpec) ConvertDown(ctx context.Context, source v1.ServiceSpec) error { sink.RouteSpec.ConvertDown(ctx, source.RouteSpec) return sink.ConfigurationSpec.ConvertDown(ctx, source.ConfigurationSpec) } // ConvertDown helps implement apis.Convertible -func (sink *ServiceStatus) ConvertDown(ctx context.Context, source v1beta1.ServiceStatus) error { +func (sink *ServiceStatus) ConvertDown(ctx context.Context, source v1.ServiceStatus) error { source.Status.ConvertTo(ctx, &sink.Status) sink.RouteStatusFields.ConvertDown(ctx, source.RouteStatusFields) diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_defaults.go index 484b45c1e5c..5346bfab75a 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_defaults.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_defaults.go @@ -23,7 +23,7 @@ import ( "knative.dev/pkg/apis" "knative.dev/serving/pkg/apis/serving" - "knative.dev/serving/pkg/apis/serving/v1beta1" + v1 "knative.dev/serving/pkg/apis/serving/v1" ) func (s *Service) SetDefaults(ctx context.Context) { @@ -51,11 +51,11 @@ func (s *Service) SetDefaults(ctx context.Context) { } func (ss *ServiceSpec) SetDefaults(ctx context.Context) { - if v1beta1.IsUpgradeViaDefaulting(ctx) { - beta := v1beta1.ServiceSpec{} - if ss.ConvertUp(ctx, &beta) == nil { + if v1.IsUpgradeViaDefaulting(ctx) { + v1 := v1.ServiceSpec{} + if ss.ConvertUp(ctx, &v1) == nil { alpha := ServiceSpec{} - if alpha.ConvertDown(ctx, beta) == nil { + if alpha.ConvertDown(ctx, v1) == nil { *ss = alpha } } @@ -70,6 +70,6 @@ func (ss *ServiceSpec) SetDefaults(ctx context.Context) { } else if ss.DeprecatedManual != nil { } else { ss.ConfigurationSpec.SetDefaults(ctx) - ss.RouteSpec.SetDefaults(v1beta1.WithDefaultConfigurationName(ctx)) + ss.RouteSpec.SetDefaults(v1.WithDefaultConfigurationName(ctx)) } } diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_lifecycle.go index 76402e6d936..168b5fb4cc8 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_lifecycle.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_lifecycle.go @@ -23,7 +23,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + duckv1 "knative.dev/pkg/apis/duck/v1" ) var serviceCondSet = apis.NewLivingConditionSet( @@ -156,6 +156,6 @@ func (ss *ServiceStatus) PropagateRouteStatus(rs *RouteStatus) { } } -func (ss *ServiceStatus) duck() *duckv1beta1.Status { +func (ss *ServiceStatus) duck() *duckv1.Status { return &ss.Status } diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_types.go index 8f21ff61206..ece0c5f9c6e 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_types.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_types.go @@ -20,7 +20,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/kmeta" ) @@ -176,7 +176,7 @@ const ( // ServiceStatus represents the Status stanza of the Service resource. type ServiceStatus struct { - duckv1beta1.Status `json:",inline"` + duckv1.Status `json:",inline"` RouteStatusFields `json:",inline"` diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_validation.go index f9a0352b434..af4f4c74abc 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_validation.go @@ -25,7 +25,7 @@ import ( "knative.dev/pkg/apis" "knative.dev/serving/pkg/apis/serving" - "knative.dev/serving/pkg/apis/serving/v1beta1" + v1 "knative.dev/serving/pkg/apis/serving/v1" ) // Validate validates the fields belonging to Service @@ -121,7 +121,7 @@ func (ss *ServiceSpec) Validate(ctx context.Context) *apis.FieldError { errs = errs.Also(ss.RouteSpec.Validate( // Within the context of Service, the RouteSpec has a default // configurationName. - v1beta1.WithDefaultConfigurationName(ctx))) + v1.WithDefaultConfigurationName(ctx))) } if len(set) > 1 { diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_defaults.go index 926e3c09dda..5c9808a3794 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_defaults.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_defaults.go @@ -27,8 +27,3 @@ func (c *Configuration) SetDefaults(ctx context.Context) { ctx = apis.WithinParent(ctx, c.ObjectMeta) c.Spec.SetDefaults(apis.WithinSpec(ctx)) } - -// SetDefaults implements apis.Defaultable -func (cs *ConfigurationSpec) SetDefaults(ctx context.Context) { - cs.Template.SetDefaults(ctx) -} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_lifecycle.go index 2a937bfc0aa..b2b1297b82b 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_lifecycle.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_lifecycle.go @@ -16,20 +16,9 @@ limitations under the License. package v1beta1 -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - - "knative.dev/pkg/apis" -) - -var configurationCondSet = apis.NewLivingConditionSet() +import "k8s.io/apimachinery/pkg/runtime/schema" // GetGroupVersionKind returns the GroupVersionKind. func (r *Configuration) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind("Configuration") } - -// IsReady returns if the configuration is ready to serve the requested configuration. -func (cs *ConfigurationStatus) IsReady() bool { - return configurationCondSet.Manage(cs).IsHappy() -} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_types.go index accf0ec6a27..344e43286ae 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_types.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_types.go @@ -19,8 +19,8 @@ package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmeta" + v1 "knative.dev/serving/pkg/apis/serving/v1" ) // +genclient @@ -37,10 +37,10 @@ type Configuration struct { metav1.ObjectMeta `json:"metadata,omitempty"` // +optional - Spec ConfigurationSpec `json:"spec,omitempty"` + Spec v1.ConfigurationSpec `json:"spec,omitempty"` // +optional - Status ConfigurationStatus `json:"status,omitempty"` + Status v1.ConfigurationStatus `json:"status,omitempty"` } // Verify that Configuration adheres to the appropriate interfaces. @@ -56,41 +56,12 @@ var ( _ kmeta.OwnerRefable = (*Configuration)(nil) ) -// ConfigurationSpec holds the desired state of the Configuration (from the client). -type ConfigurationSpec struct { - // Template holds the latest specification for the Revision to be stamped out. - // +optional - Template RevisionTemplateSpec `json:"template"` -} - const ( // ConfigurationConditionReady is set when the configuration's latest // underlying revision has reported readiness. ConfigurationConditionReady = apis.ConditionReady ) -// ConfigurationStatusFields holds the fields of Configuration's status that -// are not generally shared. This is defined separately and inlined so that -// other types can readily consume these fields via duck typing. -type ConfigurationStatusFields struct { - // LatestReadyRevisionName holds the name of the latest Revision stamped out - // from this Configuration that has had its "Ready" condition become "True". - // +optional - LatestReadyRevisionName string `json:"latestReadyRevisionName,omitempty"` - - // LatestCreatedRevisionName is the last revision that was created from this - // Configuration. It might not be ready yet, for that use LatestReadyRevisionName. - // +optional - LatestCreatedRevisionName string `json:"latestCreatedRevisionName,omitempty"` -} - -// ConfigurationStatus communicates the observed state of the Configuration (from the controller). -type ConfigurationStatus struct { - duckv1beta1.Status `json:",inline"` - - ConfigurationStatusFields `json:",inline"` -} - // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // ConfigurationList is a list of Configuration resources diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_validation.go index ff7b62c9c91..98ed1129dda 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_validation.go @@ -51,31 +51,16 @@ func (c *Configuration) Validate(ctx context.Context) (errs *apis.FieldError) { return errs } -// Validate implements apis.Validatable -func (cs *ConfigurationSpec) Validate(ctx context.Context) *apis.FieldError { - return cs.Template.Validate(ctx).ViaField("template") -} - -// Validate implements apis.Validatable -func (cs *ConfigurationStatus) Validate(ctx context.Context) *apis.FieldError { - return cs.ConfigurationStatusFields.Validate(ctx) -} - -// Validate implements apis.Validatable -func (csf *ConfigurationStatusFields) Validate(ctx context.Context) *apis.FieldError { - return nil -} - // validateLabels function validates configuration labels func (c *Configuration) validateLabels() (errs *apis.FieldError) { for key, val := range c.GetLabels() { switch { case key == config.VisibilityLabelKey: - errs = errs.Also(validateClusterVisibilityLabel(val)) + errs = errs.Also(serving.ValidateClusterVisibilityLabel(val)) case key == serving.RouteLabelKey: case key == serving.ServiceLabelKey: errs = errs.Also(verifyLabelOwnerRef(val, serving.ServiceLabelKey, "Service", c.GetOwnerReferences())) - case strings.HasPrefix(key, groupNamePrefix): + case strings.HasPrefix(key, serving.GroupNamePrefix): errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField)) } } diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/register.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/register.go index 7e7b4297d85..1e8d182282a 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/register.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/register.go @@ -24,9 +24,6 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" ) -// GroupNamePrefix is the prefix for label key and annotation key -const groupNamePrefix = serving.GroupName + "/" - // SchemeGroupVersion is group version used to register these objects var SchemeGroupVersion = schema.GroupVersion{Group: serving.GroupName, Version: "v1beta1"} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_defaults.go index 714a5fc61a9..4a00953945c 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_defaults.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_defaults.go @@ -18,80 +18,9 @@ package v1beta1 import ( "context" - - corev1 "k8s.io/api/core/v1" - - "knative.dev/serving/pkg/apis/config" ) // SetDefaults implements apis.Defaultable func (r *Revision) SetDefaults(ctx context.Context) { r.Spec.SetDefaults(ctx) } - -// SetDefaults implements apis.Defaultable -func (rts *RevisionTemplateSpec) SetDefaults(ctx context.Context) { - rts.Spec.SetDefaults(ctx) -} - -// SetDefaults implements apis.Defaultable -func (rs *RevisionSpec) SetDefaults(ctx context.Context) { - cfg := config.FromContextOrDefaults(ctx) - - // Default TimeoutSeconds based on our configmap - if rs.TimeoutSeconds == nil { - ts := cfg.Defaults.RevisionTimeoutSeconds - rs.TimeoutSeconds = &ts - } - - for idx := range rs.PodSpec.Containers { - if rs.PodSpec.Containers[idx].Name == "" { - rs.PodSpec.Containers[idx].Name = cfg.Defaults.UserContainerName(ctx) - } - - if rs.PodSpec.Containers[idx].Resources.Requests == nil { - rs.PodSpec.Containers[idx].Resources.Requests = corev1.ResourceList{} - } - if _, ok := rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceCPU]; !ok { - if rsrc := cfg.Defaults.RevisionCPURequest; rsrc != nil { - rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceCPU] = *rsrc - } - } - if _, ok := rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceMemory]; !ok { - if rsrc := cfg.Defaults.RevisionMemoryRequest; rsrc != nil { - rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceMemory] = *rsrc - } - } - - if rs.PodSpec.Containers[idx].Resources.Limits == nil { - rs.PodSpec.Containers[idx].Resources.Limits = corev1.ResourceList{} - } - if _, ok := rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceCPU]; !ok { - if rsrc := cfg.Defaults.RevisionCPULimit; rsrc != nil { - rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceCPU] = *rsrc - } - } - if _, ok := rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceMemory]; !ok { - if rsrc := cfg.Defaults.RevisionMemoryLimit; rsrc != nil { - rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceMemory] = *rsrc - } - } - if rs.PodSpec.Containers[idx].ReadinessProbe == nil { - rs.PodSpec.Containers[idx].ReadinessProbe = &corev1.Probe{} - } - if rs.PodSpec.Containers[idx].ReadinessProbe.TCPSocket == nil && - rs.PodSpec.Containers[idx].ReadinessProbe.HTTPGet == nil && - rs.PodSpec.Containers[idx].ReadinessProbe.Exec == nil { - rs.PodSpec.Containers[idx].ReadinessProbe.TCPSocket = &corev1.TCPSocketAction{} - } - - if rs.PodSpec.Containers[idx].ReadinessProbe.SuccessThreshold == 0 { - rs.PodSpec.Containers[idx].ReadinessProbe.SuccessThreshold = 1 - } - - vms := rs.PodSpec.Containers[idx].VolumeMounts - for i := range vms { - vms[i].ReadOnly = true - } - } -} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_lifecycle.go index 27672d59304..24f994bccf3 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_lifecycle.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_lifecycle.go @@ -33,8 +33,3 @@ var revisionCondSet = apis.NewLivingConditionSet() func (r *Revision) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind("Revision") } - -// IsReady returns if the revision is ready to serve the requested configuration. -func (rs *RevisionStatus) IsReady() bool { - return revisionCondSet.Manage(rs).IsHappy() -} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_types.go index d6365a4f418..fe72a4471df 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_types.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_types.go @@ -17,11 +17,10 @@ limitations under the License. package v1beta1 import ( - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmeta" + v1 "knative.dev/serving/pkg/apis/serving/v1" ) // +genclient @@ -38,10 +37,10 @@ type Revision struct { metav1.ObjectMeta `json:"metadata,omitempty"` // +optional - Spec RevisionSpec `json:"spec,omitempty"` + Spec v1.RevisionSpec `json:"spec,omitempty"` // +optional - Status RevisionStatus `json:"status,omitempty"` + Status v1.RevisionStatus `json:"status,omitempty"` } // Verify that Revision adheres to the appropriate interfaces. @@ -57,73 +56,12 @@ var ( _ kmeta.OwnerRefable = (*Revision)(nil) ) -// RevisionTemplateSpec describes the data a revision should have when created from a template. -// Based on: https://github.com/kubernetes/api/blob/e771f807/core/v1/types.go#L3179-L3190 -type RevisionTemplateSpec struct { - // +optional - metav1.ObjectMeta `json:"metadata,omitempty"` - - // +optional - Spec RevisionSpec `json:"spec,omitempty"` -} - -// RevisionContainerConcurrencyType is an integer expressing the maximum number of -// in-flight (concurrent) requests. -type RevisionContainerConcurrencyType int64 - -const ( - // RevisionContainerConcurrencyMax is the maximum configurable - // container concurrency. - RevisionContainerConcurrencyMax RevisionContainerConcurrencyType = 1000 -) - -// RevisionSpec holds the desired state of the Revision (from the client). -type RevisionSpec struct { - corev1.PodSpec `json:",inline"` - - // ContainerConcurrency specifies the maximum allowed in-flight (concurrent) - // requests per container of the Revision. Defaults to `0` which means - // concurrency to the application is not limited, and the system decides the - // target concurrency for the autoscaler. - // +optional - ContainerConcurrency RevisionContainerConcurrencyType `json:"containerConcurrency,omitempty"` - - // TimeoutSeconds holds the max duration the instance is allowed for - // responding to a request. If unspecified, a system default will - // be provided. - // +optional - TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"` -} - const ( // RevisionConditionReady is set when the revision is starting to materialize // runtime resources, and becomes true when those resources are ready. RevisionConditionReady = apis.ConditionReady ) -// RevisionStatus communicates the observed state of the Revision (from the controller). -type RevisionStatus struct { - duckv1beta1.Status `json:",inline"` - - // ServiceName holds the name of a core Kubernetes Service resource that - // load balances over the pods backing this Revision. - // +optional - ServiceName string `json:"serviceName,omitempty"` - - // LogURL specifies the generated logging url for this particular revision - // based on the revision url template specified in the controller's config. - // +optional - LogURL string `json:"logUrl,omitempty"` - - // ImageDigest holds the resolved digest for the image specified - // within .Spec.Container.Image. The digest is resolved during the creation - // of Revision. This field holds the digest value regardless of whether - // a tag or digest was originally specified in the Container object. It - // may be empty if the image comes from a registry listed to skip resolution. - // +optional - ImageDigest string `json:"imageDigest,omitempty"` -} - // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // RevisionList is a list of Revision resources diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_validation.go index 56056f2225f..43fe2f6f266 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_validation.go @@ -18,12 +18,10 @@ package v1beta1 import ( "context" - "fmt" "strings" "knative.dev/pkg/apis" "knative.dev/pkg/kmp" - "knative.dev/serving/pkg/apis/autoscaling" "knative.dev/serving/pkg/apis/serving" ) @@ -55,87 +53,6 @@ func (r *Revision) Validate(ctx context.Context) *apis.FieldError { return errs } -// Validate implements apis.Validatable -func (rts *RevisionTemplateSpec) Validate(ctx context.Context) *apis.FieldError { - errs := rts.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec") - errs = errs.Also(autoscaling.ValidateAnnotations(rts.GetAnnotations()).ViaField("metadata.annotations")) - - // If the RevisionTemplateSpec has a name specified, then check that - // it follows the requirements on the name. - if rts.Name != "" { - var prefix string - if om := apis.ParentMeta(ctx); om.Name == "" { - prefix = om.GenerateName - } else { - prefix = om.Name + "-" - } - - if !strings.HasPrefix(rts.Name, prefix) { - errs = errs.Also(apis.ErrInvalidValue( - fmt.Sprintf("%q must have prefix %q", rts.Name, prefix), - "metadata.name")) - } - } - - errs = errs.Also(serving.ValidateQueueSidecarAnnotation(rts.Annotations).ViaField("metadata.annotations")) - return errs -} - -// VerifyNameChange checks that if a user brought their own name previously that it -// changes at the appropriate times. -func (current *RevisionTemplateSpec) VerifyNameChange(ctx context.Context, og RevisionTemplateSpec) *apis.FieldError { - if current.Name == "" { - // We only check that Name changes when the RevisionTemplate changes. - return nil - } - if current.Name != og.Name { - // The name changed, so we're good. - return nil - } - - if diff, err := kmp.ShortDiff(&og, current); err != nil { - return &apis.FieldError{ - Message: "Failed to diff RevisionTemplate", - Paths: []string{apis.CurrentField}, - Details: err.Error(), - } - } else if diff != "" { - return &apis.FieldError{ - Message: "Saw the following changes without a name change (-old +new)", - Paths: []string{apis.CurrentField}, - Details: diff, - } - } - return nil -} - -// Validate implements apis.Validatable -func (rs *RevisionSpec) Validate(ctx context.Context) *apis.FieldError { - errs := rs.ContainerConcurrency.Validate(ctx).ViaField("containerConcurrency") - - errs = errs.Also(serving.ValidatePodSpec(rs.PodSpec)) - - if rs.TimeoutSeconds != nil { - errs = errs.Also(serving.ValidateTimeoutSeconds(ctx, *rs.TimeoutSeconds)) - } - - return errs -} - -// Validate implements apis.Validatable. -func (cc RevisionContainerConcurrencyType) Validate(ctx context.Context) *apis.FieldError { - if cc < 0 || cc > RevisionContainerConcurrencyMax { - return apis.ErrOutOfBoundsValue( - cc, 0, RevisionContainerConcurrencyMax, apis.CurrentField) - } - return nil -} - -// Validate implements apis.Validatable -func (rs *RevisionStatus) Validate(ctx context.Context) *apis.FieldError { - return nil -} - // ValidateLabels function validates service labels func (r *Revision) ValidateLabels() (errs *apis.FieldError) { for key, val := range r.GetLabels() { @@ -143,7 +60,7 @@ func (r *Revision) ValidateLabels() (errs *apis.FieldError) { case key == serving.RouteLabelKey || key == serving.ServiceLabelKey || key == serving.ConfigurationGenerationLabelKey: case key == serving.ConfigurationLabelKey: errs = errs.Also(verifyLabelOwnerRef(val, serving.ConfigurationLabelKey, "Configuration", r.GetOwnerReferences())) - case strings.HasPrefix(key, groupNamePrefix): + case strings.HasPrefix(key, serving.GroupNamePrefix): errs = errs.Also(apis.ErrInvalidKeyName(key, "")) } } diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_defaults.go index abb58c74e5c..8f793619f4f 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_defaults.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_defaults.go @@ -20,32 +20,9 @@ import ( "context" "knative.dev/pkg/apis" - "knative.dev/pkg/ptr" ) // SetDefaults implements apis.Defaultable func (r *Route) SetDefaults(ctx context.Context) { r.Spec.SetDefaults(apis.WithinSpec(ctx)) } - -// SetDefaults implements apis.Defaultable -func (rs *RouteSpec) SetDefaults(ctx context.Context) { - if len(rs.Traffic) == 0 && HasDefaultConfigurationName(ctx) { - rs.Traffic = []TrafficTarget{{ - Percent: 100, - LatestRevision: ptr.Bool(true), - }} - } - - for idx := range rs.Traffic { - rs.Traffic[idx].SetDefaults(ctx) - } -} - -// SetDefaults implements apis.Defaultable -func (tt *TrafficTarget) SetDefaults(ctx context.Context) { - if tt.LatestRevision == nil { - sense := (tt.RevisionName == "") - tt.LatestRevision = &sense - } -} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_lifecycle.go index ff505611135..f4b93117da8 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_lifecycle.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_lifecycle.go @@ -16,20 +16,9 @@ limitations under the License. package v1beta1 -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - - "knative.dev/pkg/apis" -) - -var routeCondSet = apis.NewLivingConditionSet() +import "k8s.io/apimachinery/pkg/runtime/schema" // GetGroupVersionKind returns the GroupVersionKind. func (r *Route) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind("Route") } - -// IsReady returns if the route is ready to serve the requested configuration. -func (rs *RouteStatus) IsReady() bool { - return routeCondSet.Manage(rs).IsHappy() -} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_types.go index c988fbaa71c..800ed30e515 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_types.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_types.go @@ -20,8 +20,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmeta" + v1 "knative.dev/serving/pkg/apis/serving/v1" ) // +genclient @@ -40,11 +40,11 @@ type Route struct { // Spec holds the desired state of the Route (from the client). // +optional - Spec RouteSpec `json:"spec,omitempty"` + Spec v1.RouteSpec `json:"spec,omitempty"` // Status communicates the observed state of the Route (from the controller). // +optional - Status RouteStatus `json:"status,omitempty"` + Status v1.RouteStatus `json:"status,omitempty"` } // Verify that Route adheres to the appropriate interfaces. @@ -60,89 +60,12 @@ var ( _ kmeta.OwnerRefable = (*Route)(nil) ) -// TrafficTarget holds a single entry of the routing table for a Route. -type TrafficTarget struct { - // Tag is optionally used to expose a dedicated url for referencing - // this target exclusively. - // +optional - // TODO(mattmoor): Discuss alternative naming options. - Tag string `json:"tag,omitempty"` - - // RevisionName of a specific revision to which to send this portion of - // traffic. This is mutually exclusive with ConfigurationName. - // +optional - RevisionName string `json:"revisionName,omitempty"` - - // ConfigurationName of a configuration to whose latest revision we will send - // this portion of traffic. When the "status.latestReadyRevisionName" of the - // referenced configuration changes, we will automatically migrate traffic - // from the prior "latest ready" revision to the new one. This field is never - // set in Route's status, only its spec. This is mutually exclusive with - // RevisionName. - // +optional - ConfigurationName string `json:"configurationName,omitempty"` - - // LatestRevision may be optionally provided to indicate that the latest - // ready Revision of the Configuration should be used for this traffic - // target. When provided LatestRevision must be true if RevisionName is - // empty; it must be false when RevisionName is non-empty. - // +optional - LatestRevision *bool `json:"latestRevision,omitempty"` - - // Percent specifies percent of the traffic to this Revision or Configuration. - // This defaults to zero if unspecified. - // +optional - Percent int `json:"percent"` - - // URL displays the URL for accessing named traffic targets. URL is displayed in - // status, and is disallowed on spec. URL must contain a scheme (e.g. http://) and - // a hostname, but may not contain anything else (e.g. basic auth, url path, etc.) - // +optional - URL *apis.URL `json:"url,omitempty"` -} - -// RouteSpec holds the desired state of the Route (from the client). -type RouteSpec struct { - // Traffic specifies how to distribute traffic over a collection of - // revisions and configurations. - // +optional - Traffic []TrafficTarget `json:"traffic,omitempty"` -} - const ( // RouteConditionReady is set when the service is configured // and has available backends ready to receive traffic. RouteConditionReady = apis.ConditionReady ) -// RouteStatusFields holds the fields of Route's status that -// are not generally shared. This is defined separately and inlined so that -// other types can readily consume these fields via duck typing. -type RouteStatusFields struct { - // URL holds the url that will distribute traffic over the provided traffic targets. - // It generally has the form http[s]://{route-name}.{route-namespace}.{cluster-level-suffix} - // +optional - URL *apis.URL `json:"url,omitempty"` - - // Address holds the information needed for a Route to be the target of an event. - // +optional - Address *duckv1beta1.Addressable `json:"address,omitempty"` - - // Traffic holds the configured traffic distribution. - // These entries will always contain RevisionName references. - // When ConfigurationName appears in the spec, this will hold the - // LatestReadyRevisionName that we last observed. - // +optional - Traffic []TrafficTarget `json:"traffic,omitempty"` -} - -// RouteStatus communicates the observed state of the Route (from the controller). -type RouteStatus struct { - duckv1beta1.Status `json:",inline"` - - RouteStatusFields `json:",inline"` -} - // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // RouteList is a list of Route resources diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_validation.go index 72da2fab867..2dde0fc8b45 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_validation.go @@ -18,10 +18,8 @@ package v1beta1 import ( "context" - "fmt" "strings" - "k8s.io/apimachinery/pkg/util/validation" "knative.dev/pkg/apis" "knative.dev/serving/pkg/apis/serving" "knative.dev/serving/pkg/reconciler/route/config" @@ -36,172 +34,15 @@ func (r *Route) Validate(ctx context.Context) *apis.FieldError { return errs } -func validateTrafficList(ctx context.Context, traffic []TrafficTarget) *apis.FieldError { - var errs *apis.FieldError - - // Track the targets of named TrafficTarget entries (to detect duplicates). - trafficMap := make(map[string]int) - - sum := 0 - for i, tt := range traffic { - errs = errs.Also(tt.Validate(ctx).ViaIndex(i)) - - if idx, ok := trafficMap[tt.Tag]; ok { - // We want only single definition of the route, even if it points - // to the same config or revision. - errs = errs.Also(&apis.FieldError{ - Message: fmt.Sprintf("Multiple definitions for %q", tt.Tag), - Paths: []string{ - fmt.Sprintf("[%d].tag", i), - fmt.Sprintf("[%d].tag", idx), - }, - }) - } else { - trafficMap[tt.Tag] = i - } - sum += tt.Percent - } - - if sum != 100 { - errs = errs.Also(&apis.FieldError{ - Message: fmt.Sprintf("Traffic targets sum to %d, want 100", sum), - Paths: []string{apis.CurrentField}, - }) - } - return errs -} - -// Validate implements apis.Validatable -func (rs *RouteSpec) Validate(ctx context.Context) *apis.FieldError { - return validateTrafficList(ctx, rs.Traffic).ViaField("traffic") -} - -// Validate verifies that TrafficTarget is properly configured. -func (tt *TrafficTarget) Validate(ctx context.Context) *apis.FieldError { - errs := tt.validateLatestRevision(ctx) - errs = tt.validateRevisionAndConfiguration(ctx, errs) - errs = tt.validateTrafficPercentage(errs) - return tt.validateUrl(ctx, errs) -} - -func (tt *TrafficTarget) validateRevisionAndConfiguration(ctx context.Context, errs *apis.FieldError) *apis.FieldError { - // We only validate the sense of latestRevision in the context of a Spec, - // and only when it is specified. - switch { - // When we have a default configurationName, we don't - // allow one to be specified. - case HasDefaultConfigurationName(ctx) && tt.ConfigurationName != "": - errs = errs.Also(apis.ErrDisallowedFields("configurationName")) - - // Both revisionName and configurationName are never allowed to - // appear concurrently. - case tt.RevisionName != "" && tt.ConfigurationName != "": - errs = errs.Also(apis.ErrMultipleOneOf( - "revisionName", "configurationName")) - - // When a revisionName appears, we must check that the name is valid. - case tt.RevisionName != "": - if el := validation.IsQualifiedName(tt.RevisionName); len(el) > 0 { - errs = errs.Also(apis.ErrInvalidKeyName( - tt.RevisionName, "revisionName", el...)) - } - - // When revisionName is missing in Status report an error. - case apis.IsInStatus(ctx): - errs = errs.Also(apis.ErrMissingField("revisionName")) - - // When configurationName is specified, we must check that the name is valid. - case tt.ConfigurationName != "": - if el := validation.IsQualifiedName(tt.ConfigurationName); len(el) > 0 { - errs = errs.Also(apis.ErrInvalidKeyName( - tt.ConfigurationName, "configurationName", el...)) - } - - // When we are using a default configurationName, it must be a valid name already. - case HasDefaultConfigurationName(ctx): - - // All other cases are missing one of revisionName or configurationName. - default: - errs = errs.Also(apis.ErrMissingOneOf( - "revisionName", "configurationName")) - } - return errs -} - -func (tt *TrafficTarget) validateTrafficPercentage(errs *apis.FieldError) *apis.FieldError { - // Check that the traffic Percentage is within bounds. - if tt.Percent < 0 || tt.Percent > 100 { - errs = errs.Also(apis.ErrOutOfBoundsValue( - tt.Percent, 0, 100, "percent")) - } - return errs -} - -func (tt *TrafficTarget) validateLatestRevision(ctx context.Context) *apis.FieldError { - if apis.IsInSpec(ctx) && tt.LatestRevision != nil { - lr := *tt.LatestRevision - pinned := tt.RevisionName != "" - if pinned == lr { - // The senses for whether to pin to a particular revision or - // float forward to the latest revision must match. - return apis.ErrInvalidValue(lr, "latestRevision") - } - } - return nil -} - -func (tt *TrafficTarget) validateUrl(ctx context.Context, errs *apis.FieldError) *apis.FieldError { - // Check that we set the URL appropriately. - if tt.URL.String() != "" { - // URL is not allowed in traffic under spec. - if apis.IsInSpec(ctx) { - errs = errs.Also(apis.ErrDisallowedFields("url")) - } - - // URL is not allowed in any traffic target without a name. - if tt.Tag == "" { - errs = errs.Also(apis.ErrDisallowedFields("url")) - } - } else if tt.Tag != "" { - // URL must be specified in status when name is specified. - if apis.IsInStatus(ctx) { - errs = errs.Also(apis.ErrMissingField("url")) - } - } - return errs -} - -// Validate implements apis.Validatable. -func (rs *RouteStatus) Validate(ctx context.Context) *apis.FieldError { - return rs.RouteStatusFields.Validate(ctx) -} - -// Validate implements apis.Validatable. -func (rsf *RouteStatusFields) Validate(ctx context.Context) *apis.FieldError { - // TODO(mattmoor): Validate other status fields. - - if len(rsf.Traffic) != 0 { - return validateTrafficList(ctx, rsf.Traffic).ViaField("traffic") - } - return nil -} - -func validateClusterVisibilityLabel(label string) (errs *apis.FieldError) { - if label != config.VisibilityClusterLocal { - errs = apis.ErrInvalidValue(label, config.VisibilityLabelKey) - } - return -} - // validateLabels function validates route labels. func (r *Route) validateLabels() (errs *apis.FieldError) { for key, val := range r.GetLabels() { switch { case key == config.VisibilityLabelKey: - errs = errs.Also(validateClusterVisibilityLabel(val)) + errs = errs.Also(serving.ValidateClusterVisibilityLabel(val)) case key == serving.ServiceLabelKey: errs = errs.Also(verifyLabelOwnerRef(val, serving.ServiceLabelKey, "Service", r.GetOwnerReferences())) - case strings.HasPrefix(key, groupNamePrefix): + case strings.HasPrefix(key, serving.GroupNamePrefix): errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField)) } } diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_defaults.go index 09af86568f2..e05d1ca8141 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_defaults.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_defaults.go @@ -49,9 +49,3 @@ func (s *Service) SetDefaults(ctx context.Context) { } } } - -// SetDefaults implements apis.Defaultable -func (ss *ServiceSpec) SetDefaults(ctx context.Context) { - ss.ConfigurationSpec.SetDefaults(ctx) - ss.RouteSpec.SetDefaults(WithDefaultConfigurationName(ctx)) -} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_lifecycle.go index 5168d911167..ad59308fcd0 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_lifecycle.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_lifecycle.go @@ -16,20 +16,9 @@ limitations under the License. package v1beta1 -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - - "knative.dev/pkg/apis" -) - -var serviceCondSet = apis.NewLivingConditionSet() +import "k8s.io/apimachinery/pkg/runtime/schema" // GetGroupVersionKind returns the GroupVersionKind. func (s *Service) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind("Service") } - -// IsReady returns if the service is ready to serve the requested configuration. -func (ss *ServiceStatus) IsReady() bool { - return serviceCondSet.Manage(ss).IsHappy() -} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_types.go index ba6d2248bb2..332ee83b362 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_types.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_types.go @@ -20,8 +20,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmeta" + v1 "knative.dev/serving/pkg/apis/serving/v1" ) // +genclient @@ -45,10 +45,10 @@ type Service struct { metav1.ObjectMeta `json:"metadata,omitempty"` // +optional - Spec ServiceSpec `json:"spec,omitempty"` + Spec v1.ServiceSpec `json:"spec,omitempty"` // +optional - Status ServiceStatus `json:"status,omitempty"` + Status v1.ServiceStatus `json:"status,omitempty"` } // Verify that Service adheres to the appropriate interfaces. @@ -64,24 +64,6 @@ var ( _ kmeta.OwnerRefable = (*Service)(nil) ) -// ServiceSpec represents the configuration for the Service object. -// A Service's specification is the union of the specifications for a Route -// and Configuration. The Service restricts what can be expressed in these -// fields, e.g. the Route must reference the provided Configuration; -// however, these limitations also enable friendlier defaulting, -// e.g. Route never needs a Configuration name, and may be defaulted to -// the appropriate "run latest" spec. -type ServiceSpec struct { - // ServiceSpec inlines an unrestricted ConfigurationSpec. - ConfigurationSpec `json:",inline"` - - // ServiceSpec inlines RouteSpec and restricts/defaults its fields - // via webhook. In particular, this spec can only reference this - // Service's configuration and revisions (which also influences - // defaults). - RouteSpec `json:",inline"` -} - // ConditionType represents a Service condition value const ( // ServiceConditionReady is set when the service is configured @@ -89,19 +71,6 @@ const ( ServiceConditionReady = apis.ConditionReady ) -// ServiceStatus represents the Status stanza of the Service resource. -type ServiceStatus struct { - duckv1beta1.Status `json:",inline"` - - // In addition to inlining ConfigurationSpec, we also inline the fields - // specific to ConfigurationStatus. - ConfigurationStatusFields `json:",inline"` - - // In addition to inlining RouteSpec, we also inline the fields - // specific to RouteStatus. - RouteStatusFields `json:",inline"` -} - // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // ServiceList is a list of Service resources diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_validation.go index 8b103e5cd03..6daced418ca 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_validation.go @@ -51,27 +51,13 @@ func (s *Service) Validate(ctx context.Context) (errs *apis.FieldError) { return errs } -// Validate implements apis.Validatable -func (ss *ServiceSpec) Validate(ctx context.Context) *apis.FieldError { - return ss.ConfigurationSpec.Validate(ctx).Also( - // Within the context of Service, the RouteSpec has a default - // configurationName. - ss.RouteSpec.Validate(WithDefaultConfigurationName(ctx))) -} - -// Validate implements apis.Validatable -func (ss *ServiceStatus) Validate(ctx context.Context) *apis.FieldError { - return ss.ConfigurationStatusFields.Validate(ctx).Also( - ss.RouteStatusFields.Validate(ctx)) -} - // validateLabels function validates service labels func (s *Service) validateLabels() (errs *apis.FieldError) { for key, val := range s.GetLabels() { switch { case key == config.VisibilityLabelKey: - errs = errs.Also(validateClusterVisibilityLabel(val)) - case strings.HasPrefix(key, groupNamePrefix): + errs = errs.Also(serving.ValidateClusterVisibilityLabel(val)) + case strings.HasPrefix(key, serving.GroupNamePrefix): errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField)) } } diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go index c07bd927fb0..4c6ac4637d6 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go @@ -22,8 +22,6 @@ package v1beta1 import ( runtime "k8s.io/apimachinery/pkg/runtime" - apis "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -87,57 +85,6 @@ func (in *ConfigurationList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ConfigurationSpec) DeepCopyInto(out *ConfigurationSpec) { - *out = *in - in.Template.DeepCopyInto(&out.Template) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationSpec. -func (in *ConfigurationSpec) DeepCopy() *ConfigurationSpec { - if in == nil { - return nil - } - out := new(ConfigurationSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ConfigurationStatus) DeepCopyInto(out *ConfigurationStatus) { - *out = *in - in.Status.DeepCopyInto(&out.Status) - out.ConfigurationStatusFields = in.ConfigurationStatusFields - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationStatus. -func (in *ConfigurationStatus) DeepCopy() *ConfigurationStatus { - if in == nil { - return nil - } - out := new(ConfigurationStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ConfigurationStatusFields) DeepCopyInto(out *ConfigurationStatusFields) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationStatusFields. -func (in *ConfigurationStatusFields) DeepCopy() *ConfigurationStatusFields { - if in == nil { - return nil - } - out := new(ConfigurationStatusFields) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Revision) DeepCopyInto(out *Revision) { *out = *in @@ -199,63 +146,6 @@ func (in *RevisionList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RevisionSpec) DeepCopyInto(out *RevisionSpec) { - *out = *in - in.PodSpec.DeepCopyInto(&out.PodSpec) - if in.TimeoutSeconds != nil { - in, out := &in.TimeoutSeconds, &out.TimeoutSeconds - *out = new(int64) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionSpec. -func (in *RevisionSpec) DeepCopy() *RevisionSpec { - if in == nil { - return nil - } - out := new(RevisionSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RevisionStatus) DeepCopyInto(out *RevisionStatus) { - *out = *in - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionStatus. -func (in *RevisionStatus) DeepCopy() *RevisionStatus { - if in == nil { - return nil - } - out := new(RevisionStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RevisionTemplateSpec) DeepCopyInto(out *RevisionTemplateSpec) { - *out = *in - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionTemplateSpec. -func (in *RevisionTemplateSpec) DeepCopy() *RevisionTemplateSpec { - if in == nil { - return nil - } - out := new(RevisionTemplateSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Route) DeepCopyInto(out *Route) { *out = *in @@ -317,80 +207,6 @@ func (in *RouteList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RouteSpec) DeepCopyInto(out *RouteSpec) { - *out = *in - if in.Traffic != nil { - in, out := &in.Traffic, &out.Traffic - *out = make([]TrafficTarget, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteSpec. -func (in *RouteSpec) DeepCopy() *RouteSpec { - if in == nil { - return nil - } - out := new(RouteSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RouteStatus) DeepCopyInto(out *RouteStatus) { - *out = *in - in.Status.DeepCopyInto(&out.Status) - in.RouteStatusFields.DeepCopyInto(&out.RouteStatusFields) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteStatus. -func (in *RouteStatus) DeepCopy() *RouteStatus { - if in == nil { - return nil - } - out := new(RouteStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RouteStatusFields) DeepCopyInto(out *RouteStatusFields) { - *out = *in - if in.URL != nil { - in, out := &in.URL, &out.URL - *out = new(apis.URL) - (*in).DeepCopyInto(*out) - } - if in.Address != nil { - in, out := &in.Address, &out.Address - *out = new(duckv1beta1.Addressable) - (*in).DeepCopyInto(*out) - } - if in.Traffic != nil { - in, out := &in.Traffic, &out.Traffic - *out = make([]TrafficTarget, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteStatusFields. -func (in *RouteStatusFields) DeepCopy() *RouteStatusFields { - if in == nil { - return nil - } - out := new(RouteStatusFields) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Service) DeepCopyInto(out *Service) { *out = *in @@ -451,66 +267,3 @@ func (in *ServiceList) DeepCopyObject() runtime.Object { } return nil } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) { - *out = *in - in.ConfigurationSpec.DeepCopyInto(&out.ConfigurationSpec) - in.RouteSpec.DeepCopyInto(&out.RouteSpec) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceSpec. -func (in *ServiceSpec) DeepCopy() *ServiceSpec { - if in == nil { - return nil - } - out := new(ServiceSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ServiceStatus) DeepCopyInto(out *ServiceStatus) { - *out = *in - in.Status.DeepCopyInto(&out.Status) - out.ConfigurationStatusFields = in.ConfigurationStatusFields - in.RouteStatusFields.DeepCopyInto(&out.RouteStatusFields) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceStatus. -func (in *ServiceStatus) DeepCopy() *ServiceStatus { - if in == nil { - return nil - } - out := new(ServiceStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TrafficTarget) DeepCopyInto(out *TrafficTarget) { - *out = *in - if in.LatestRevision != nil { - in, out := &in.LatestRevision, &out.LatestRevision - *out = new(bool) - **out = **in - } - if in.URL != nil { - in, out := &in.URL, &out.URL - *out = new(apis.URL) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficTarget. -func (in *TrafficTarget) DeepCopy() *TrafficTarget { - if in == nil { - return nil - } - out := new(TrafficTarget) - in.DeepCopyInto(out) - return out -} diff --git a/vendor/knative.dev/serving/pkg/logging/testdata/test-config-logging.yaml b/vendor/knative.dev/serving/pkg/logging/testdata/test-config-logging.yaml new file mode 120000 index 00000000000..761fc5070b2 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/logging/testdata/test-config-logging.yaml @@ -0,0 +1 @@ +../../../test/config/config-logging.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/network/error_handler.go b/vendor/knative.dev/serving/pkg/network/error_handler.go new file mode 100644 index 00000000000..486518b966d --- /dev/null +++ b/vendor/knative.dev/serving/pkg/network/error_handler.go @@ -0,0 +1,43 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package network + +import ( + "io/ioutil" + "net/http" + + "go.uber.org/zap" +) + +// ErrorHandler sets up a handler suitable for use with the ErrorHandler field on +// httputil's reverse proxy. +func ErrorHandler(logger *zap.SugaredLogger) func(http.ResponseWriter, *http.Request, error) { + return func(w http.ResponseWriter, req *http.Request, err error) { + ss := readSockStat(logger) + logger.Errorw("error reverse proxying request; sockstat: "+ss, zap.Error(err)) + http.Error(w, err.Error(), http.StatusBadGateway) + } +} + +func readSockStat(logger *zap.SugaredLogger) string { + b, err := ioutil.ReadFile("/proc/net/sockstat") + if err != nil { + logger.Errorw("Unable to read sockstat", zap.Error(err)) + return "" + } + return string(b) +} diff --git a/vendor/knative.dev/serving/pkg/network/network.go b/vendor/knative.dev/serving/pkg/network/network.go index 05fa4fe0edc..3e8d24e8f74 100644 --- a/vendor/knative.dev/serving/pkg/network/network.go +++ b/vendor/knative.dev/serving/pkg/network/network.go @@ -42,6 +42,10 @@ const ( // uses to mark requests going through it. ProxyHeaderName = "K-Proxy-Request" + // HashHeaderName is the name of an internal header that Ingress controller + // uses to find out which version of the networking config is deployed. + HashHeaderName = "K-Network-Hash" + // OriginalHostHeader is used to avoid Istio host based routing rules // in Activator. // The header contains the original Host value that can be rewritten diff --git a/vendor/knative.dev/serving/pkg/network/probe_handler.go b/vendor/knative.dev/serving/pkg/network/probe_handler.go new file mode 100644 index 00000000000..be88b574868 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/network/probe_handler.go @@ -0,0 +1,52 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package network + +import ( + "fmt" + "net/http" +) + +// ProbeHeaderValue is the value used in 'K-Network-Probe' +var ProbeHeaderValue = "probe" + +type handler struct { + next http.Handler +} + +// NewProbeHandler wraps a HTTP handler handling probing requests around the provided HTTP handler +func NewProbeHandler(next http.Handler) http.Handler { + return &handler{next: next} +} + +// ServeHTTP handles probing requests +func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if ph := r.Header.Get(ProbeHeaderName); ph != ProbeHeaderValue { + r.Header.Del(HashHeaderName) + h.next.ServeHTTP(w, r) + return + } + + hh := r.Header.Get(HashHeaderName) + if hh == "" { + http.Error(w, fmt.Sprintf("a probe request must contain a non-empty %q header", HashHeaderName), http.StatusBadRequest) + return + } + + w.Header().Set(HashHeaderName, hh) + w.WriteHeader(200) +} diff --git a/vendor/knative.dev/serving/pkg/network/transports.go b/vendor/knative.dev/serving/pkg/network/transports.go index 88d1f142d5c..791cdf913aa 100644 --- a/vendor/knative.dev/serving/pkg/network/transports.go +++ b/vendor/knative.dev/serving/pkg/network/transports.go @@ -104,13 +104,17 @@ func newHTTPTransport(connTimeout time.Duration, disableKeepAlives bool) http.Ro // NewProberTransport creates a RoundTripper that is useful for probing, // since it will not cache connections. func NewProberTransport() http.RoundTripper { - return newAutoTransport(newHTTPTransport(DefaultConnTimeout, true /*disable keep-alives*/), NewH2CTransport()) + return newAutoTransport( + newHTTPTransport(DefaultConnTimeout, true /*disable keep-alives*/), + NewH2CTransport()) } // NewAutoTransport creates a RoundTripper that can use appropriate transport // based on the request's HTTP version. func NewAutoTransport() http.RoundTripper { - return newAutoTransport(newHTTPTransport(DefaultConnTimeout, false /*disable keep-alives*/), NewH2CTransport()) + return newAutoTransport( + newHTTPTransport(DefaultConnTimeout, false /*disable keep-alives*/), + NewH2CTransport()) } // AutoTransport uses h2c for HTTP2 requests and falls back to `http.DefaultTransport` for all others diff --git a/vendor/knative.dev/serving/pkg/reconciler/configuration/config/testdata/config-gc.yaml b/vendor/knative.dev/serving/pkg/reconciler/gc/config/testdata/config-gc.yaml similarity index 100% rename from vendor/knative.dev/serving/pkg/reconciler/configuration/config/testdata/config-gc.yaml rename to vendor/knative.dev/serving/pkg/reconciler/gc/config/testdata/config-gc.yaml diff --git a/vendor/knative.dev/serving/pkg/reconciler/route/config/domain.go b/vendor/knative.dev/serving/pkg/reconciler/route/config/domain.go index a7d5cd1d77c..3863a1311f4 100644 --- a/vendor/knative.dev/serving/pkg/reconciler/route/config/domain.go +++ b/vendor/knative.dev/serving/pkg/reconciler/route/config/domain.go @@ -22,7 +22,7 @@ import ( "github.com/ghodss/yaml" corev1 "k8s.io/api/core/v1" "knative.dev/pkg/configmap" - "knative.dev/serving/pkg/network" + "knative.dev/pkg/network" ) const ( diff --git a/vendor/knative.dev/serving/test/performance/dataplane-probe/kodata/HEAD b/vendor/knative.dev/serving/test/performance/dataplane-probe/kodata/HEAD new file mode 120000 index 00000000000..481bd4eff49 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/dataplane-probe/kodata/HEAD @@ -0,0 +1 @@ +../../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/dataplane-probe/kodata/dev.config b/vendor/knative.dev/serving/test/performance/dataplane-probe/kodata/dev.config new file mode 120000 index 00000000000..493b8a816f8 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/dataplane-probe/kodata/dev.config @@ -0,0 +1 @@ +../dev.config \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/dataplane-probe/kodata/prod.config b/vendor/knative.dev/serving/test/performance/dataplane-probe/kodata/prod.config new file mode 120000 index 00000000000..6115d5c8651 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/dataplane-probe/kodata/prod.config @@ -0,0 +1 @@ +../prod.config \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/dataplane-probe/kodata/refs b/vendor/knative.dev/serving/test/performance/dataplane-probe/kodata/refs new file mode 120000 index 00000000000..fe164fe40f7 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/dataplane-probe/kodata/refs @@ -0,0 +1 @@ +../../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/deployment-probe/kodata/HEAD b/vendor/knative.dev/serving/test/performance/deployment-probe/kodata/HEAD new file mode 120000 index 00000000000..481bd4eff49 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/deployment-probe/kodata/HEAD @@ -0,0 +1 @@ +../../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/deployment-probe/kodata/dev.config b/vendor/knative.dev/serving/test/performance/deployment-probe/kodata/dev.config new file mode 120000 index 00000000000..493b8a816f8 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/deployment-probe/kodata/dev.config @@ -0,0 +1 @@ +../dev.config \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/deployment-probe/kodata/prod.config b/vendor/knative.dev/serving/test/performance/deployment-probe/kodata/prod.config new file mode 120000 index 00000000000..6115d5c8651 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/deployment-probe/kodata/prod.config @@ -0,0 +1 @@ +../prod.config \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/deployment-probe/kodata/refs b/vendor/knative.dev/serving/test/performance/deployment-probe/kodata/refs new file mode 120000 index 00000000000..fe164fe40f7 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/deployment-probe/kodata/refs @@ -0,0 +1 @@ +../../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/load-test/kodata/HEAD b/vendor/knative.dev/serving/test/performance/load-test/kodata/HEAD new file mode 120000 index 00000000000..481bd4eff49 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/load-test/kodata/HEAD @@ -0,0 +1 @@ +../../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/load-test/kodata/dev.config b/vendor/knative.dev/serving/test/performance/load-test/kodata/dev.config new file mode 120000 index 00000000000..493b8a816f8 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/load-test/kodata/dev.config @@ -0,0 +1 @@ +../dev.config \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/load-test/kodata/prod.config b/vendor/knative.dev/serving/test/performance/load-test/kodata/prod.config new file mode 120000 index 00000000000..6115d5c8651 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/load-test/kodata/prod.config @@ -0,0 +1 @@ +../prod.config \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/load-test/kodata/refs b/vendor/knative.dev/serving/test/performance/load-test/kodata/refs new file mode 120000 index 00000000000..fe164fe40f7 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/load-test/kodata/refs @@ -0,0 +1 @@ +../../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/third_party/istio-1.1-latest b/vendor/knative.dev/serving/third_party/istio-1.1-latest index eeb30440bcf..cf1864a94b6 120000 --- a/vendor/knative.dev/serving/third_party/istio-1.1-latest +++ b/vendor/knative.dev/serving/third_party/istio-1.1-latest @@ -1 +1 @@ -istio-1.1.7 \ No newline at end of file +istio-1.1.13 \ No newline at end of file diff --git a/vendor/knative.dev/serving/third_party/istio-1.2-latest b/vendor/knative.dev/serving/third_party/istio-1.2-latest index bc5de0fd095..f0583c75c95 120000 --- a/vendor/knative.dev/serving/third_party/istio-1.2-latest +++ b/vendor/knative.dev/serving/third_party/istio-1.2-latest @@ -1 +1 @@ -istio-1.2.0 \ No newline at end of file +istio-1.2.4 \ No newline at end of file