From d3783b475c674195ca47c22a02a074c05e4af0fa Mon Sep 17 00:00:00 2001 From: Jan Chaloupka Date: Mon, 29 Apr 2019 14:22:42 +0200 Subject: [PATCH] Revendor latest openshift/cluster-api --- Gopkg.lock | 19 +- .../actuators/machine/actuator_test.go | 1 - .../cluster-api-actuator-pkg/Gopkg.lock | 69 +-- .../cluster-api-actuator-pkg/Gopkg.toml | 16 +- .../cluster-api-actuator-pkg/Makefile | 25 +- .../hack/ci-integration.sh | 8 + .../pkg/e2e/autoscaler/autoscaler.go | 212 ++++----- .../pkg/e2e/framework/common.go | 21 +- .../pkg/e2e/framework/framework.go | 2 +- .../pkg/e2e/framework/machinehealthcheck.go | 2 - .../pkg/e2e/framework/machines.go | 31 ++ .../pkg/e2e/framework/nodes.go | 33 ++ .../pkg/e2e/infra/infra.go | 91 +++- .../pkg/e2e/infra/utils.go | 57 +-- .../machinehealthcheck/machinehealthcheck.go | 81 +--- .../pkg/e2e/operators/machine-api-operator.go | 13 +- .../pkg/e2e/operators/utils.go | 6 +- .../pkg/manifests/manifests.go | 26 +- .../pkg/manifests/userdata.go | 4 +- .../config/crds/machine_v1beta1_cluster.yaml | 14 - .../config/crds/machine_v1beta1_machine.yaml | 73 ---- .../machine_v1beta1_machinedeployment.yaml | 43 -- .../crds/machine_v1beta1_machineset.yaml | 43 -- .../pkg/apis/machine/v1beta1/common_types.go | 26 +- .../pkg/apis/machine/v1beta1/machine_types.go | 75 +--- .../machine/v1beta1/zz_generated.deepcopy.go | 81 ---- .../pkg/controller/machine/BUILD.bazel | 3 + .../pkg/controller/machine/controller.go | 44 +- .../machinedeployment/controller.go | 2 +- .../pkg/controller/machineset/controller.go | 2 +- .../cluster-autoscaler-operator/Gopkg.lock | 256 ++++++----- .../cluster-autoscaler-operator/Gopkg.toml | 31 +- .../cluster-autoscaler-operator/Makefile | 13 +- .../cmd/manager/main.go | 19 +- .../examples/clusterautoscaler.yaml | 6 +- .../examples/machineautoscaler.yaml | 2 +- .../hack/verify-actuator-pkg.sh | 13 + .../install/01_clusterautoscaler.crd.yaml | 4 +- .../install/02_machineautoscaler.crd.yaml | 4 +- .../kustomization.yaml | 2 +- .../pkg/apis/addtoscheme_autoscaling_v1.go | 10 + ....go => addtoscheme_autoscaling_v1beta1.go} | 4 +- .../clusterautoscaler_types.go | 2 +- .../pkg/apis/autoscaling/v1/doc.go | 4 + .../autoscaling/{v1alpha1 => v1}/register.go | 6 +- .../{v1alpha1 => v1}/zz_generated.deepcopy.go | 117 +---- .../{v1alpha1 => v1}/zz_generated.defaults.go | 2 +- .../autoscaling/v1/zz_generated.openapi.go | 62 +++ .../pkg/apis/autoscaling/v1alpha1/doc.go | 4 - .../v1alpha1/zz_generated.openapi.go | 107 ----- .../pkg/apis/autoscaling/v1beta1/doc.go | 4 + .../machineautoscaler_types.go | 2 +- .../pkg/apis/autoscaling/v1beta1/register.go | 19 + .../v1beta1/zz_generated.deepcopy.go | 140 ++++++ .../v1beta1/zz_generated.defaults.go | 32 ++ .../v1beta1/zz_generated.openapi.go | 62 +++ .../clusterautoscaler/clusterautoscaler.go | 8 +- .../clusterautoscaler_controller.go | 136 +++--- .../machineautoscaler_controller.go | 66 +-- .../pkg/operator/config.go | 6 +- .../pkg/operator/operator.go | 59 +-- .../pkg/operator/status.go | 405 ++++++++++++------ .../pkg/util/util.go | 63 +++ .../cluster-autoscaler-operator-patch.yaml | 0 .../test/e2e/main.go | 111 ----- .../test/e2e/operator_expectations.go | 325 -------------- .../test/helpers/helpers.go | 127 ++++++ .../test/resources/cluster.yaml | 15 - .../test/resources/machine-set.yaml | 26 -- 69 files changed, 1582 insertions(+), 1815 deletions(-) create mode 100755 vendor/github.com/openshift/cluster-api-actuator-pkg/hack/ci-integration.sh create mode 100644 vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/nodes.go create mode 100755 vendor/github.com/openshift/cluster-autoscaler-operator/hack/verify-actuator-pkg.sh create mode 100644 vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/addtoscheme_autoscaling_v1.go rename vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/{addtoscheme_autoscaling_v1alpha1.go => addtoscheme_autoscaling_v1beta1.go} (69%) rename vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/{v1alpha1 => v1}/clusterautoscaler_types.go (99%) create mode 100644 vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/doc.go rename vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/{v1alpha1 => v1}/register.go (78%) rename vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/{v1alpha1 => v1}/zz_generated.deepcopy.go (65%) rename vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/{v1alpha1 => v1}/zz_generated.defaults.go (98%) create mode 100644 vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/zz_generated.openapi.go delete mode 100644 vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/doc.go delete mode 100644 vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/zz_generated.openapi.go create mode 100644 vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/doc.go rename vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/{v1alpha1 => v1beta1}/machineautoscaler_types.go (99%) create mode 100644 vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/register.go create mode 100644 vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/zz_generated.deepcopy.go create mode 100644 vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/zz_generated.defaults.go create mode 100644 vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/zz_generated.openapi.go rename vendor/github.com/openshift/cluster-autoscaler-operator/{ => test}/cluster-autoscaler-operator-patch.yaml (100%) delete mode 100644 vendor/github.com/openshift/cluster-autoscaler-operator/test/e2e/main.go delete mode 100644 vendor/github.com/openshift/cluster-autoscaler-operator/test/e2e/operator_expectations.go create mode 100644 vendor/github.com/openshift/cluster-autoscaler-operator/test/helpers/helpers.go delete mode 100644 vendor/github.com/openshift/cluster-autoscaler-operator/test/resources/cluster.yaml delete mode 100644 vendor/github.com/openshift/cluster-autoscaler-operator/test/resources/machine-set.yaml diff --git a/Gopkg.lock b/Gopkg.lock index 87c47069f..32a533b29 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -412,7 +412,7 @@ [[projects]] branch = "openshift-4.0-cluster-api-0.0.0-alpha.4" - digest = "1:fdddf352fc7677bb205bc1a84a8c4205c92ca2b1b8cf50e862a7cbbf26da4b10" + digest = "1:43b90c55a82c4be0bb8524534a92f2c7bd909e041a51e7b1ed6d52300978ef6a" name = "github.com/openshift/cluster-api" packages = [ "pkg/apis", @@ -428,15 +428,17 @@ "pkg/client/clientset_generated/clientset/typed/machine/v1beta1/fake", "pkg/controller/error", "pkg/controller/machine", + "pkg/controller/node", + "pkg/controller/noderefutil", "pkg/errors", "pkg/util", ] pruneopts = "T" - revision = "9839db3a35e26b97dccc223fc7b7310e4fb48544" + revision = "d8958b539e331bf5ebb056b7f872541e13fb8e01" [[projects]] branch = "master" - digest = "1:9c11f175671408bd03a6ef847b0d3de5a7c89ccd7ec92def30a96d5d93a6369d" + digest = "1:e5a3d16ae5e88ee05f61a5f098d510e726633f2ba33d4edefb565182f62679fb" name = "github.com/openshift/cluster-api-actuator-pkg" packages = [ "pkg/e2e/framework", @@ -444,15 +446,18 @@ "pkg/types", ] pruneopts = "T" - revision = "417ca171b620cd9ed3c504dc2f39ebe31f4dad3d" + revision = "286578aa9fd0510b7c37fbd4b4ab9c0eab7b03eb" [[projects]] branch = "master" - digest = "1:99f72b8afa76d7ccac0225c685d3cbeee2f137d69b387c3ef5a9b0b0416a493c" + digest = "1:4e77fc2cc2faa6f0558dd51ab8b1167ef347669c7bfc48d45fa2281487e48b6d" name = "github.com/openshift/cluster-autoscaler-operator" - packages = ["pkg/apis/autoscaling/v1alpha1"] + packages = [ + "pkg/apis/autoscaling/v1", + "pkg/apis/autoscaling/v1beta1", + ] pruneopts = "T" - revision = "54672e5e562be1c55db424a744da445fc715f7b3" + revision = "c0100183b6cd7668221d5b4ead52a4ed6fa09d85" [[projects]] branch = "master" diff --git a/pkg/cloud/libvirt/actuators/machine/actuator_test.go b/pkg/cloud/libvirt/actuators/machine/actuator_test.go index 6ab318b50..60b2458f1 100644 --- a/pkg/cloud/libvirt/actuators/machine/actuator_test.go +++ b/pkg/cloud/libvirt/actuators/machine/actuator_test.go @@ -43,7 +43,6 @@ func TestMachineEvents(t *testing.T) { machineInvalidProviderConfig := machine.DeepCopy() machineInvalidProviderConfig.Spec.ProviderSpec.Value = nil - machineInvalidProviderConfig.Spec.ProviderSpec.ValueFrom = nil cases := []struct { name string diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/Gopkg.lock b/vendor/github.com/openshift/cluster-api-actuator-pkg/Gopkg.lock index 753508e96..13955cb25 100644 --- a/vendor/github.com/openshift/cluster-api-actuator-pkg/Gopkg.lock +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/Gopkg.lock @@ -25,6 +25,14 @@ pruneopts = "" revision = "de5bf2ad457846296e2031421a34e2568e304e35" +[[projects]] + digest = "1:60942d250d0e06d3722ddc8e22bc52f8cef7961ba6d8d3e95327a32b6b024a7b" + name = "github.com/appscode/jsonpatch" + packages = ["."] + pruneopts = "" + revision = "7c0e3b262f30165a8ec3d0b4c6059fd92703bfb2" + version = "1.0.0" + [[projects]] branch = "master" digest = "1:c0bec5f9b98d0bc872ff5e834fac186b807b656683bd29cb82fb207a1513fabb" @@ -281,14 +289,6 @@ revision = "28bf78dadb0f64748ff13a0b6547e4972a5cea64" version = "v1.0.1" -[[projects]] - branch = "master" - digest = "1:58050e2bc9621cc6b68c1da3e4a0d1c40ad1f89062b9855c26521fd42a97a106" - name = "github.com/mattbaird/jsonpatch" - packages = ["."] - pruneopts = "" - revision = "81af80346b1a01caae0cbc27fd3c1ba5b11e189f" - [[projects]] digest = "1:63722a4b1e1717be7b98fc686e0b30d5e7f734b9e93d7dee86293b6deab7ea28" name = "github.com/matttproud/golang_protobuf_extensions" @@ -364,15 +364,15 @@ version = "v1.4.2" [[projects]] - branch = "master" - digest = "1:7c3defaa4c171d552da0ccedce06992efad4d102ea39cd37f8444a0403b5913c" + digest = "1:853f9ec7a92a4b87a9b660e838731623d098613ef3bd5443b8331790ff7bef10" name = "github.com/openshift/api" packages = ["config/v1"] pruneopts = "" - revision = "af79befc50a8223c8122e9e654f65763dd17a87e" + revision = "8e476cb7322e59919cbb6482fd076ec5a214df25" [[projects]] - digest = "1:6299a67dc836b7645d1e207f4764fd8bdcb11b1d614fc2c32435925ffdc7997a" + branch = "openshift-4.0-cluster-api-0.0.0-alpha.4" + digest = "1:70aff930abe993c5b2c11128f615ac7ad529e99d82ee3fb13e41e2afac30a38c" name = "github.com/openshift/cluster-api" packages = [ "pkg/apis/cluster/common", @@ -388,18 +388,19 @@ "pkg/util", ] pruneopts = "" - revision = "8b6a416a1830212712a6b03c5431afbd4f586d62" + revision = "d8958b539e331bf5ebb056b7f872541e13fb8e01" [[projects]] branch = "master" - digest = "1:8439cd39e3006f645c7b3941b2dd8e26218c867e8a420aaf3a9a9bd49e1acc07" + digest = "1:6d48343e436f36fdfacd82c48d37b891f44e44cbcdbbb57d42b8a333927716a4" name = "github.com/openshift/cluster-autoscaler-operator" packages = [ "pkg/apis", - "pkg/apis/autoscaling/v1alpha1", + "pkg/apis/autoscaling/v1", + "pkg/apis/autoscaling/v1beta1", ] pruneopts = "" - revision = "73c46659d0e2c0ac03e6e207d52ff0c025b04786" + revision = "17350a84b40565851a3f1bd21c6f8a6763b8eacb" [[projects]] branch = "master" @@ -729,7 +730,7 @@ version = "v2.2.1" [[projects]] - digest = "1:3e3e9df293bd6f9fd64effc9fa1f0edcd97e6c74145cd9ab05d35719004dc41f" + digest = "1:be67264067c68b1f601bfc4a6c102b1380ed0743147381de81ed11da88d2e246" name = "k8s.io/api" packages = [ "admission/v1beta1", @@ -738,6 +739,7 @@ "apps/v1", "apps/v1beta1", "apps/v1beta2", + "auditregistration/v1alpha1", "authentication/v1", "authentication/v1beta1", "authorization/v1", @@ -766,11 +768,11 @@ "storage/v1beta1", ] pruneopts = "" - revision = "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" - version = "kubernetes-1.12.5" + revision = "05914d821849570fba9eacfb29466f2d8d3cd229" + version = "kubernetes-1.13.1" [[projects]] - digest = "1:38bf124557f0bc0aecaa95557185cfc84c46de8a222ac0ae33e58379d8a82009" + digest = "1:2133e488e6db5701ef295c39cbc0836855c02af677e8707e539ebf605a4211ca" name = "k8s.io/apiextensions-apiserver" packages = [ "pkg/apis/apiextensions", @@ -780,11 +782,11 @@ "pkg/client/clientset/clientset/typed/apiextensions/v1beta1", ] pruneopts = "" - revision = "a384d17938fe55d54a52d5668bf0ff40044daef0" - version = "kubernetes-1.12.5" + revision = "0fe22c71c47604641d9aa352c785b7912c200562" + version = "kubernetes-1.13.1" [[projects]] - digest = "1:8cac653dd97e89700e00ce6ea7134cf28b3e1b59615ab99464760e230fab9860" + digest = "1:66b0292f815d508d11ed5fe94fdeb0bcc5a988703a08e73bf3cb3a415de676cf" name = "k8s.io/apimachinery" packages = [ "pkg/api/equality", @@ -835,11 +837,11 @@ "third_party/forked/golang/reflect", ] pruneopts = "" - revision = "49ce2735e5074ffc3f8190c8406cf51a96302dad" - version = "kubernetes-1.12.5" + revision = "2b1284ed4c93a43499e781493253e2ac5959c4fd" + version = "kubernetes-1.13.1" [[projects]] - digest = "1:203ee3d901467a9bfa00c1859438f168288431405b7a30c7c6f14f8391cafa6f" + digest = "1:d603c9957fa66c90792d45fe0205d484da2ea364a01069c20890f2640b4a0fd5" name = "k8s.io/client-go" packages = [ "discovery", @@ -851,6 +853,7 @@ "kubernetes/typed/apps/v1", "kubernetes/typed/apps/v1beta1", "kubernetes/typed/apps/v1beta2", + "kubernetes/typed/auditregistration/v1alpha1", "kubernetes/typed/authentication/v1", "kubernetes/typed/authentication/v1beta1", "kubernetes/typed/authorization/v1", @@ -919,8 +922,8 @@ "util/workqueue", ] pruneopts = "" - revision = "701b913670036511e3d752318272c97f1a2a2edd" - version = "kubernetes-1.12.5" + revision = "8d9ed539ba3134352c586810e749e58df4e94e4f" + version = "kubernetes-1.13.1" [[projects]] branch = "master" @@ -978,7 +981,7 @@ revision = "c2654d5206da6b7b6ace12841e8f359bb89b443c" [[projects]] - digest = "0:" + digest = "1:35fe7fc05f04f79af905348b757b440723f67534f873abfef906e1a64dfe9e64" name = "sigs.k8s.io/controller-runtime" packages = [ "pkg/cache", @@ -1007,11 +1010,12 @@ "pkg/source/internal", "pkg/webhook/admission", "pkg/webhook/admission/types", + "pkg/webhook/internal/metrics", "pkg/webhook/types", ] pruneopts = "" - revision = "" - version = "v0.1.8" + revision = "12d98582e72927b6cd0123e2b4e819f9341ce62c" + version = "v0.1.10" [[projects]] digest = "1:0fb3157cb64930e8fb7d5b3fbfcedb71b8b4b990d8babcc7c7cd28e1eb672e13" @@ -1062,7 +1066,8 @@ "github.com/openshift/cluster-api/pkg/client/clientset_generated/clientset", "github.com/openshift/cluster-api/pkg/controller/node", "github.com/openshift/cluster-autoscaler-operator/pkg/apis", - "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1", + "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1", + "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1", "github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers", "github.com/openshift/machine-api-operator/pkg/apis/healthchecking/v1alpha1", "github.com/openshift/machine-api-operator/pkg/generated/clientset/versioned", diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/Gopkg.toml b/vendor/github.com/openshift/cluster-api-actuator-pkg/Gopkg.toml index 880a08059..3f6235648 100644 --- a/vendor/github.com/openshift/cluster-api-actuator-pkg/Gopkg.toml +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/Gopkg.toml @@ -41,9 +41,13 @@ required = [ "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1", ] +[[constraint]] + name = "github.com/openshift/api" + revision = "8e476cb7322e59919cbb6482fd076ec5a214df25" + [[constraint]] name = "github.com/openshift/cluster-api" - revision = "8b6a416a1830212712a6b03c5431afbd4f586d62" + branch = "openshift-4.0-cluster-api-0.0.0-alpha.4" [[constraint]] name = "github.com/openshift/cluster-autoscaler-operator" @@ -60,20 +64,20 @@ required = [ [[override]] name = "k8s.io/api" - version = "kubernetes-1.12.5" + version = "kubernetes-1.13.1" [[override]] name = "k8s.io/apiextensions-apiserver" - version = "kubernetes-1.12.5" + version = "kubernetes-1.13.1" [[override]] name = "k8s.io/apimachinery" - version = "kubernetes-1.12.5" + version = "kubernetes-1.13.1" [[override]] name = "k8s.io/client-go" - version = "kubernetes-1.12.5" + version = "kubernetes-1.13.1" [[override]] name = "k8s.io/kube-aggregator" - branch = "release-1.12" + branch = "release-1.13" diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/Makefile b/vendor/github.com/openshift/cluster-api-actuator-pkg/Makefile index 2d4952d5f..dbf8725c0 100644 --- a/vendor/github.com/openshift/cluster-api-actuator-pkg/Makefile +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/Makefile @@ -45,22 +45,21 @@ build-e2e: .PHONY: test-e2e test-e2e: ## Run openshift specific e2e test - go test -timeout 90m \ - -v github.com/openshift/cluster-api-actuator-pkg/pkg/e2e \ - -kubeconfig $${KUBECONFIG:-~/.kube/config} \ - -machine-api-namespace $${NAMESPACE:-openshift-machine-api} \ - -ginkgo.v \ - -args -v 5 -logtostderr true + # Run operator tests first to preserve logs for troubleshooting test + # failures and flakes. + # Feature:Operator tests remove deployments. Thus loosing all the logs + # previously acquired. + hack/ci-integration.sh -ginkgo.v -ginkgo.noColor=true -ginkgo.focus "Feature:Operators" + hack/ci-integration.sh -ginkgo.v -ginkgo.noColor=true -ginkgo.skip "Feature:Operators" .PHONY: k8s-e2e k8s-e2e: ## Run k8s specific e2e test - go test -timeout 30m \ - -v github.com/openshift/cluster-api-actuator-pkg/pkg/e2e \ - -kubeconfig $${KUBECONFIG:-~/.kube/config} \ - -machine-api-namespace $${NAMESPACE:-kube-system} \ - -ginkgo.v \ - -args -v 5 -logtostderr true - + # Run operator tests first to preserve logs for troubleshooting test + # failures and flakes. + # Feature:Operator tests remove deployments. Thus loosing all the logs + # previously acquired. + NAMESPACE=kube-system hack/ci-integration.sh -ginkgo.v -ginkgo.noColor=true -ginkgo.focus "Feature:Operators" + NAMESPACE=kube-system hack/ci-integration.sh -ginkgo.v -ginkgo.noColor=true -ginkgo.skip "Feature:Operators" .PHONY: help help: diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/hack/ci-integration.sh b/vendor/github.com/openshift/cluster-api-actuator-pkg/hack/ci-integration.sh new file mode 100755 index 000000000..66db62562 --- /dev/null +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/hack/ci-integration.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +go test -timeout 90m \ + -v github.com/openshift/cluster-api-actuator-pkg/pkg/e2e \ + -kubeconfig ${KUBECONFIG:-~/.kube/config} \ + -machine-api-namespace ${NAMESPACE:-openshift-machine-api} \ + -args -v 5 -logtostderr \ + $@ diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/autoscaler/autoscaler.go b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/autoscaler/autoscaler.go index 91efaf168..99c83f010 100644 --- a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/autoscaler/autoscaler.go +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/autoscaler/autoscaler.go @@ -10,7 +10,8 @@ import ( o "github.com/onsi/gomega" e2e "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework" mapiv1beta1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1" - caov1alpha1 "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1" + caov1 "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1" + caov1beta1 "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -61,7 +62,7 @@ func newWorkLoad() *batchv1.Job { }, RestartPolicy: corev1.RestartPolicy("Never"), NodeSelector: map[string]string{ - "node-role.kubernetes.io/worker": "", + e2e.WorkerNodeRoleLabel: "", }, Tolerations: []corev1.Toleration{ { @@ -123,9 +124,9 @@ func labelMachineSetNodes(client runtimeclient.Client, ms *mapiv1beta1.MachineSe } // Build default CA resource to allow fast scaling up and down -func clusterAutoscalerResource() *caov1alpha1.ClusterAutoscaler { +func clusterAutoscalerResource() *caov1.ClusterAutoscaler { tenSecondString := "10s" - return &caov1alpha1.ClusterAutoscaler{ + return &caov1.ClusterAutoscaler{ ObjectMeta: metav1.ObjectMeta{ Name: "default", Namespace: e2e.TestContext.MachineApiNamespace, @@ -135,10 +136,10 @@ func clusterAutoscalerResource() *caov1alpha1.ClusterAutoscaler { }, TypeMeta: metav1.TypeMeta{ Kind: "ClusterAutoscaler", - APIVersion: "autoscaling.openshift.io/v1alpha1", + APIVersion: "autoscaling.openshift.io/v1", }, - Spec: caov1alpha1.ClusterAutoscalerSpec{ - ScaleDown: &caov1alpha1.ScaleDownConfig{ + Spec: caov1.ClusterAutoscalerSpec{ + ScaleDown: &caov1.ScaleDownConfig{ Enabled: true, DelayAfterAdd: &tenSecondString, DelayAfterDelete: &tenSecondString, @@ -150,8 +151,8 @@ func clusterAutoscalerResource() *caov1alpha1.ClusterAutoscaler { } // Build MA resource from targeted machineset -func machineAutoscalerResource(targetMachineSet *mapiv1beta1.MachineSet, minReplicas, maxReplicas int32) *caov1alpha1.MachineAutoscaler { - return &caov1alpha1.MachineAutoscaler{ +func machineAutoscalerResource(targetMachineSet *mapiv1beta1.MachineSet, minReplicas, maxReplicas int32) *caov1beta1.MachineAutoscaler { + return &caov1beta1.MachineAutoscaler{ ObjectMeta: metav1.ObjectMeta{ GenerateName: fmt.Sprintf("autoscale-%s", targetMachineSet.Name), Namespace: e2e.TestContext.MachineApiNamespace, @@ -161,12 +162,12 @@ func machineAutoscalerResource(targetMachineSet *mapiv1beta1.MachineSet, minRepl }, TypeMeta: metav1.TypeMeta{ Kind: "MachineAutoscaler", - APIVersion: "autoscaling.openshift.io/v1alpha1", + APIVersion: "autoscaling.openshift.io/v1beta1", }, - Spec: caov1alpha1.MachineAutoscalerSpec{ + Spec: caov1beta1.MachineAutoscalerSpec{ MaxReplicas: maxReplicas, MinReplicas: minReplicas, - ScaleTargetRef: caov1alpha1.CrossVersionObjectReference{ + ScaleTargetRef: caov1beta1.CrossVersionObjectReference{ Name: targetMachineSet.Name, Kind: "MachineSet", APIVersion: "machine.openshift.io/v1beta1", @@ -177,13 +178,87 @@ func machineAutoscalerResource(targetMachineSet *mapiv1beta1.MachineSet, minRepl var _ = g.Describe("[Feature:Machines] Autoscaler should", func() { defer g.GinkgoRecover() + scaleUpFunc := func(client runtimeclient.Client, targetMachineSet mapiv1beta1.MachineSet, nodeTestLabel string, initialNumberOfReplicas int32, expectedReplicas int32) { + g.By(fmt.Sprintf("Creating MachineAutoscaler object for targetMachineSet %q", targetMachineSet.Name)) + machineAutoscaler := machineAutoscalerResource(&targetMachineSet, 1, expectedReplicas) + err := client.Create(context.TODO(), machineAutoscaler) + o.Expect(err).NotTo(o.HaveOccurred()) + + g.By(fmt.Sprintf("Waiting for cluster to scale out number of replicas of targetMachineSet %q", targetMachineSet.Name)) + err = wait.PollImmediate(5*time.Second, e2e.WaitLong, func() (bool, error) { + ms, err := e2e.GetMachineSet(context.TODO(), client, targetMachineSet.Name) + if err != nil { + glog.Errorf("error getting machineset object: %v, retrying...", err) + return false, nil + } + glog.Infof("MachineSet %q. Initial number of replicas: %d. Current number of replicas: %d", targetMachineSet.Name, initialNumberOfReplicas, pointer.Int32PtrDerefOr(ms.Spec.Replicas, e2e.DefaultMachineSetReplicas)) + return pointer.Int32PtrDerefOr(ms.Spec.Replicas, e2e.DefaultMachineSetReplicas) == expectedReplicas, nil + }) + o.Expect(err).NotTo(o.HaveOccurred()) + + g.By(fmt.Sprintf("Waiting for cluster to scale up nodes for targetMachineSet %q", targetMachineSet.Name)) + err = wait.PollImmediate(5*time.Second, e2e.WaitLong, func() (bool, error) { + scaledMachines := mapiv1beta1.MachineList{} + if err := client.List(context.TODO(), runtimeclient.MatchingLabels(targetMachineSet.Spec.Selector.MatchLabels), &scaledMachines); err != nil { + glog.Errorf("Error querying api for machineset object: %v, retrying...", err) + return false, nil + } + + // get all linked nodes and label them + nodeCounter := 0 + for _, machine := range scaledMachines.Items { + if machine.Status.NodeRef == nil { + glog.Errorf("Machine %q does not have node reference set", machine.Name) + return false, nil + } + glog.Infof("Machine %q is linked to node %q", machine.Name, machine.Status.NodeRef.Name) + nodeCounter++ + } + + glog.Infof("Expecting %d nodes. Current number of nodes in the group: %d", expectedReplicas, nodeCounter) + return nodeCounter == int(expectedReplicas), nil + }) + o.Expect(err).NotTo(o.HaveOccurred()) + + g.By(fmt.Sprintf("Labeling all nodes belonging to the machineset %q (after scale up phase)", targetMachineSet.Name)) + err = labelMachineSetNodes(client, &targetMachineSet, nodeTestLabel) + o.Expect(err).NotTo(o.HaveOccurred()) + } + + scaleDownFunc := func(client runtimeclient.Client, targetMachineSet string, nodeTestLabel string, initialNumberOfReplicas int32) { + g.By(fmt.Sprintf("Waiting for machineset %q to have at most initial number of replicas", targetMachineSet)) + err := wait.PollImmediate(5*time.Second, e2e.WaitLong, func() (bool, error) { + ms, err := e2e.GetMachineSet(context.TODO(), client, targetMachineSet) + if err != nil { + glog.Errorf("error getting machineset object: %v, retrying...", err) + return false, nil + } + msReplicas := pointer.Int32PtrDerefOr(ms.Spec.Replicas, e2e.DefaultMachineSetReplicas) + glog.Infof("Initial number of replicas: %d. Current number of replicas: %d", initialNumberOfReplicas, msReplicas) + if msReplicas > initialNumberOfReplicas { + return false, nil + } + + // Make sure all scaled down nodes are really gone (so they don't affect tests to be run next) + scaledNodes := corev1.NodeList{} + if err := client.List(context.TODO(), runtimeclient.MatchingLabels(map[string]string{nodeTestLabel: ""}), &scaledNodes); err != nil { + glog.Errorf("Error querying api for node objects: %v, retrying...", err) + return false, nil + } + scaledNodesLen := int32(len(scaledNodes.Items)) + glog.Infof("Current number of replicas: %d. Current number of nodes: %d", msReplicas, scaledNodesLen) + return scaledNodesLen <= msReplicas && scaledNodesLen <= initialNumberOfReplicas, nil + }) + o.Expect(err).NotTo(o.HaveOccurred()) + } g.It("scale out", func() { var err error client, err := e2e.LoadClient() o.Expect(err).NotTo(o.HaveOccurred()) - nodeTestLabel := fmt.Sprintf("machine.openshift.io/autoscaling-test-%v", string(uuid.NewUUID())) + nodeTestLabel0 := fmt.Sprintf("machine.openshift.io/autoscaling-test-%v", string(uuid.NewUUID())) + nodeTestLabel1 := fmt.Sprintf("machine.openshift.io/autoscaling-test-%v", string(uuid.NewUUID())) // We want to clean up these objects on any subsequent error. defer func() { @@ -195,7 +270,7 @@ var _ = g.Describe("[Feature:Machines] Autoscaler should", func() { glog.Info("Deleted workload object") } - err = e2e.DeleteObjectsByLabels(context.TODO(), client, map[string]string{autoscalingTestLabel: ""}, &caov1alpha1.MachineAutoscalerList{}) + err = e2e.DeleteObjectsByLabels(context.TODO(), client, map[string]string{autoscalingTestLabel: ""}, &caov1beta1.MachineAutoscalerList{}) if err != nil { // if this one fails, there are still other resources to be deleted. glog.Warning(err) @@ -203,7 +278,7 @@ var _ = g.Describe("[Feature:Machines] Autoscaler should", func() { glog.Info("Deleted machineAutoscaler object") } - err = e2e.DeleteObjectsByLabels(context.TODO(), client, map[string]string{autoscalingTestLabel: ""}, &caov1alpha1.ClusterAutoscalerList{}) + err = e2e.DeleteObjectsByLabels(context.TODO(), client, map[string]string{autoscalingTestLabel: ""}, &caov1.ClusterAutoscalerList{}) if err != nil { // if this one fails, there is no point of returning an error as this is the last resource deletion action glog.Warning(err) @@ -212,19 +287,25 @@ var _ = g.Describe("[Feature:Machines] Autoscaler should", func() { } }() - g.By("Getint target machineSet") + g.By("Getting target machineSet") machinesets, err := e2e.GetMachineSets(context.TODO(), client) o.Expect(err).NotTo(o.HaveOccurred()) - o.Expect(len(machinesets)).To(o.BeNumerically(">", 0)) + o.Expect(len(machinesets)).To(o.BeNumerically(">", 1)) - targetMachineSet := machinesets[0] - glog.Infof("Target machineSet %s", targetMachineSet.Name) + targetMachineSet0 := machinesets[0] + glog.Infof("Target machineSet0 %q", targetMachineSet0.Name) + targetMachineSet1 := machinesets[1] + glog.Infof("Target machineSet1 %q", targetMachineSet1.Name) // When we add support for machineDeployments on the installer, cluster-autoscaler and cluster-autoscaler-operator // we need to test against deployments instead so we skip this test. - if ownerReferences := targetMachineSet.GetOwnerReferences(); len(ownerReferences) > 0 { + if ownerReferences0 := targetMachineSet0.GetOwnerReferences(); len(ownerReferences0) > 0 { // glog.Infof("MachineSet %s is owned by a machineDeployment. Please run tests against machineDeployment instead", targetMachineSet.Name) - g.Skip(fmt.Sprintf("MachineSet %s is owned by a machineDeployment. Please run tests against machineDeployment instead", targetMachineSet.Name)) + g.Skip(fmt.Sprintf("MachineSet %q is owned by a machineDeployment. Please run tests against machineDeployment instead", targetMachineSet0.Name)) + } + + if ownerReferences1 := targetMachineSet1.GetOwnerReferences(); len(ownerReferences1) > 0 { + g.Skip(fmt.Sprintf("MachineSet %q is owned by a machineDeployment. Please run tests against machineDeployment instead", targetMachineSet1.Name)) } g.By("Create ClusterAutoscaler object") @@ -232,68 +313,17 @@ var _ = g.Describe("[Feature:Machines] Autoscaler should", func() { err = client.Create(context.TODO(), clusterAutoscaler) o.Expect(err).NotTo(o.HaveOccurred()) - initialNumberOfReplicas := pointer.Int32PtrDerefOr(targetMachineSet.Spec.Replicas, e2e.DefaultMachineSetReplicas) - - g.By("Creating MachineAutoscaler objects") - machineAutoscaler := machineAutoscalerResource(&targetMachineSet, 1, initialNumberOfReplicas+1) - err = client.Create(context.TODO(), machineAutoscaler) - o.Expect(err).NotTo(o.HaveOccurred()) - - g.By("Labeling all nodes belonging to the machineset (before scale up phase)") - err = labelMachineSetNodes(client, &targetMachineSet, nodeTestLabel) - o.Expect(err).NotTo(o.HaveOccurred()) - - glog.Info("Get nodeList") - nodeList := corev1.NodeList{} - err = client.List(context.TODO(), runtimeclient.MatchingLabels(map[string]string{nodeTestLabel: ""}), &nodeList) - o.Expect(err).NotTo(o.HaveOccurred()) - - nodeGroupInitialTotalNodes := len(nodeList.Items) - glog.Infof("Cluster initial number of nodes in node group %v is %d", targetMachineSet.Name, nodeGroupInitialTotalNodes) + initialNumberOfReplicas0 := pointer.Int32PtrDerefOr(targetMachineSet0.Spec.Replicas, e2e.DefaultMachineSetReplicas) + initialNumberOfReplicas1 := pointer.Int32PtrDerefOr(targetMachineSet1.Spec.Replicas, e2e.DefaultMachineSetReplicas) + glog.Infof("initialNumberOfReplicas0 %d, initialNumberOfReplicas1 %d", initialNumberOfReplicas0, initialNumberOfReplicas1) + o.Expect(initialNumberOfReplicas0).To(o.BeNumerically("==", initialNumberOfReplicas1)) g.By("Creating workload") err = client.Create(context.TODO(), newWorkLoad()) o.Expect(err).NotTo(o.HaveOccurred()) - g.By("Waiting for cluster to scale out number of replicas") - err = wait.PollImmediate(5*time.Second, e2e.WaitLong, func() (bool, error) { - ms, err := e2e.GetMachineSet(context.TODO(), client, targetMachineSet.Name) - if err != nil { - glog.Errorf("error getting machineset object: %v, retrying...", err) - return false, nil - } - glog.Infof("MachineSet %s. Initial number of replicas: %d. Current number of replicas: %d", targetMachineSet.Name, initialNumberOfReplicas, pointer.Int32PtrDerefOr(ms.Spec.Replicas, e2e.DefaultMachineSetReplicas)) - return pointer.Int32PtrDerefOr(ms.Spec.Replicas, e2e.DefaultMachineSetReplicas) > initialNumberOfReplicas, nil - }) - o.Expect(err).NotTo(o.HaveOccurred()) - - g.By("Waiting for cluster to scale up nodes") - err = wait.PollImmediate(5*time.Second, e2e.WaitLong, func() (bool, error) { - scaledMachines := mapiv1beta1.MachineList{} - if err := client.List(context.TODO(), runtimeclient.MatchingLabels(targetMachineSet.Spec.Selector.MatchLabels), &scaledMachines); err != nil { - glog.Errorf("Error querying api for machineset object: %v, retrying...", err) - return false, nil - } - - // get all linked nodes and label them - nodeCounter := 0 - for _, machine := range scaledMachines.Items { - if machine.Status.NodeRef == nil { - glog.Errorf("Machine %q does not have node reference set", machine.Name) - return false, nil - } - glog.Infof("Machine %q is linked to node %q", machine.Name, machine.Status.NodeRef.Name) - nodeCounter++ - } - - glog.Infof("Expecting at least one new node to come up. Initial number of node group nodes: %d. Current number of nodes in the group: %d", nodeGroupInitialTotalNodes, nodeCounter) - return nodeCounter > nodeGroupInitialTotalNodes, nil - }) - o.Expect(err).NotTo(o.HaveOccurred()) - - g.By("Labeling all nodes belonging to the machineset (after scale up phase)") - err = labelMachineSetNodes(client, &targetMachineSet, nodeTestLabel) - o.Expect(err).NotTo(o.HaveOccurred()) + scaleUpFunc(client, targetMachineSet1, nodeTestLabel1, initialNumberOfReplicas1, initialNumberOfReplicas1+2) + scaleUpFunc(client, targetMachineSet0, nodeTestLabel0, initialNumberOfReplicas0, initialNumberOfReplicas1+1) // Delete workload g.By("Deleting workload") @@ -304,30 +334,8 @@ var _ = g.Describe("[Feature:Machines] Autoscaler should", func() { // start to scale down the unneeded nodes. We wait for that // condition; if successful we assert that (a smoke test of) // scale down is functional. - g.By("Waiting for cluster to have at most initial number of replicas") - err = wait.PollImmediate(5*time.Second, e2e.WaitLong, func() (bool, error) { - ms, err := e2e.GetMachineSet(context.TODO(), client, targetMachineSet.Name) - if err != nil { - glog.Errorf("error getting machineset object: %v, retrying...", err) - return false, nil - } - msReplicas := pointer.Int32PtrDerefOr(ms.Spec.Replicas, e2e.DefaultMachineSetReplicas) - glog.Infof("Initial number of replicas: %d. Current number of replicas: %d", initialNumberOfReplicas, msReplicas) - if msReplicas > initialNumberOfReplicas { - return false, nil - } - - // Make sure all scaled down nodes are really gone (so they don't affect tests to be run next) - scaledNodes := corev1.NodeList{} - if err := client.List(context.TODO(), runtimeclient.MatchingLabels(map[string]string{nodeTestLabel: ""}), &scaledNodes); err != nil { - glog.Errorf("Error querying api for node objects: %v, retrying...", err) - return false, nil - } - scaledNodesLen := int32(len(scaledNodes.Items)) - glog.Infof("Current number of replicas: %d. Current number of nodes: %d", msReplicas, scaledNodesLen) - return scaledNodesLen <= msReplicas && scaledNodesLen <= initialNumberOfReplicas, nil - }) - o.Expect(err).NotTo(o.HaveOccurred()) + scaleDownFunc(client, targetMachineSet0.Name, nodeTestLabel0, initialNumberOfReplicas0) + scaleDownFunc(client, targetMachineSet1.Name, nodeTestLabel1, initialNumberOfReplicas1) }) }) diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/common.go b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/common.go index 4249b92a1..a5f4c8434 100644 --- a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/common.go +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/common.go @@ -6,7 +6,8 @@ import ( "time" mapiv1beta1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1" - caov1alpha1 "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1" + caov1 "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1" + caov1beta1 "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -15,11 +16,11 @@ import ( ) const ( - WorkerRoleLabel = "node-role.kubernetes.io/worker" - WaitShort = 1 * time.Minute - WaitMedium = 3 * time.Minute - WaitLong = 10 * time.Minute - RetryMedium = 5 * time.Second + WorkerNodeRoleLabel = "node-role.kubernetes.io/worker" + WaitShort = 1 * time.Minute + WaitMedium = 3 * time.Minute + WaitLong = 10 * time.Minute + RetryMedium = 5 * time.Second // DefaultMachineSetReplicas is the default number of replicas of a machineset // if MachineSet.Spec.Replicas field is set to nil @@ -88,8 +89,8 @@ func GetMachine(ctx context.Context, client runtimeclient.Client, machineName st // DeleteObjectsByLabels list all objects of a given kind by labels and deletes them. // Currently supported kinds: -// - caov1alpha1.MachineAutoscalerList -// - caov1alpha1.ClusterAutoscalerList +// - caov1beta1.MachineAutoscalerList +// - caov1.ClusterAutoscalerList // - batchv1.JobList func DeleteObjectsByLabels(ctx context.Context, client runtimeclient.Client, labels map[string]string, list runtime.Object) error { if err := client.List(ctx, runtimeclient.MatchingLabels(labels), list); err != nil { @@ -99,11 +100,11 @@ func DeleteObjectsByLabels(ctx context.Context, client runtimeclient.Client, lab // TODO(jchaloup): find a way how to list the items independent of a kind var objs []runtime.Object switch d := list.(type) { - case *caov1alpha1.MachineAutoscalerList: + case *caov1beta1.MachineAutoscalerList: for _, item := range d.Items { objs = append(objs, runtime.Object(&item)) } - case *caov1alpha1.ClusterAutoscalerList: + case *caov1.ClusterAutoscalerList: for _, item := range d.Items { objs = append(objs, runtime.Object(&item)) } diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/framework.go b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/framework.go index 26ecf23ed..1c8667ed3 100644 --- a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/framework.go +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/framework.go @@ -436,7 +436,7 @@ func IsNodeReady(node *corev1.Node) bool { } func WaitUntilAllNodesAreReady(client runtimeclient.Client) error { - return wait.PollImmediate(1*time.Second, time.Minute, func() (bool, error) { + return wait.PollImmediate(1*time.Second, PoolNodesReadyTimeout, func() (bool, error) { nodeList := corev1.NodeList{} if err := client.List(context.TODO(), &runtimeclient.ListOptions{}, &nodeList); err != nil { glog.Errorf("error querying api for nodeList object: %v, retrying...", err) diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/machinehealthcheck.go b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/machinehealthcheck.go index 27200e345..5bd8c4219 100644 --- a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/machinehealthcheck.go +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/machinehealthcheck.go @@ -16,8 +16,6 @@ import ( const ( // KubeletKillerPodName contains the name of the pod that stops kubelet process KubeletKillerPodName = "kubelet-killer" - // NodeWorkerLabel contains label that every worker node has - NodeWorkerLabel = "node-role.kubernetes.io/worker" // MachineHealthCheckName contains the name of the machinehealthcheck used for tests MachineHealthCheckName = "workers-check" ) diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/machines.go b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/machines.go index 079ff97ff..6508af6a7 100644 --- a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/machines.go +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/machines.go @@ -2,6 +2,7 @@ package framework import ( "bytes" + "context" "fmt" "strings" @@ -9,12 +10,19 @@ import ( "github.com/openshift/cluster-api-actuator-pkg/pkg/types" machinev1beta1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1" + mapiv1beta1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1" + controllernode "github.com/openshift/cluster-api/pkg/controller/node" + apiv1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/rest" + "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/clientcmd" + + runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" ) func (f *Framework) DeleteMachineAndWait(machine *machinev1beta1.Machine, client types.CloudProviderClient) { @@ -242,6 +250,29 @@ func (f *Framework) WaitForNodesToGetReady(count int) error { }) } +// GetMachineFromNode returns the machine referenced by the "controllernode.MachineAnnotationKey" annotation in the given node +func GetMachineFromNode(client runtimeclient.Client, node *corev1.Node) (*mapiv1beta1.Machine, error) { + machineNamespaceKey, ok := node.Annotations[controllernode.MachineAnnotationKey] + if !ok { + return nil, fmt.Errorf("node %q does not have a MachineAnnotationKey %q", node.Name, controllernode.MachineAnnotationKey) + } + namespace, machineName, err := cache.SplitMetaNamespaceKey(machineNamespaceKey) + if err != nil { + return nil, fmt.Errorf("machine annotation format is incorrect %v: %v", machineNamespaceKey, err) + } + + if namespace != TestContext.MachineApiNamespace { + return nil, fmt.Errorf("Machine %q is forbidden to live outside of default %v namespace", machineNamespaceKey, TestContext.MachineApiNamespace) + } + + machine, err := GetMachine(context.TODO(), client, machineName) + if err != nil { + return nil, fmt.Errorf("error querying api for machine object: %v", err) + } + + return machine, nil +} + func ReadKubeconfigFromServer(sshConfig *SSHConfig) (string, error) { client, err := createSSHClient(sshConfig) if err != nil { diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/nodes.go b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/nodes.go new file mode 100644 index 000000000..bdfa6514c --- /dev/null +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework/nodes.go @@ -0,0 +1,33 @@ +package framework + +import ( + "context" + + corev1 "k8s.io/api/core/v1" + runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" +) + +// GetWorkerNodes returns all nodes with the nodeWorkerRoleLabel label +func GetWorkerNodes(client runtimeclient.Client) ([]corev1.Node, error) { + listOptions := runtimeclient.ListOptions{ + Namespace: TestContext.MachineApiNamespace, + } + listOptions.MatchingLabels(map[string]string{WorkerNodeRoleLabel: ""}) + workerNodes := &corev1.NodeList{} + err := client.List(context.TODO(), &listOptions, workerNodes) + if err != nil { + return nil, err + } + return workerNodes.Items, nil +} + +// FilterReadyNodes fileter the list of nodes and returns the list with ready nodes +func FilterReadyNodes(nodes []corev1.Node) []corev1.Node { + var readyNodes []corev1.Node + for _, n := range nodes { + if IsNodeReady(&n) { + readyNodes = append(readyNodes, n) + } + } + return readyNodes +} diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/infra/infra.go b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/infra/infra.go index 6e639a481..6bddb342a 100644 --- a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/infra/infra.go +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/infra/infra.go @@ -26,8 +26,8 @@ import ( ) var nodeDrainLabels = map[string]string{ - e2e.WorkerRoleLabel: "", - "node-draining-test": string(uuid.NewUUID()), + e2e.WorkerNodeRoleLabel: "", + "node-draining-test": string(uuid.NewUUID()), } func replicationControllerWorkload(namespace string) *corev1.ReplicationController { @@ -94,6 +94,36 @@ func podDisruptionBudget(namespace string) *kpolicyapi.PodDisruptionBudget { } } +func invalidMachinesetWithEmptyProviderConfig() *mapiv1beta1.MachineSet { + var oneReplicas int32 = 1 + return &mapiv1beta1.MachineSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "invalid-machineset", + Namespace: e2e.TestContext.MachineApiNamespace, + }, + Spec: mapiv1beta1.MachineSetSpec{ + Replicas: &oneReplicas, + Selector: metav1.LabelSelector{ + MatchLabels: map[string]string{ + "little-kitty": "i-am-little-kitty", + }, + }, + Template: mapiv1beta1.MachineTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + "big-kitty": "i-am-bit-kitty", + }, + }, + Spec: mapiv1beta1.MachineSpec{ + // Empty providerSpec!!! we don't want to provision real instances. + // Just to observe how many machine replicas get created. + ProviderSpec: mapiv1beta1.ProviderSpec{}, + }, + }, + }, + } +} + var _ = g.Describe("[Feature:Machines] Managed cluster should", func() { defer g.GinkgoRecover() @@ -195,9 +225,13 @@ var _ = g.Describe("[Feature:Machines] Managed cluster should", func() { err = waitForClusterSizeToBeHealthy(client, initialClusterSize) o.Expect(err).NotTo(o.HaveOccurred()) - workerNode, err := getWorkerNode(client) + g.By("getting worker node") + workerNodes, err := e2e.GetWorkerNodes(client) o.Expect(err).NotTo(o.HaveOccurred()) - workerMachine, err := getMachineFromNode(client, workerNode) + o.Expect(workerNodes).ToNot(o.BeEmpty()) + + workerNode := &workerNodes[0] + workerMachine, err := e2e.GetMachineFromNode(client, workerNode) o.Expect(err).NotTo(o.HaveOccurred()) g.By(fmt.Sprintf("deleting machine object %q", workerMachine.Name)) err = deleteMachine(client, workerMachine) @@ -446,4 +480,53 @@ var _ = g.Describe("[Feature:Machines] Managed cluster should", func() { o.Expect(err).NotTo(o.HaveOccurred()) }) + + g.It("reject invalid machinesets", func() { + var err error + client, err := e2e.LoadClient() + o.Expect(err).NotTo(o.HaveOccurred()) + + g.By("Creating invalid machineset") + invalidMachineSet := invalidMachinesetWithEmptyProviderConfig() + + err = client.Create(context.TODO(), invalidMachineSet) + o.Expect(err).NotTo(o.HaveOccurred()) + + g.By("Waiting for ReconcileError MachineSet event") + err = wait.PollImmediate(e2e.RetryMedium, e2e.WaitShort, func() (bool, error) { + eventList := corev1.EventList{} + if err := client.List(context.TODO(), nil, &eventList); err != nil { + glog.Errorf("error querying api for eventList object: %v, retrying...", err) + return false, nil + } + + glog.Infof("Fetching ReconcileError MachineSet invalid-machineset event") + for _, event := range eventList.Items { + if event.Reason != "ReconcileError" || event.InvolvedObject.Kind != "MachineSet" || event.InvolvedObject.Name != invalidMachineSet.Name { + continue + } + + glog.Infof("Found ReconcileError event for %q machine set with the following message: %v", event.InvolvedObject.Name, event.Message) + return true, nil + } + + return false, nil + }) + o.Expect(err).NotTo(o.HaveOccurred()) + + // Verify the number of machines does not grow over time. + // The assumption is once the ReconcileError event is recorded and caught, + // the machineset is not reconciled again until it's updated. + machineList := &mapiv1beta1.MachineList{} + err = client.List(context.TODO(), runtimeclient.MatchingLabels(invalidMachineSet.Spec.Template.Labels), machineList) + o.Expect(err).NotTo(o.HaveOccurred()) + + g.By(fmt.Sprintf("Verify no machine from %q machineset were created", invalidMachineSet.Name)) + glog.Infof("Have %v machines generated from %q machineset", len(machineList.Items), invalidMachineSet.Name) + o.Expect(len(machineList.Items)).To(o.BeNumerically("==", 0)) + + g.By("Deleting invalid machineset") + err = client.Delete(context.TODO(), invalidMachineSet) + o.Expect(err).NotTo(o.HaveOccurred()) + }) }) diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/infra/utils.go b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/infra/utils.go index e638d916b..8e499f2a1 100644 --- a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/infra/utils.go +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/infra/utils.go @@ -19,16 +19,14 @@ import ( "k8s.io/client-go/discovery" "k8s.io/client-go/dynamic" "k8s.io/client-go/scale" - "k8s.io/client-go/tools/cache" "k8s.io/utils/pointer" runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/apiutil" ) const ( - nodeWorkerRoleLabel = "node-role.kubernetes.io/worker" - machineRoleLabel = "machine.openshift.io/cluster-api-machine-role" - machineAPIGroup = "machine.openshift.io" + machineRoleLabel = "machine.openshift.io/cluster-api-machine-role" + machineAPIGroup = "machine.openshift.io" ) func isOneMachinePerNode(client runtimeclient.Client) bool { @@ -124,29 +122,6 @@ func getMachinesFromMachineSet(client runtimeclient.Client, machineSet mapiv1bet return machinesForSet, nil } -// getMachineFromNode returns the machine referenced by the "controllernode.MachineAnnotationKey" annotation in the given node -func getMachineFromNode(client runtimeclient.Client, node *corev1.Node) (*mapiv1beta1.Machine, error) { - machineNamespaceKey, ok := node.Annotations[controllernode.MachineAnnotationKey] - if !ok { - return nil, fmt.Errorf("node %q does not have a MachineAnnotationKey %q", node.Name, controllernode.MachineAnnotationKey) - } - namespace, machineName, err := cache.SplitMetaNamespaceKey(machineNamespaceKey) - if err != nil { - return nil, fmt.Errorf("machine annotation format is incorrect %v: %v", machineNamespaceKey, err) - } - - if namespace != e2e.TestContext.MachineApiNamespace { - return nil, fmt.Errorf("Machine %q is forbidden to live outside of default %v namespace", machineNamespaceKey, e2e.TestContext.MachineApiNamespace) - } - - machine, err := e2e.GetMachine(context.TODO(), client, machineName) - if err != nil { - return nil, fmt.Errorf("error querying api for machine object: %v", err) - } - - return machine, nil -} - // deleteMachine deletes a specific machine and returns an error otherwise func deleteMachine(client runtimeclient.Client, machine *mapiv1beta1.Machine) error { return wait.PollImmediate(1*time.Second, time.Minute, func() (bool, error) { @@ -193,28 +168,6 @@ func getNodeFromMachine(client runtimeclient.Client, machine *mapiv1beta1.Machin return &node, nil } -// getWorkerNode returns a node with the nodeWorkerRoleLabel label -func getWorkerNode(client runtimeclient.Client) (*corev1.Node, error) { - nodeList := corev1.NodeList{} - listOptions := runtimeclient.ListOptions{} - listOptions.MatchingLabels(map[string]string{nodeWorkerRoleLabel: ""}) - if err := wait.PollImmediate(1*time.Second, time.Minute, func() (bool, error) { - if err := client.List(context.TODO(), &listOptions, &nodeList); err != nil { - glog.Errorf("Error querying api for nodeList object: %v, retrying...", err) - return false, nil - } - if len(nodeList.Items) < 1 { - glog.Errorf("No nodes were found with label %q", nodeWorkerRoleLabel) - return false, nil - } - return true, nil - }); err != nil { - glog.Errorf("Error calling getWorkerMachine: %v", err) - return nil, err - } - return &nodeList.Items[0], nil -} - // nodesAreReady returns true if an array of nodes are all ready func nodesAreReady(nodes []*corev1.Node) bool { // All nodes needs to be ready @@ -373,7 +326,7 @@ func waitUntilNodesAreReady(client runtimeclient.Client, listOpt *runtimeclient. // expecting nodeGroupSize nodes readyNodes := 0 for _, node := range nodes.Items { - if _, exists := node.Labels[e2e.WorkerRoleLabel]; !exists { + if _, exists := node.Labels[e2e.WorkerNodeRoleLabel]; !exists { continue } @@ -404,7 +357,7 @@ func waitUntilNodesAreDeleted(client runtimeclient.Client, listOpt *runtimeclien // expecting nodeGroupSize nodes nodeCounter := 0 for _, node := range nodes.Items { - if _, exists := node.Labels[e2e.WorkerRoleLabel]; !exists { + if _, exists := node.Labels[e2e.WorkerNodeRoleLabel]; !exists { continue } @@ -459,7 +412,7 @@ func verifyNodeDraining(client runtimeclient.Client, targetMachine *mapiv1beta1. return false, nil } if machine.Status.NodeRef == nil || machine.Status.NodeRef.Kind != "Node" { - glog.Error("Machine %q not linked to a node", machine.Name) + glog.Errorf("Machine %q not linked to a node", machine.Name) return false, nil } diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/machinehealthcheck/machinehealthcheck.go b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/machinehealthcheck/machinehealthcheck.go index abecd6853..d045dd6a9 100644 --- a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/machinehealthcheck/machinehealthcheck.go +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/machinehealthcheck/machinehealthcheck.go @@ -57,49 +57,23 @@ var _ = Describe("[Feature:MachineHealthCheck] MachineHealthCheck controller", f client, err = e2e.LoadClient() Expect(err).ToNot(HaveOccurred()) - isKubemarkProvider, err := e2e.IsKubemarkProvider(client) - Expect(err).ToNot(HaveOccurred()) - if isKubemarkProvider { - glog.V(2).Info("Can not run this tests with the 'KubeMark' provider") - Skip("Can not run this tests with the 'KubeMark' provider") - } + // TODO: enable once https://github.com/openshift/cluster-api-actuator-pkg/pull/61 is fixed + glog.V(2).Info("Skipping machine health checking test") + Skip("Skipping machine health checking test") - listOptions := runtimeclient.ListOptions{ - Namespace: e2e.TestContext.MachineApiNamespace, - } - listOptions.SetLabelSelector(fmt.Sprintf("%s=", e2e.NodeWorkerLabel)) - workers := &corev1.NodeList{} - err = client.List(context.TODO(), &listOptions, workers) + workerNodes, err := e2e.GetWorkerNodes(client) Expect(err).ToNot(HaveOccurred()) - numberOfReadyWorkers = 0 - workerNode = nil - for i, w := range workers.Items { - readyCond := conditions.GetNodeCondition(&w, corev1.NodeReady) - if readyCond.Status == corev1.ConditionTrue { - numberOfReadyWorkers++ - if workerNode == nil { - workerNode = &workers.Items[i] - glog.V(2).Infof("Worker node %s", workerNode.Name) - } - } - } - Expect(workerNode).ToNot(BeNil()) + readyWorkerNodes := e2e.FilterReadyNodes(workerNodes) + Expect(readyWorkerNodes).ToNot(BeEmpty()) - listOptions = runtimeclient.ListOptions{ - Namespace: e2e.TestContext.MachineApiNamespace, - } - machineList := &mapiv1beta1.MachineList{} - err = client.List(context.TODO(), &listOptions, machineList) - Expect(err).ToNot(HaveOccurred()) + numberOfReadyWorkers = len(readyWorkerNodes) + workerNode = &readyWorkerNodes[0] + glog.V(2).Infof("Worker node %s", workerNode.Name) - for i, m := range machineList.Items { - if m.Status.NodeRef != nil && m.Status.NodeRef.Name == workerNode.Name { - workerMachine = &machineList.Items[i] - glog.V(2).Infof("Worker machine %s", workerMachine.Name) - } - } - Expect(workerMachine).ToNot(BeNil()) + workerMachine, err = e2e.GetMachineFromNode(client, workerNode) + Expect(err).ToNot(HaveOccurred()) + glog.V(2).Infof("Worker machine %s", workerMachine.Name) glog.V(2).Infof("Create machine health check with label selector: %s", workerMachine.Labels) err = e2e.CreateMachineHealthCheck(workerMachine.Labels) @@ -138,12 +112,9 @@ var _ = Describe("[Feature:MachineHealthCheck] MachineHealthCheck controller", f }) AfterEach(func() { - isKubemarkProvider, err := e2e.IsKubemarkProvider(client) - Expect(err).ToNot(HaveOccurred()) - if isKubemarkProvider { - glog.V(2).Info("Can not run this tests with the 'KubeMark' provider") - Skip("Can not run this tests with the 'KubeMark' provider") - } + // TODO: enable once https://github.com/openshift/cluster-api-actuator-pkg/pull/61 is fixed + glog.V(2).Info("Skipping machine health checking test") + Skip("Skipping machine health checking test") waitForWorkersToGetReady(numberOfReadyWorkers) deleteMachineHealthCheck(e2e.MachineHealthCheckName) @@ -176,28 +147,16 @@ func waitForWorkersToGetReady(numberOfReadyWorkers int) { client, err := e2e.LoadClient() Expect(err).ToNot(HaveOccurred()) - listOptions := runtimeclient.ListOptions{ - Namespace: e2e.TestContext.MachineApiNamespace, - } - listOptions.SetLabelSelector(fmt.Sprintf("%s=", e2e.NodeWorkerLabel)) - workers := &corev1.NodeList{} glog.V(2).Infof("Wait until the environment will have %d ready workers", numberOfReadyWorkers) Eventually(func() bool { - err := client.List(context.TODO(), &listOptions, workers) + workerNodes, err := e2e.GetWorkerNodes(client) if err != nil { return false } - readyWorkers := 0 - for _, w := range workers.Items { - readyCond := conditions.GetNodeCondition(&w, corev1.NodeReady) - if readyCond.Status == corev1.ConditionTrue { - readyWorkers++ - } - } - - glog.V(2).Infof("Number of ready workers %d", readyWorkers) - return readyWorkers == numberOfReadyWorkers + readyWorkerNodes := e2e.FilterReadyNodes(workerNodes) + glog.V(2).Infof("Number of ready workers %d", len(readyWorkerNodes)) + return len(readyWorkerNodes) == numberOfReadyWorkers }, 15*time.Minute, 10*time.Second).Should(BeTrue()) } @@ -225,7 +184,7 @@ func deleteKubeletKillerPods() { listOptions := runtimeclient.ListOptions{ Namespace: e2e.TestContext.MachineApiNamespace, } - listOptions.SetLabelSelector(fmt.Sprintf("%s=", e2e.KubeletKillerPodName)) + listOptions.MatchingLabels(map[string]string{e2e.KubeletKillerPodName: ""}) podList := &corev1.PodList{} err = client.List(context.TODO(), &listOptions, podList) Expect(err).ToNot(HaveOccurred()) diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/operators/machine-api-operator.go b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/operators/machine-api-operator.go index 6c3f77590..c128b831a 100644 --- a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/operators/machine-api-operator.go +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/operators/machine-api-operator.go @@ -8,6 +8,10 @@ import ( e2e "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework" ) +var ( + deploymentDeprecatedName = "clusterapi-manager-controllers" +) + var _ = g.Describe("[Feature:Operators] Machine API operator deployment should", func() { defer g.GinkgoRecover() @@ -23,9 +27,13 @@ var _ = g.Describe("[Feature:Operators] Machine API operator deployment should", client, err := e2e.LoadClient() o.Expect(err).NotTo(o.HaveOccurred()) - deploymentName := "clusterapi-manager-controllers" + deploymentName := "machine-api-controllers" initialDeployment, err := getDeployment(client, deploymentName) - o.Expect(err).NotTo(o.HaveOccurred()) + if err != nil { + initialDeployment, err = getDeployment(client, deploymentDeprecatedName) + o.Expect(err).NotTo(o.HaveOccurred()) + deploymentName = deploymentDeprecatedName + } g.By(fmt.Sprintf("checking deployment %q is available", deploymentName)) o.Expect(isDeploymentAvailable(client, deploymentName)).To(o.BeTrue()) @@ -37,7 +45,6 @@ var _ = g.Describe("[Feature:Operators] Machine API operator deployment should", g.By(fmt.Sprintf("checking deployment %q is available again", deploymentName)) o.Expect(isDeploymentAvailable(client, deploymentName)).To(o.BeTrue()) }) - }) var _ = g.Describe("[Feature:Operators] Machine API cluster operator status should", func() { diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/operators/utils.go b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/operators/utils.go index 19e9851b1..29adce076 100644 --- a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/operators/utils.go +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/operators/utils.go @@ -45,7 +45,7 @@ func deleteDeployment(client runtimeclient.Client, deployment *kappsapi.Deployme } func isDeploymentAvailable(client runtimeclient.Client, name string) bool { - if err := wait.PollImmediate(1*time.Second, e2e.WaitShort, func() (bool, error) { + if err := wait.PollImmediate(1*time.Second, e2e.WaitLong, func() (bool, error) { d, err := getDeployment(client, name) if err != nil { glog.Errorf("Error getting deployment: %v", err) @@ -84,8 +84,8 @@ func isStatusAvailable(client runtimeclient.Client, name string) bool { glog.Errorf("Condition: %q is true", osconfigv1.OperatorProgressing) return false, nil } - if cov1helpers.IsStatusConditionTrue(clusterOperator.Status.Conditions, osconfigv1.OperatorFailing) { - glog.Errorf("Condition: %q is true", osconfigv1.OperatorFailing) + if cov1helpers.IsStatusConditionTrue(clusterOperator.Status.Conditions, osconfigv1.OperatorFailing) || cov1helpers.IsStatusConditionTrue(clusterOperator.Status.Conditions, osconfigv1.OperatorDegraded) { + glog.Errorf("Condition: %q is true", osconfigv1.OperatorDegraded) return false, nil } return true, nil diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/manifests/manifests.go b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/manifests/manifests.go index d5ead12d4..dceb3efc1 100644 --- a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/manifests/manifests.go +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/manifests/manifests.go @@ -948,7 +948,7 @@ func TestingMachine(clusterID string, namespace string, providerSpec machinev1be Namespace: namespace, GenerateName: "vs-master-", Labels: map[string]string{ - "sigs.k8s.io/cluster-api-cluster": clusterID, + "machine.openshift.io/cluster-api-cluster": clusterID, }, }, Spec: machinev1beta1.MachineSpec{ @@ -958,10 +958,6 @@ func TestingMachine(clusterID string, namespace string, providerSpec machinev1be }, }, ProviderSpec: providerSpec, - Versions: machinev1beta1.MachineVersionInfo{ - Kubelet: "1.10.1", - ControlPlane: "1.10.1", - }, }, } @@ -976,15 +972,11 @@ func MasterMachine(clusterID, namespace string, providerSpec machinev1beta1.Prov Namespace: namespace, GenerateName: "vs-master-", Labels: map[string]string{ - "sigs.k8s.io/cluster-api-cluster": clusterID, + "machine.openshift.io/cluster-api-cluster": clusterID, }, }, Spec: machinev1beta1.MachineSpec{ ProviderSpec: providerSpec, - Versions: machinev1beta1.MachineVersionInfo{ - Kubelet: "1.10.1", - ControlPlane: "1.10.1", - }, }, } @@ -1050,14 +1042,14 @@ func WorkerMachineSet(clusterID, namespace string, providerSpec machinev1beta1.P Namespace: namespace, GenerateName: clusterID + "-worker-machine-" + randomUUID[:6] + "-", Labels: map[string]string{ - "sigs.k8s.io/cluster-api-cluster": clusterID, + "machine.openshift.io/cluster-api-cluster": clusterID, }, }, Spec: machinev1beta1.MachineSetSpec{ Selector: metav1.LabelSelector{ MatchLabels: map[string]string{ - "sigs.k8s.io/cluster-api-machineset": clusterID + "-worker-machineset-" + randomUUID[:6], - "sigs.k8s.io/cluster-api-cluster": clusterID, + "machine.openshift.io/cluster-api-machineset": clusterID + "-worker-machineset-" + randomUUID[:6], + "machine.openshift.io/cluster-api-cluster": clusterID, }, }, Replicas: &replicas, @@ -1065,8 +1057,8 @@ func WorkerMachineSet(clusterID, namespace string, providerSpec machinev1beta1.P ObjectMeta: metav1.ObjectMeta{ GenerateName: clusterID + "-worker-machine-" + randomUUID[:6] + "-", Labels: map[string]string{ - "sigs.k8s.io/cluster-api-machineset": clusterID + "-worker-machineset-" + randomUUID[:6], - "sigs.k8s.io/cluster-api-cluster": clusterID, + "machine.openshift.io/cluster-api-machineset": clusterID + "-worker-machineset-" + randomUUID[:6], + "machine.openshift.io/cluster-api-cluster": clusterID, }, }, Spec: machinev1beta1.MachineSpec{ @@ -1076,10 +1068,6 @@ func WorkerMachineSet(clusterID, namespace string, providerSpec machinev1beta1.P }, }, ProviderSpec: providerSpec, - Versions: machinev1beta1.MachineVersionInfo{ - Kubelet: "1.10.1", - ControlPlane: "1.10.1", - }, }, }, }, diff --git a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/manifests/userdata.go b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/manifests/userdata.go index 2a47a02e6..e96468770 100644 --- a/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/manifests/userdata.go +++ b/vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/manifests/userdata.go @@ -19,7 +19,7 @@ setenforce 0 yum install -y docker systemctl enable docker systemctl start docker -yum install -y kubelet-1.11.3 kubeadm-1.11.3 kubectl-1.11.3 --disableexcludes=kubernetes +yum install -y kubelet-1.12.3 kubeadm-1.12.3 kubectl-1.12.3 kubernetes-cni-0.6.0-0 --disableexcludes=kubernetes cat < /etc/default/kubelet KUBELET_KUBEADM_EXTRA_ARGS=--cgroup-driver=systemd @@ -70,7 +70,7 @@ setenforce 0 yum install -y docker systemctl enable docker systemctl start docker -yum install -y kubelet-1.11.3 kubeadm-1.11.3 --disableexcludes=kubernetes +yum install -y kubelet-1.12.3 kubeadm-1.12.3 kubernetes-cni-0.6.0-0 --disableexcludes=kubernetes cat < /etc/default/kubelet KUBELET_KUBEADM_EXTRA_ARGS=--cgroup-driver=systemd diff --git a/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_cluster.yaml b/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_cluster.yaml index 253ebd0d3..507760d97 100644 --- a/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_cluster.yaml +++ b/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_cluster.yaml @@ -73,20 +73,6 @@ spec: their own versioned API types that should be serialized/deserialized from this field, akin to component config. type: object - valueFrom: - description: Source for the provider configuration. Cannot be used - if value is not empty. - properties: - machineClass: - description: The machine class from which the provider config - should be sourced. - properties: - provider: - description: Provider is the name of the cloud-provider - which MachineClass is intended for. - type: string - type: object - type: object type: object required: - clusterNetwork diff --git a/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_machine.yaml b/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_machine.yaml index e78458a40..e4944fbe7 100644 --- a/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_machine.yaml +++ b/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_machine.yaml @@ -30,13 +30,6 @@ spec: type: object spec: properties: - configSource: - description: ConfigSource is used to populate in the associated Node - for dynamic kubelet config. This field already exists in Node, so - any updates to it in the Machine spec will be automatically copied - to the linked NodeRef from the status. The rest of dynamic kubelet - config support should then work as-is. - type: object metadata: description: ObjectMeta will autopopulate the Node created. Use this to indicate what labels, annotations, name prefix, etc., should be @@ -68,20 +61,6 @@ spec: their own versioned API types that should be serialized/deserialized from this field, akin to component config. type: object - valueFrom: - description: Source for the provider configuration. Cannot be used - if value is not empty. - properties: - machineClass: - description: The machine class from which the provider config - should be sourced. - properties: - provider: - description: Provider is the name of the cloud-provider - which MachineClass is intended for. - type: string - type: object - type: object type: object taints: description: Taints is the full, authoritative list of taints to apply @@ -90,25 +69,6 @@ spec: items: type: object type: array - versions: - description: Versions of key software to use. This field is optional - at cluster creation time, and omitting the field indicates that the - cluster installation tool should select defaults for the user. These - defaults may differ based on the cluster installer, but the tool should - populate the values it uses when persisting Machine objects. A Machine - spec missing this field at runtime is invalid. - properties: - controlPlane: - description: ControlPlane is the semantic version of the Kubernetes - control plane to run. This should only be populated when the machine - is a control plane. - type: string - kubelet: - description: Kubelet is the semantic version of kubelet to run - type: string - required: - - kubelet - type: object required: - providerSpec type: object @@ -120,15 +80,6 @@ spec: items: type: object type: array - conditions: - description: 'Conditions lists the conditions synced from the node conditions - of the corresponding node-object. Machine-controller is responsible - for keeping conditions up-to-date. MachineSet controller will be taking - these conditions as a signal to decide if machine is healthy or needs - to be replaced. Refer: https://kubernetes.io/docs/concepts/architecture/nodes/#condition' - items: - type: object - type: array errorMessage: description: ErrorMessage will be set in the event that there is a terminal problem reconciling the Machine and will contain a more verbose string @@ -200,30 +151,6 @@ spec: recommended that providers maintain their own versioned API types that should be serialized/deserialized from this field. type: object - versions: - description: 'Versions specifies the current versions of software on - the corresponding Node (if it exists). This is provided for a few - reasons: 1) It is more convenient than checking the NodeRef, traversing - it to the Node, and finding the appropriate field in Node.Status.NodeInfo (which - uses different field names and formatting). 2) It removes some of - the dependency on the structure of the Node, so that if the structure - of Node.Status.NodeInfo changes, only machine controllers need - to be updated, rather than every client of the Machines API. 3) - There is no other simple way to check the control plane version. - A client would have to connect directly to the apiserver running - on the target node in order to find out its version.' - properties: - controlPlane: - description: ControlPlane is the semantic version of the Kubernetes - control plane to run. This should only be populated when the machine - is a control plane. - type: string - kubelet: - description: Kubelet is the semantic version of kubelet to run - type: string - required: - - kubelet - type: object type: object version: v1beta1 status: diff --git a/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_machinedeployment.yaml b/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_machinedeployment.yaml index cd7527f39..00cd0bdf9 100644 --- a/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_machinedeployment.yaml +++ b/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_machinedeployment.yaml @@ -123,14 +123,6 @@ spec: description: 'Specification of the desired behavior of the machine. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status' properties: - configSource: - description: ConfigSource is used to populate in the associated - Node for dynamic kubelet config. This field already exists - in Node, so any updates to it in the Machine spec will be - automatically copied to the linked NodeRef from the status. - The rest of dynamic kubelet config support should then work - as-is. - type: object metadata: description: ObjectMeta will autopopulate the Node created. Use this to indicate what labels, annotations, name prefix, @@ -165,20 +157,6 @@ spec: should be serialized/deserialized from this field, akin to component config. type: object - valueFrom: - description: Source for the provider configuration. Cannot - be used if value is not empty. - properties: - machineClass: - description: The machine class from which the provider - config should be sourced. - properties: - provider: - description: Provider is the name of the cloud-provider - which MachineClass is intended for. - type: string - type: object - type: object type: object taints: description: Taints is the full, authoritative list of taints @@ -187,27 +165,6 @@ spec: items: type: object type: array - versions: - description: Versions of key software to use. This field is - optional at cluster creation time, and omitting the field - indicates that the cluster installation tool should select - defaults for the user. These defaults may differ based on - the cluster installer, but the tool should populate the values - it uses when persisting Machine objects. A Machine spec missing - this field at runtime is invalid. - properties: - controlPlane: - description: ControlPlane is the semantic version of the - Kubernetes control plane to run. This should only be populated - when the machine is a control plane. - type: string - kubelet: - description: Kubelet is the semantic version of kubelet - to run - type: string - required: - - kubelet - type: object required: - providerSpec type: object diff --git a/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_machineset.yaml b/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_machineset.yaml index 733fc975f..689896305 100644 --- a/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_machineset.yaml +++ b/vendor/github.com/openshift/cluster-api/config/crds/machine_v1beta1_machineset.yaml @@ -63,14 +63,6 @@ spec: description: 'Specification of the desired behavior of the machine. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status' properties: - configSource: - description: ConfigSource is used to populate in the associated - Node for dynamic kubelet config. This field already exists - in Node, so any updates to it in the Machine spec will be - automatically copied to the linked NodeRef from the status. - The rest of dynamic kubelet config support should then work - as-is. - type: object metadata: description: ObjectMeta will autopopulate the Node created. Use this to indicate what labels, annotations, name prefix, @@ -105,20 +97,6 @@ spec: should be serialized/deserialized from this field, akin to component config. type: object - valueFrom: - description: Source for the provider configuration. Cannot - be used if value is not empty. - properties: - machineClass: - description: The machine class from which the provider - config should be sourced. - properties: - provider: - description: Provider is the name of the cloud-provider - which MachineClass is intended for. - type: string - type: object - type: object type: object taints: description: Taints is the full, authoritative list of taints @@ -127,27 +105,6 @@ spec: items: type: object type: array - versions: - description: Versions of key software to use. This field is - optional at cluster creation time, and omitting the field - indicates that the cluster installation tool should select - defaults for the user. These defaults may differ based on - the cluster installer, but the tool should populate the values - it uses when persisting Machine objects. A Machine spec missing - this field at runtime is invalid. - properties: - controlPlane: - description: ControlPlane is the semantic version of the - Kubernetes control plane to run. This should only be populated - when the machine is a control plane. - type: string - kubelet: - description: Kubelet is the semantic version of kubelet - to run - type: string - required: - - kubelet - type: object required: - providerSpec type: object diff --git a/vendor/github.com/openshift/cluster-api/pkg/apis/machine/v1beta1/common_types.go b/vendor/github.com/openshift/cluster-api/pkg/apis/machine/v1beta1/common_types.go index 788475410..5ee990c9f 100644 --- a/vendor/github.com/openshift/cluster-api/pkg/apis/machine/v1beta1/common_types.go +++ b/vendor/github.com/openshift/cluster-api/pkg/apis/machine/v1beta1/common_types.go @@ -17,8 +17,7 @@ limitations under the License. package v1beta1 import ( - corev1 "k8s.io/api/core/v1" - runtime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime" ) // ProviderSpec defines the configuration to use during node creation. @@ -32,27 +31,4 @@ type ProviderSpec struct { // field, akin to component config. // +optional Value *runtime.RawExtension `json:"value,omitempty"` - - // Source for the provider configuration. Cannot be used if value is - // not empty. - // +optional - ValueFrom *ProviderSpecSource `json:"valueFrom,omitempty"` -} - -// ProviderSpecSource represents a source for the provider-specific -// resource configuration. -type ProviderSpecSource struct { - // The machine class from which the provider config should be sourced. - // +optional - MachineClass *MachineClassRef `json:"machineClass,omitempty"` -} - -// MachineClassRef is a reference to the MachineClass object. Controllers should find the right MachineClass using this reference. -type MachineClassRef struct { - // +optional - *corev1.ObjectReference `json:",inline"` - - // Provider is the name of the cloud-provider which MachineClass is intended for. - // +optional - Provider string `json:"provider,omitempty"` } diff --git a/vendor/github.com/openshift/cluster-api/pkg/apis/machine/v1beta1/machine_types.go b/vendor/github.com/openshift/cluster-api/pkg/apis/machine/v1beta1/machine_types.go index e7fbb4b7f..cab20ee09 100644 --- a/vendor/github.com/openshift/cluster-api/pkg/apis/machine/v1beta1/machine_types.go +++ b/vendor/github.com/openshift/cluster-api/pkg/apis/machine/v1beta1/machine_types.go @@ -17,9 +17,12 @@ limitations under the License. package v1beta1 import ( + "fmt" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" "github.com/openshift/cluster-api/pkg/apis/machine/common" ) @@ -30,6 +33,10 @@ const ( // MachineClusterLabelName is the label set on machines linked to a cluster. MachineClusterLabelName = "cluster.k8s.io/cluster-name" + + // MachineClusterIDLabel is the label that a machine must have to identify the + // cluster to which it belongs. + MachineClusterIDLabel = "machine.openshift.io/cluster-api-cluster" ) // +genclient @@ -68,23 +75,6 @@ type MachineSpec struct { // +optional ProviderSpec ProviderSpec `json:"providerSpec"` - // Versions of key software to use. This field is optional at cluster - // creation time, and omitting the field indicates that the cluster - // installation tool should select defaults for the user. These - // defaults may differ based on the cluster installer, but the tool - // should populate the values it uses when persisting Machine objects. - // A Machine spec missing this field at runtime is invalid. - // +optional - Versions MachineVersionInfo `json:"versions,omitempty"` - - // ConfigSource is used to populate in the associated Node for dynamic kubelet config. This - // field already exists in Node, so any updates to it in the Machine - // spec will be automatically copied to the linked NodeRef from the - // status. The rest of dynamic kubelet config support should then work - // as-is. - // +optional - ConfigSource *corev1.NodeConfigSource `json:"configSource,omitempty"` - // ProviderID is the identification ID of the machine provided by the provider. // This field must match the provider ID as seen on the node object corresponding to this machine. // This field is required by higher level consumers of cluster-api. Example use case is cluster autoscaler @@ -112,22 +102,6 @@ type MachineStatus struct { // +optional LastUpdated *metav1.Time `json:"lastUpdated,omitempty"` - // Versions specifies the current versions of software on the corresponding Node (if it - // exists). This is provided for a few reasons: - // - // 1) It is more convenient than checking the NodeRef, traversing it to - // the Node, and finding the appropriate field in Node.Status.NodeInfo - // (which uses different field names and formatting). - // 2) It removes some of the dependency on the structure of the Node, - // so that if the structure of Node.Status.NodeInfo changes, only - // machine controllers need to be updated, rather than every client - // of the Machines API. - // 3) There is no other simple way to check the control plane - // version. A client would have to connect directly to the apiserver - // running on the target node in order to find out its version. - // +optional - Versions *MachineVersionInfo `json:"versions,omitempty"` - // ErrorReason will be set in the event that there is a terminal problem // reconciling the Machine and will contain a succinct value suitable // for machine interpretation. @@ -177,14 +151,6 @@ type MachineStatus struct { // +optional Addresses []corev1.NodeAddress `json:"addresses,omitempty"` - // Conditions lists the conditions synced from the node conditions of the corresponding node-object. - // Machine-controller is responsible for keeping conditions up-to-date. - // MachineSet controller will be taking these conditions as a signal to decide if - // machine is healthy or needs to be replaced. - // Refer: https://kubernetes.io/docs/concepts/architecture/nodes/#condition - // +optional - Conditions []corev1.NodeCondition `json:"conditions,omitempty"` - // LastOperation describes the last-operation performed by the machine-controller. // This API should be useful as a history in terms of the latest operation performed on the // specific machine. It should also convey the state of the latest-operation for example if @@ -215,21 +181,24 @@ type LastOperation struct { Type *string `json:"type,omitempty"` } -/// [MachineStatus] - /// [MachineVersionInfo] -type MachineVersionInfo struct { - // Kubelet is the semantic version of kubelet to run - Kubelet string `json:"kubelet"` - // ControlPlane is the semantic version of the Kubernetes control plane to - // run. This should only be populated when the machine is a - // control plane. - // +optional - ControlPlane string `json:"controlPlane,omitempty"` -} +func (m *Machine) Validate() field.ErrorList { + errors := field.ErrorList{} -/// [MachineVersionInfo] + // validate spec.labels + fldPath := field.NewPath("spec") + if m.Labels[MachineClusterIDLabel] == "" { + errors = append(errors, field.Invalid(fldPath.Child("labels"), m.Labels, fmt.Sprintf("missing %v label.", MachineClusterIDLabel))) + } + + // validate provider config is set + if m.Spec.ProviderSpec.Value == nil { + errors = append(errors, field.Invalid(fldPath.Child("spec").Child("providerspec"), m.Spec.ProviderSpec, "value field must be set")) + } + + return errors +} // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/vendor/github.com/openshift/cluster-api/pkg/apis/machine/v1beta1/zz_generated.deepcopy.go b/vendor/github.com/openshift/cluster-api/pkg/apis/machine/v1beta1/zz_generated.deepcopy.go index c7535569a..ec66da125 100644 --- a/vendor/github.com/openshift/cluster-api/pkg/apis/machine/v1beta1/zz_generated.deepcopy.go +++ b/vendor/github.com/openshift/cluster-api/pkg/apis/machine/v1beta1/zz_generated.deepcopy.go @@ -289,27 +289,6 @@ func (in *MachineClassList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MachineClassRef) DeepCopyInto(out *MachineClassRef) { - *out = *in - if in.ObjectReference != nil { - in, out := &in.ObjectReference, &out.ObjectReference - *out = new(v1.ObjectReference) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineClassRef. -func (in *MachineClassRef) DeepCopy() *MachineClassRef { - if in == nil { - return nil - } - out := new(MachineClassRef) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachineDeployment) DeepCopyInto(out *MachineDeployment) { *out = *in @@ -632,12 +611,6 @@ func (in *MachineSpec) DeepCopyInto(out *MachineSpec) { } } in.ProviderSpec.DeepCopyInto(&out.ProviderSpec) - out.Versions = in.Versions - if in.ConfigSource != nil { - in, out := &in.ConfigSource, &out.ConfigSource - *out = new(v1.NodeConfigSource) - (*in).DeepCopyInto(*out) - } if in.ProviderID != nil { in, out := &in.ProviderID, &out.ProviderID *out = new(string) @@ -668,11 +641,6 @@ func (in *MachineStatus) DeepCopyInto(out *MachineStatus) { in, out := &in.LastUpdated, &out.LastUpdated *out = (*in).DeepCopy() } - if in.Versions != nil { - in, out := &in.Versions, &out.Versions - *out = new(MachineVersionInfo) - **out = **in - } if in.ErrorReason != nil { in, out := &in.ErrorReason, &out.ErrorReason *out = new(common.MachineStatusError) @@ -693,13 +661,6 @@ func (in *MachineStatus) DeepCopyInto(out *MachineStatus) { *out = make([]v1.NodeAddress, len(*in)) copy(*out, *in) } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]v1.NodeCondition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } if in.LastOperation != nil { in, out := &in.LastOperation, &out.LastOperation *out = new(LastOperation) @@ -741,22 +702,6 @@ func (in *MachineTemplateSpec) DeepCopy() *MachineTemplateSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MachineVersionInfo) DeepCopyInto(out *MachineVersionInfo) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineVersionInfo. -func (in *MachineVersionInfo) DeepCopy() *MachineVersionInfo { - if in == nil { - return nil - } - out := new(MachineVersionInfo) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NetworkRanges) DeepCopyInto(out *NetworkRanges) { *out = *in @@ -786,11 +731,6 @@ func (in *ProviderSpec) DeepCopyInto(out *ProviderSpec) { *out = new(runtime.RawExtension) (*in).DeepCopyInto(*out) } - if in.ValueFrom != nil { - in, out := &in.ValueFrom, &out.ValueFrom - *out = new(ProviderSpecSource) - (*in).DeepCopyInto(*out) - } return } @@ -803,24 +743,3 @@ func (in *ProviderSpec) DeepCopy() *ProviderSpec { in.DeepCopyInto(out) return out } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ProviderSpecSource) DeepCopyInto(out *ProviderSpecSource) { - *out = *in - if in.MachineClass != nil { - in, out := &in.MachineClass, &out.MachineClass - *out = new(MachineClassRef) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderSpecSource. -func (in *ProviderSpecSource) DeepCopy() *ProviderSpecSource { - if in == nil { - return nil - } - out := new(ProviderSpecSource) - in.DeepCopyInto(out) - return out -} diff --git a/vendor/github.com/openshift/cluster-api/pkg/controller/machine/BUILD.bazel b/vendor/github.com/openshift/cluster-api/pkg/controller/machine/BUILD.bazel index ee70c72ae..006b431d2 100644 --- a/vendor/github.com/openshift/cluster-api/pkg/controller/machine/BUILD.bazel +++ b/vendor/github.com/openshift/cluster-api/pkg/controller/machine/BUILD.bazel @@ -38,14 +38,17 @@ go_test( "controller_test.go", "machine_controller_suite_test.go", "machine_controller_test.go", + "openshift_controller_test.go", ], embed = [":go_default_library"], deps = [ "//pkg/apis:go_default_library", "//pkg/apis/cluster/v1alpha1:go_default_library", "//pkg/apis/machine/v1beta1:go_default_library", + "//pkg/controller/error:go_default_library", "//vendor/golang.org/x/net/context:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", "//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library", "//vendor/k8s.io/client-go/rest:go_default_library", diff --git a/vendor/github.com/openshift/cluster-api/pkg/controller/machine/controller.go b/vendor/github.com/openshift/cluster-api/pkg/controller/machine/controller.go index c47a6f743..e216e749b 100644 --- a/vendor/github.com/openshift/cluster-api/pkg/controller/machine/controller.go +++ b/vendor/github.com/openshift/cluster-api/pkg/controller/machine/controller.go @@ -127,6 +127,13 @@ func (r *ReconcileMachine) Reconcile(request reconcile.Request) (reconcile.Resul name := m.Name klog.Infof("Reconciling Machine %q", name) + if errList := m.Validate(); len(errList) > 0 { + err := fmt.Errorf("%q machine validation failed: %v", m.Name, errList.ToAggregate().Error()) + klog.Error(err) + r.eventRecorder.Eventf(m, corev1.EventTypeWarning, "FailedValidate", err.Error()) + return reconcile.Result{}, err + } + // Cluster might be nil as some providers might not require a cluster object // for machine management. cluster, err := r.getCluster(ctx, m) @@ -178,7 +185,7 @@ func (r *ReconcileMachine) Reconcile(request reconcile.Request) (reconcile.Resul } if !r.isDeleteAllowed(m) { - klog.Infof("Skipping reconciling of machine %q", name) + klog.Infof("Deleting machine hosting this controller is not allowed. Skipping reconciliation of machine %q", name) return reconcile.Result{}, nil } @@ -191,18 +198,13 @@ func (r *ReconcileMachine) Reconcile(request reconcile.Request) (reconcile.Resul // deleted without a manual intervention. if _, exists := m.ObjectMeta.Annotations[ExcludeNodeDrainingAnnotation]; !exists && m.Status.NodeRef != nil { if err := r.drainNode(m); err != nil { - return reconcile.Result{}, err + return delayIfRequeueAfterError(err) } } if err := r.actuator.Delete(ctx, cluster, m); err != nil { - if requeueErr, ok := err.(*controllerError.RequeueAfterError); ok { - klog.Infof("Actuator returned requeue-after error: %v", requeueErr) - return reconcile.Result{Requeue: true, RequeueAfter: requeueErr.RequeueAfter}, nil - } - klog.Errorf("Failed to delete machine %q: %v", name, err) - return reconcile.Result{}, err + return delayIfRequeueAfterError(err) } if m.Status.NodeRef != nil { @@ -233,28 +235,17 @@ func (r *ReconcileMachine) Reconcile(request reconcile.Request) (reconcile.Resul if exist { klog.Infof("Reconciling machine %q triggers idempotent update", name) if err := r.actuator.Update(ctx, cluster, m); err != nil { - if requeueErr, ok := err.(*controllerError.RequeueAfterError); ok { - klog.Infof("Actuator returned requeue-after error: %v", requeueErr) - return reconcile.Result{Requeue: true, RequeueAfter: requeueErr.RequeueAfter}, nil - } - klog.Errorf(`Error updating machine "%s/%s": %v`, m.Namespace, name, err) - return reconcile.Result{}, err + return delayIfRequeueAfterError(err) } - return reconcile.Result{}, nil } // Machine resource created. Machine does not yet exist. klog.Infof("Reconciling machine object %v triggers idempotent create.", m.ObjectMeta.Name) if err := r.actuator.Create(ctx, cluster, m); err != nil { - if requeueErr, ok := err.(*controllerError.RequeueAfterError); ok { - klog.Infof("Actuator returned requeue-after error: %v", requeueErr) - return reconcile.Result{Requeue: true, RequeueAfter: requeueErr.RequeueAfter}, nil - } - klog.Warningf("Failed to create machine %q: %v", name, err) - return reconcile.Result{}, err + return delayIfRequeueAfterError(err) } return reconcile.Result{}, nil @@ -297,7 +288,7 @@ func (r *ReconcileMachine) drainNode(machine *machinev1.Machine) error { func (r *ReconcileMachine) getCluster(ctx context.Context, machine *machinev1.Machine) (*machinev1.Cluster, error) { if machine.Labels[machinev1.MachineClusterLabelName] == "" { - klog.Infof("Machine %q in namespace %q doesn't specify %q label, assuming nil cluster", machine.Name, machinev1.MachineClusterLabelName, machine.Namespace) + klog.Infof("Machine %q in namespace %q doesn't specify %q label, assuming nil cluster", machine.Name, machine.Namespace, machinev1.MachineClusterLabelName) return nil, nil } @@ -347,3 +338,12 @@ func (r *ReconcileMachine) deleteNode(ctx context.Context, name string) error { } return r.Client.Delete(ctx, &node) } + +func delayIfRequeueAfterError(err error) (reconcile.Result, error) { + switch t := err.(type) { + case *controllerError.RequeueAfterError: + klog.Infof("Actuator returned requeue-after error: %v", err) + return reconcile.Result{Requeue: true, RequeueAfter: t.RequeueAfter}, nil + } + return reconcile.Result{}, err +} diff --git a/vendor/github.com/openshift/cluster-api/pkg/controller/machinedeployment/controller.go b/vendor/github.com/openshift/cluster-api/pkg/controller/machinedeployment/controller.go index 67e9c3894..e986773f0 100644 --- a/vendor/github.com/openshift/cluster-api/pkg/controller/machinedeployment/controller.go +++ b/vendor/github.com/openshift/cluster-api/pkg/controller/machinedeployment/controller.go @@ -271,7 +271,7 @@ func (r *ReconcileMachineDeployment) reconcile(ctx context.Context, d *v1beta1.M func (r *ReconcileMachineDeployment) getCluster(d *v1beta1.MachineDeployment) (*v1beta1.Cluster, error) { if d.Spec.Template.Labels[v1beta1.MachineClusterLabelName] == "" { - klog.Infof("Deployment %q in namespace %q doesn't specify %q label, assuming nil cluster", d.Name, v1beta1.MachineClusterLabelName, d.Namespace) + klog.Infof("Deployment %q in namespace %q doesn't specify %q label, assuming nil cluster", d.Name, d.Namespace, v1beta1.MachineClusterLabelName) return nil, nil } diff --git a/vendor/github.com/openshift/cluster-api/pkg/controller/machineset/controller.go b/vendor/github.com/openshift/cluster-api/pkg/controller/machineset/controller.go index 48d8d3cfa..421179ef2 100644 --- a/vendor/github.com/openshift/cluster-api/pkg/controller/machineset/controller.go +++ b/vendor/github.com/openshift/cluster-api/pkg/controller/machineset/controller.go @@ -293,7 +293,7 @@ func (r *ReconcileMachineSet) reconcile(ctx context.Context, machineSet *machine func (r *ReconcileMachineSet) getCluster(ms *machinev1beta1.MachineSet) (*machinev1beta1.Cluster, error) { if ms.Spec.Template.Labels[machinev1beta1.MachineClusterLabelName] == "" { - klog.Infof("MachineSet %q in namespace %q doesn't specify %q label, assuming nil cluster", ms.Name, machinev1beta1.MachineClusterLabelName, ms.Namespace) + klog.Infof("MachineSet %q in namespace %q doesn't specify %q label, assuming nil cluster", ms.Name, ms.Namespace, machinev1beta1.MachineClusterLabelName) return nil, nil } diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/Gopkg.lock b/vendor/github.com/openshift/cluster-autoscaler-operator/Gopkg.lock index 93f4722c7..8d470fec1 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/Gopkg.lock +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/Gopkg.lock @@ -1,14 +1,6 @@ # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. -[[projects]] - digest = "1:2173c429b0c4654deb4f3e8d1f503c374f93a6b5549d74f9cba797c1e787f8e4" - name = "cloud.google.com/go" - packages = ["compute/metadata"] - pruneopts = "NT" - revision = "c9474f2f8deb81759839474b6bd1726bbfe1c1c4" - version = "v0.36.0" - [[projects]] digest = "1:0a111edd8693fd977f42a0c4f199a0efb13c20aec9da99ad8830c7bb6a87e8d6" name = "github.com/PuerkitoBio/purell" @@ -25,6 +17,14 @@ pruneopts = "NT" revision = "de5bf2ad457846296e2031421a34e2568e304e35" +[[projects]] + digest = "1:680b63a131506e668818d630d3ca36123ff290afa0afc9f4be21940adca3f27d" + name = "github.com/appscode/jsonpatch" + packages = ["."] + pruneopts = "NT" + revision = "7c0e3b262f30165a8ec3d0b4c6059fd92703bfb2" + version = "1.0.0" + [[projects]] branch = "master" digest = "1:c819830f4f5ef85874a90ac3cbcc96cd322c715f5c96fbe4722eacd3dafbaa07" @@ -50,15 +50,23 @@ version = "v1.1.1" [[projects]] - digest = "1:2453249730493850718f891fb40b8f1bc932a0265384fc85b269dc04a01d4673" + digest = "1:1302bdd23af4264a095d48c2c28660a8ecf2e02454ce172cef5cb946029a1383" name = "github.com/emicklei/go-restful" packages = [ ".", "log", ] pruneopts = "NT" - revision = "85d198d05a92d31823b852b4a5928114912e8949" - version = "v2.9.0" + revision = "b9bbc5664f49b6deec52393bd68f39830687a347" + version = "v2.9.3" + +[[projects]] + digest = "1:820227d03dc661d34f837f3704626d2837dbfbf9f0ec8fdf1f58e683dc5f56fc" + name = "github.com/evanphx/json-patch" + packages = ["."] + pruneopts = "NT" + revision = "72bf35d0ff611848c1dc9df0f976c81192392fa5" + version = "v4.1.0" [[projects]] digest = "1:81466b4218bf6adddac2572a30ac733a9255919bc2f470b4827a317bd4ee1756" @@ -69,20 +77,20 @@ version = "v1.0.0" [[projects]] - branch = "master" digest = "1:d421af4c4fe51d399667d573982d663fe1fa67020a88d3ae43466ebfe8e2b5c9" name = "github.com/go-logr/logr" packages = ["."] pruneopts = "NT" revision = "9fb12b3b21c5415d16ac18dc5cd42c1cfdd40c4e" + version = "v0.1.0" [[projects]] digest = "1:340497a512995aa69c0add901d79a2096b3449d35a44a6f1f1115091a9f8c687" name = "github.com/go-logr/zapr" packages = ["."] pruneopts = "NT" - revision = "7536572e8d55209135cd5e7ccf7fce43dca217ab" - version = "v0.1.0" + revision = "03f06a783fbb7dfaf3f629c7825480e43a7105e6" + version = "v0.1.1" [[projects]] digest = "1:260f7ebefc63024c8dfe2c9f1a2935a89fa4213637a1f522f592f80c001cc441" @@ -90,7 +98,7 @@ packages = ["."] pruneopts = "NT" revision = "ef5f0afec364d3b9396b7b77b43dbe26bf1f8004" - version = "v0.18.0" + version = "v0.19.0" [[projects]] digest = "1:98abd61947ff5c7c6fcfec5473d02a4821ed3a2dd99a4fbfdb7925b0dd745546" @@ -98,23 +106,23 @@ packages = ["."] pruneopts = "NT" revision = "8483a886a90412cd6858df4ea3483dce9c8e35a3" - version = "v0.18.0" + version = "v0.19.0" [[projects]] - digest = "1:4da4ea0a664ba528965683d350f602d0f11464e6bb2e17aad0914723bc25d163" + digest = "1:8f80caf2fa31f78a035f33981c9685013033073b53f344f579e60fa69f0c6670" name = "github.com/go-openapi/spec" packages = ["."] pruneopts = "NT" - revision = "5b6cdde3200976e3ecceb2868706ee39b6aff3e4" - version = "v0.18.0" + revision = "53d776530bf78a11b03a7b52dd8a083086b045e5" + version = "v0.19.0" [[projects]] - digest = "1:dc0f590770e5a6c70ea086232324f7b7dc4857c60eca63ab8ff78e0a5cfcdbf3" + digest = "1:076ebf43e6e70f18ef9d079a685ede59a0f4dc9247256c209cf57407f959cef9" name = "github.com/go-openapi/swag" packages = ["."] pruneopts = "NT" - revision = "1d29f06aebd59ccdf11ae04aa0334ded96e2d909" - version = "v0.18.0" + revision = "b3e2804c8535ee0d1b89320afd98474d5b8e9e3b" + version = "v0.19.0" [[projects]] digest = "1:0b39706cfa32c1ba9e14435b5844d04aef81b60f44b6077e61e0607d56692603" @@ -144,7 +152,7 @@ revision = "5b532d6fd5efaf7fa130d4e859a2fde0fc3a9e1b" [[projects]] - digest = "1:2bac1ab777481a7ef169837f0eeac25a1a6628ac93aef853168681dfec4a653c" + digest = "1:d7212166c4b7f30a20fb3de70ab7e36564900b2e36360ffd31958b5af8fed025" name = "github.com/golang/protobuf" packages = [ "proto", @@ -154,16 +162,16 @@ "ptypes/timestamp", ] pruneopts = "NT" - revision = "c823c79ea1570fb5ff454033735a8e68575d1d0f" - version = "v1.3.0" + revision = "b5d812f8a3706043e23a9cd5babf2e5423744d30" + version = "v1.3.1" [[projects]] - branch = "master" digest = "1:05f95ffdfcf651bdb0f05b40b69e7f5663047f8da75c72d58728acb59b5cc107" name = "github.com/google/btree" packages = ["."] pruneopts = "NT" revision = "4030bb1f1f0c35b30ca7009e9ebd06849dd45306" + version = "v1.0.0" [[projects]] branch = "master" @@ -238,16 +246,16 @@ version = "v0.3.7" [[projects]] - digest = "1:1d39c063244ad17c4b18e8da1551163b6ffb52bd1640a49a8ec5c3b7bf4dbd5d" + digest = "1:0fbdc0dfdabfa16d50dd7151b7efe3189ffb0df68fa9866dc35240bfea39ad92" name = "github.com/json-iterator/go" packages = ["."] pruneopts = "NT" - revision = "1624edc4454b8682399def8740d46db5e4362ba4" - version = "v1.1.5" + revision = "0ff49de124c6f76f8494e194af75bde0f1a49a29" + version = "v1.1.6" [[projects]] branch = "master" - digest = "1:4925ec3736ef6c299cfcf61597782e3d66ec13114f7476019d04c742a7be55d0" + digest = "1:1832b664bdd6ff3139a8590c907044d7d440cd10fa46979d89fe98a11b75b256" name = "github.com/mailru/easyjson" packages = [ "buffer", @@ -255,15 +263,7 @@ "jwriter", ] pruneopts = "NT" - revision = "6243d8e04c3f819e79757e8bc3faa15c3cb27003" - -[[projects]] - branch = "master" - digest = "1:0e9bfc47ab9941ecc3344e580baca5deb4091177e84dd9773b48b38ec26b93d5" - name = "github.com/mattbaird/jsonpatch" - packages = ["."] - pruneopts = "NT" - revision = "81af80346b1a01caae0cbc27fd3c1ba5b11e189f" + revision = "1de009706dbeb9d05f18586f0735fcdb7c524481" [[projects]] digest = "1:ea1db000388d88b31db7531c83016bef0d6db0d908a07794bfc36aca16fbf935" @@ -290,7 +290,7 @@ version = "1.0.1" [[projects]] - digest = "1:0204417af2b5c56719f7e2809902c9a56ebb1b539d73ba520eeac84e98f21b72" + digest = "1:545744762d3d6d59328a38e44f571baaeda30184b88b43a28879bedf7711afa5" name = "github.com/onsi/ginkgo" packages = [ ".", @@ -313,11 +313,11 @@ "types", ] pruneopts = "NT" - revision = "2e1be8f7d90e9d3e3e58b0ce470f2f14d075406f" - version = "v1.7.0" + revision = "eea6ad008b96acdaa524f5b409513bf062b500ad" + version = "v1.8.0" [[projects]] - digest = "1:7efa6868c0394e8567b411d9160f10376d6f28926c5786d520f3603bc3e18198" + digest = "1:9f353a779b8b118229dfc1541e41d72d1a3a6f2d13756f5fe66daeb0f52191ab" name = "github.com/onsi/gomega" packages = [ ".", @@ -334,23 +334,22 @@ "types", ] pruneopts = "NT" - revision = "65fb64232476ad9046e57c26cd0bff3d3a8dc6cd" - version = "v1.4.3" + revision = "90e289841c1ed79b7a598a7cd9959750cb5e89e2" + version = "v1.5.0" [[projects]] - branch = "master" - digest = "1:d81228aec193f40dc8ed219ebd607a88dac61bed2b12f8003a588ce5aa74c91d" + digest = "1:089d12b21181b39d795d8e62e1197ec1ea61afe393f0d2abf12339d888d7357e" name = "github.com/openshift/api" packages = [ "config/v1", "security/v1", ] pruneopts = "NT" - revision = "c58918e29f89383d2e1467bad7156e2b0c49497f" + revision = "8e476cb7322e59919cbb6482fd076ec5a214df25" [[projects]] branch = "master" - digest = "1:020cce845c0b03af242c1490f1e300c1dc02c64c7fdf6423af70462e90b34617" + digest = "1:a5aa6d074656d7cd97b9e1744f2c79244b8bc37ffb67cb31c47298010092c881" name = "github.com/openshift/client-go" packages = [ "config/clientset/versioned", @@ -360,10 +359,11 @@ "config/clientset/versioned/typed/config/v1/fake", ] pruneopts = "NT" - revision = "31ef839c86359881d2c312c4f0131febc6662400" + revision = "7cc0953bbbb7925e30232c056606d666942bb542" [[projects]] - digest = "1:8dd66f623f950b0b5d91c96e8eb469f4b7eb506c371136ce1e7b4408398cdddb" + branch = "openshift-4.0-cluster-api-0.0.0-alpha.4" + digest = "1:9b3599b2a72b85979c01c1991927dda9517417e23d72a070fad86b4fbda54bd5" name = "github.com/openshift/cluster-api" packages = [ "pkg/apis/cluster/common", @@ -379,40 +379,54 @@ "pkg/util", ] pruneopts = "NT" - revision = "0c3e884db79556cf786aa8436f5be977ef10c211" + revision = "5e580f96e63e5db1fc8095ca5f587716a4a8d9e9" [[projects]] branch = "master" - digest = "1:fda26b4b3cc8dc89575c57b4c141db0cf03051c65a7296e143683e1bd8aa9962" + digest = "1:eafab113b2b239ce2084185e26910539af8762ce72d6b64ddf465fa9a1c312d9" name = "github.com/openshift/cluster-api-actuator-pkg" packages = [ "pkg/e2e", - "pkg/e2e/actuators", "pkg/e2e/autoscaler", "pkg/e2e/framework", "pkg/e2e/infra", + "pkg/e2e/machinehealthcheck", "pkg/e2e/operators", "pkg/manifests", "pkg/types", ] pruneopts = "N" - revision = "6da15dab1653f3bc0d878366ce9f7c91e4ba08d0" + revision = "cd01e806d9c5624889678f4893da3d228a791a2e" [[projects]] branch = "master" - digest = "1:225f3203c014b4b8c94b89c0b6003997e502c670b224fbbb868053c79c6a4a47" + digest = "1:67bee13d597afd627a9eb8c126765b1ce852a1846cfdda7fe573b4725a8ed9ad" name = "github.com/openshift/cluster-version-operator" packages = ["lib/resourcemerge"] pruneopts = "NT" - revision = "70c0232ed95e4b0e0cd78efdcdec6f2410f592bb" + revision = "f355f763fb0a1fc0fd016b02d7b043e64bdb8938" [[projects]] branch = "master" - digest = "1:e3844be1ab2695aa21d64bde33812079709600cd8ad5a91018a7c1bf07a32089" + digest = "1:009f4e6c084242edc88223d0f2a4cfeaec47ebdb5e8b93314c52eb5fbf421063" name = "github.com/openshift/library-go" packages = ["pkg/config/clusteroperator/v1helpers"] pruneopts = "NT" - revision = "0e0c8d01a19e8a9f2e517596557f4494a2490d88" + revision = "dab26bb3a8dc7fccde7227194af755bbff30ce5d" + +[[projects]] + digest = "1:92a5a6bfc5b3b2cb1189f6408de941646b366cb67a11b3b7513d56ccd7cbd7c0" + name = "github.com/openshift/machine-api-operator" + packages = [ + "pkg/apis/healthchecking", + "pkg/apis/healthchecking/v1alpha1", + "pkg/generated/clientset/versioned", + "pkg/generated/clientset/versioned/scheme", + "pkg/generated/clientset/versioned/typed/healthchecking/v1alpha1", + "pkg/util/conditions", + ] + pruneopts = "NT" + revision = "9650e16c98802a4b57b7551201b0973fcae2f738" [[projects]] digest = "1:93b1d84c5fa6d1ea52f4114c37714cddd84d5b78f151b62bb101128dd51399bf" @@ -488,17 +502,11 @@ [[projects]] branch = "master" - digest = "1:1c282f5c094061ce301d1ea3098799fc907ac1399e9f064c463787323a7b7340" + digest = "1:75f1b9f32d4d204eac68f3427bc4642453fb4fe20f1596ec058757f01dc16e7b" name = "github.com/prometheus/procfs" - packages = [ - ".", - "internal/util", - "iostats", - "nfs", - "xfs", - ] + packages = ["."] pruneopts = "NT" - revision = "bbced9601137e764853b2fad7ec3e2dc4c504e02" + revision = "ea9eea63887261e4d8ed8315f4078e88d540c725" [[projects]] digest = "1:9d8420bbf131d1618bde6530af37c3799340d3762cc47210c1d9532a4c3a2779" @@ -549,7 +557,7 @@ [[projects]] branch = "master" - digest = "1:cb5a25c74941338785e146140b698349d96c78599c6d7e9570a4725303a85c91" + digest = "1:2c0b9b49d155596fecc071bce8db372c193f638265c11ab24914aae99fcfa704" name = "golang.org/x/crypto" packages = [ "curve25519", @@ -562,11 +570,11 @@ "ssh/terminal", ] pruneopts = "NT" - revision = "31a38585487a4b1fd6ff4f8f3db26f1fb296ac82" + revision = "a5d413f7728c81fb97d96a2b722368945f651e78" [[projects]] branch = "master" - digest = "1:7514a961568b6f5d2a114b82de007f4714a27c65dffc71433fe8620a8a9db708" + digest = "1:318eeba3eb64a2c2b6fdaa988b6d08dadde9ec7b6ff909d72dd87735be65f7d9" name = "golang.org/x/net" packages = [ "context", @@ -580,32 +588,30 @@ "idna", ] pruneopts = "NT" - revision = "c95aed5357e77a4bf7d3955c46740000a17adee1" + revision = "74de082e2cca95839e88aa0aeee5aadf6ce7710f" [[projects]] branch = "master" - digest = "1:3418b2325cb0e56bb54774c4e484a2d8829b1fe4bad1c5f077cfd08d138a9a9f" + digest = "1:54c605b4036ec49dbc4c887969128d5ee68140cf0bbec46e67cbb2497e69c15e" name = "golang.org/x/oauth2" packages = [ ".", - "google", "internal", - "jws", - "jwt", ] pruneopts = "NT" - revision = "e64efc72b421e893cbf63f17ba2221e7d6d0b0f3" + revision = "9f3314589c9a9136388751d9adae6b0ed400978a" [[projects]] branch = "master" - digest = "1:f2c030d3f273165fb333d1b402a60f9c9afa4e9c167465596ac88d79c799602f" + digest = "1:e2fd9ef1691f1a2731d69db8b523d1b6c88ec583f56e3bd40e3468948b5418e6" name = "golang.org/x/sys" packages = [ + "cpu", "unix", "windows", ] pruneopts = "NT" - revision = "92a0ff1e1e2f61773648454ec71ec0c0f1c700a2" + revision = "baf5eb976a8cd65845293cd814ea151018552292" [[projects]] digest = "1:8c74f97396ed63cc2ef04ebb5fc37bb032871b8fd890a25991ed40974b00cd2a" @@ -649,16 +655,15 @@ name = "golang.org/x/time" packages = ["rate"] pruneopts = "NT" - revision = "85acf8d2951cb2a3bde7632f9ff273ef0379bcbd" + revision = "9d24e82272b4f38b78bc8cff74fa936d31ccd8ef" [[projects]] branch = "master" - digest = "1:509a5a08fc8545a714ac3ffbad721fd03fb2936aa31c8d12a74641f7b3303095" + digest = "1:e9de94093a593289a2816dcac941c8c7d63007a407f3727bb6777d7b793c308f" name = "golang.org/x/tools" packages = [ "go/ast/astutil", "go/gcexportdata", - "go/internal/cgo", "go/internal/gcimporter", "go/internal/packagesdriver", "go/packages", @@ -670,26 +675,23 @@ "internal/semver", ] pruneopts = "NT" - revision = "f0a709d59f0fd2d705cf7767149e23a7a99f585b" + revision = "202502a5a9245830b5ec7b877e26b67760da8e67" [[projects]] - digest = "1:902ffa11f1d8c19c12b05cabffe69e1a16608ad03a8899ebcb9c6bde295660ae" + digest = "1:711179d92dbef98932acd7afd0dab80b4cf2d97f099f3285c9ba8fa451809fec" name = "google.golang.org/appengine" packages = [ - ".", "internal", - "internal/app_identity", "internal/base", "internal/datastore", "internal/log", - "internal/modules", "internal/remote_api", "internal/urlfetch", "urlfetch", ] pruneopts = "NT" - revision = "e9657d882bb81064595ca3b56cbe2546bbabf7b1" - version = "v1.4.0" + revision = "54a98f90d1c46b7731eb8fb305d2a321c30ef610" + version = "v1.5.0" [[projects]] digest = "1:1b91ae0dc69a41d4c2ed23ea5cffb721ea63f5037ca4b81e6d6771fbb8f45129" @@ -725,7 +727,7 @@ version = "v2.2.2" [[projects]] - digest = "1:b3f8152a68d73095a40fdcf329a93fc42e8eadb3305171df23fdb6b4e41a6417" + digest = "1:18b9b70bdf29da610c0df032cf60ee7526a48756fa44012cc639dcb557335cbc" name = "k8s.io/api" packages = [ "admission/v1beta1", @@ -734,6 +736,7 @@ "apps/v1", "apps/v1beta1", "apps/v1beta2", + "auditregistration/v1alpha1", "authentication/v1", "authentication/v1beta1", "authorization/v1", @@ -762,11 +765,11 @@ "storage/v1beta1", ] pruneopts = "NT" - revision = "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" - version = "kubernetes-1.12.5" + revision = "5cb15d34447165a97c76ed5a60e4e99c8a01ecfe" + version = "kubernetes-1.13.4" [[projects]] - digest = "1:82b4765488fd2a8bcefb93e196fdbfe342d33b16ae073a6f51bb4fb13e81e102" + digest = "1:c6f23048e162e65d586c809fd02e263e180ad157f110df17437c22517bb59a4b" name = "k8s.io/apiextensions-apiserver" packages = [ "pkg/apis/apiextensions", @@ -776,11 +779,12 @@ "pkg/client/clientset/clientset/typed/apiextensions/v1beta1", ] pruneopts = "NT" - revision = "a384d17938fe55d54a52d5668bf0ff40044daef0" - version = "kubernetes-1.12.5" + revision = "d002e88f6236312f0289d9d1deab106751718ff0" + source = "https://github.com/openshift/kubernetes-apiextensions-apiserver.git" + version = "kubernetes-1.13.4" [[projects]] - digest = "1:14a6fa7d7afcbaa4dc8dcc7db435f7e176e51ed97f67a1ff7f05f6421a92c7c6" + digest = "1:f44b5a32a31245ea062cd397cc343bda06d75c731596589996c1f77634e653af" name = "k8s.io/apimachinery" packages = [ "pkg/api/equality", @@ -816,6 +820,7 @@ "pkg/util/mergepatch", "pkg/util/naming", "pkg/util/net", + "pkg/util/rand", "pkg/util/runtime", "pkg/util/sets", "pkg/util/strategicpatch", @@ -830,11 +835,11 @@ "third_party/forked/golang/reflect", ] pruneopts = "NT" - revision = "49ce2735e5074ffc3f8190c8406cf51a96302dad" - version = "kubernetes-1.12.5" + revision = "86fb29eff6288413d76bd8506874fddd9fccdff0" + version = "kubernetes-1.13.4" [[projects]] - digest = "1:9aef72dc639ffc347ab8b81dc74d85ad12c64708e8bf8cdc43fac17b6018585d" + digest = "1:7f28bbfb5889618ab038d4d250d7adb6762aa43b2fc120a95a1cd47c68af6dd4" name = "k8s.io/client-go" packages = [ "discovery", @@ -847,6 +852,7 @@ "kubernetes/typed/apps/v1", "kubernetes/typed/apps/v1beta1", "kubernetes/typed/apps/v1beta2", + "kubernetes/typed/auditregistration/v1alpha1", "kubernetes/typed/authentication/v1", "kubernetes/typed/authentication/v1beta1", "kubernetes/typed/authorization/v1", @@ -878,7 +884,6 @@ "pkg/apis/clientauthentication/v1beta1", "pkg/version", "plugin/pkg/client/auth/exec", - "plugin/pkg/client/auth/gcp", "rest", "rest/watch", "restmapper", @@ -891,7 +896,6 @@ "scale/scheme/extensionsint", "scale/scheme/extensionsv1beta1", "testing", - "third_party/forked/golang/template", "tools/auth", "tools/cache", "tools/clientcmd", @@ -911,16 +915,15 @@ "util/flowcontrol", "util/homedir", "util/integer", - "util/jsonpath", "util/retry", "util/workqueue", ] pruneopts = "NT" - revision = "701b913670036511e3d752318272c97f1a2a2edd" - version = "kubernetes-1.12.5" + revision = "b40b2a5939e43f7ffe0028ad67586b7ce50bb675" + version = "kubernetes-1.13.4" [[projects]] - digest = "1:26b81b5e76e3f84ea5140da4f74649576e470f79091d2ef8e0d1b5000bc636ca" + digest = "1:dc1ae99dcab96913d81ae970b1f7a7411a54199b14bfb17a7e86f9a56979c720" name = "k8s.io/code-generator" packages = [ "cmd/client-gen", @@ -944,17 +947,15 @@ "cmd/lister-gen", "cmd/lister-gen/args", "cmd/lister-gen/generators", - "cmd/openapi-gen", - "cmd/openapi-gen/args", "pkg/util", ] pruneopts = "T" - revision = "b1289fc74931d4b6b04bd1a259acfc88a2cb0a66" - version = "kubernetes-1.12.5" + revision = "c2090bec4d9b1fb25de3812f868accc2bc9ecbae" + version = "kubernetes-1.13.4" [[projects]] branch = "master" - digest = "1:4e07c417d966628ee9e471354ad5e311c9c25ff357d42fd0dd2f81a40caf6aad" + digest = "1:be219f9a8b4ec4488dc55bb2b321e801193f37b8b0825c015ec389a7de011a90" name = "k8s.io/gengo" packages = [ "args", @@ -967,7 +968,7 @@ "types", ] pruneopts = "NT" - revision = "0689ccc1d7d65d9dd1bedcc3b0b1ed7df91ba266" + revision = "e17681d19d3ac4837a019ece36c2a0ec31ffe985" [[projects]] digest = "1:29f93bb84d907a2c035e729e19d66fe52165d8c905cb3ef1920140d76ae6afaf" @@ -978,30 +979,26 @@ version = "v0.2.0" [[projects]] - branch = "release-1.12" - digest = "1:66169f83260a0fa4b15ab886113f1accad6e9bc1c7fb94a99aef1c9c064d1ae9" + digest = "1:51450ed83182dd52f7c3724fa6dd5415b30935df31e1fb7b8239ae8da58236b7" name = "k8s.io/kube-aggregator" packages = [ "pkg/apis/apiregistration", "pkg/apis/apiregistration/v1", ] pruneopts = "NT" - revision = "e77f03c95d650ebee799b6d828bc73e47310c0f1" + revision = "3e0149950b0e22a3b8579db52bd50e40d0dac10e" + version = "kubernetes-1.13.4" [[projects]] branch = "master" - digest = "1:4dbb9fa9ab4548516c842af1280f967b174f0e40590f37eee3451bba8de8d3d5" + digest = "1:0f43a164be6cf6da89cf03e0b40833f8a60b82c2752b6beeaf5951befd5867b7" name = "k8s.io/kube-openapi" packages = [ - "cmd/openapi-gen/args", "pkg/common", - "pkg/generators", - "pkg/generators/rules", "pkg/util/proto", - "pkg/util/sets", ] pruneopts = "NT" - revision = "d50a959ae76a85c7c262a9767ef29f37093c2b8a" + revision = "94e1e7b7574c44c4c0f2007de6fe617e259191f3" [[projects]] branch = "master" @@ -1012,7 +1009,7 @@ revision = "21c4ce38f2a793ec01e925ddc31216500183b773" [[projects]] - digest = "1:e03ddaf9f31bccbbb8c33eabad2c85025a95ca98905649fd744e0a54c630a064" + digest = "1:06035489efbd51ccface65fc878ceeb849aba05b2f9443c8993f363fc96e80ac" name = "sigs.k8s.io/controller-runtime" packages = [ "pkg/cache", @@ -1020,6 +1017,7 @@ "pkg/client", "pkg/client/apiutil", "pkg/client/config", + "pkg/client/fake", "pkg/controller", "pkg/controller/controllerutil", "pkg/event", @@ -1042,10 +1040,12 @@ "pkg/source/internal", "pkg/webhook/admission", "pkg/webhook/admission/types", + "pkg/webhook/internal/metrics", "pkg/webhook/types", ] pruneopts = "NT" - revision = "c63ebda0bf4be5f0a8abd4003e4ea546032545ba" + revision = "12d98582e72927b6cd0123e2b4e819f9341ce62c" + version = "v0.1.10" [[projects]] digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c" @@ -1061,26 +1061,23 @@ input-imports = [ "github.com/blang/semver", "github.com/go-openapi/spec", - "github.com/golang/glog", "github.com/onsi/ginkgo", "github.com/onsi/gomega", "github.com/openshift/api/config/v1", "github.com/openshift/client-go/config/clientset/versioned", "github.com/openshift/client-go/config/clientset/versioned/fake", "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e", - "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/actuators", "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/autoscaler", "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/infra", + "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/machinehealthcheck", "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/operators", "github.com/openshift/cluster-version-operator/lib/resourcemerge", "github.com/stretchr/testify/assert", "k8s.io/api/apps/v1", - "k8s.io/api/batch/v1", "k8s.io/api/core/v1", "k8s.io/apimachinery/pkg/api/equality", "k8s.io/apimachinery/pkg/api/errors", "k8s.io/apimachinery/pkg/api/meta", - "k8s.io/apimachinery/pkg/api/resource", "k8s.io/apimachinery/pkg/apis/meta/v1", "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured", "k8s.io/apimachinery/pkg/runtime", @@ -1088,19 +1085,20 @@ "k8s.io/apimachinery/pkg/types", "k8s.io/apimachinery/pkg/util/wait", "k8s.io/client-go/kubernetes/scheme", - "k8s.io/client-go/plugin/pkg/client/auth/gcp", - "k8s.io/client-go/rest", + "k8s.io/client-go/tools/record", + "k8s.io/client-go/tools/reference", "k8s.io/code-generator/cmd/client-gen", "k8s.io/code-generator/cmd/conversion-gen", "k8s.io/code-generator/cmd/deepcopy-gen", "k8s.io/code-generator/cmd/defaulter-gen", "k8s.io/code-generator/cmd/informer-gen", "k8s.io/code-generator/cmd/lister-gen", - "k8s.io/code-generator/cmd/openapi-gen", "k8s.io/gengo/args", + "k8s.io/klog", "k8s.io/kube-openapi/pkg/common", "sigs.k8s.io/controller-runtime/pkg/client", "sigs.k8s.io/controller-runtime/pkg/client/config", + "sigs.k8s.io/controller-runtime/pkg/client/fake", "sigs.k8s.io/controller-runtime/pkg/controller", "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil", "sigs.k8s.io/controller-runtime/pkg/event", diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/Gopkg.toml b/vendor/github.com/openshift/cluster-autoscaler-operator/Gopkg.toml index 6392d51d4..25d564ec5 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/Gopkg.toml +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/Gopkg.toml @@ -6,13 +6,12 @@ required = [ "k8s.io/code-generator/cmd/client-gen", "k8s.io/code-generator/cmd/lister-gen", "k8s.io/code-generator/cmd/informer-gen", - "k8s.io/code-generator/cmd/openapi-gen", "k8s.io/gengo/args", "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e", - "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/actuators", "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/autoscaler", "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/infra", "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/operators", + "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/machinehealthcheck", "github.com/openshift/api/config/v1", "github.com/onsi/ginkgo", "github.com/onsi/gomega", @@ -23,38 +22,38 @@ required = [ [[override]] name = "github.com/openshift/cluster-autoscaler-operator" +[[override]] + name = "github.com/openshift/cluster-api-actuator-pkg" + branch = "master" + [[override]] name = "k8s.io/code-generator" - version = "kubernetes-1.12.5" + version = "kubernetes-1.13.4" [[override]] name = "k8s.io/api" - version = "kubernetes-1.12.5" + version = "kubernetes-1.13.4" [[override]] name = "k8s.io/apiextensions-apiserver" - version = "kubernetes-1.12.5" + source = "https://github.com/openshift/kubernetes-apiextensions-apiserver.git" + version = "kubernetes-1.13.4" [[override]] name = "k8s.io/apimachinery" - version = "kubernetes-1.12.5" + version = "kubernetes-1.13.4" [[override]] name = "k8s.io/client-go" - version = "kubernetes-1.12.5" + version = "kubernetes-1.13.4" [[override]] name = "k8s.io/kube-aggregator" - branch = "release-1.12" + version = "kubernetes-1.13.4" [[override]] name = "sigs.k8s.io/controller-runtime" - # version = "v0.1.8" # does not work, still pulls v.1.10 instead - revision = "c63ebda0bf4be5f0a8abd4003e4ea546032545ba" - -[[override]] - name = "github.com/openshift/api" - branch = "master" + version = "v0.1.10" [[override]] name = "github.com/openshift/client-go" @@ -83,5 +82,5 @@ required = [ go-tests = false [[constraint]] - branch = "master" - name = "github.com/golang/glog" + name = "k8s.io/klog" + version = "0.2.0" diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/Makefile b/vendor/github.com/openshift/cluster-autoscaler-operator/Makefile index 9d0f9ab0c..2d20396b3 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/Makefile +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/Makefile @@ -42,16 +42,16 @@ generate: ## Code generation (requires operator-sdk >= v0.5.0) mkdir -p deploy/crds cp install/01_clusterautoscaler.crd.yaml \ - deploy/crds/autoscaling_v1alpha1_clusterautoscaler_crd.yaml + deploy/crds/autoscaling_v1_clusterautoscaler_crd.yaml cp install/02_machineautoscaler.crd.yaml \ - deploy/crds/autoscaling_v1alpha1_machineautoscaler_crd.yaml + deploy/crds/autoscaling_v1beta1_machineautoscaler_crd.yaml operator-sdk generate k8s operator-sdk generate openapi - cp deploy/crds/autoscaling_v1alpha1_clusterautoscaler_crd.yaml \ + cp deploy/crds/autoscaling_v1_clusterautoscaler_crd.yaml \ install/01_clusterautoscaler.crd.yaml - cp deploy/crds/autoscaling_v1alpha1_machineautoscaler_crd.yaml \ + cp deploy/crds/autoscaling_v1beta1_machineautoscaler_crd.yaml \ install/02_machineautoscaler.crd.yaml .PHONY: build @@ -70,6 +70,10 @@ push: .PHONY: check check: fmt vet lint test ## Check your code +.PHONY: check-pkg +check-pkg: + ./hack/verify-actuator-pkg.sh + .PHONY: test test: ## Run unit tests $(DOCKER_CMD) go test -race -cover ./... @@ -81,6 +85,7 @@ test-e2e: ## Run e2e tests -kubeconfig $${KUBECONFIG:-~/.kube/config} \ -machine-api-namespace $${NAMESPACE:-openshift-machine-api} \ -ginkgo.v \ + -ginkgo.noColor=true \ -args -v 5 -logtostderr true .PHONY: lint diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/cmd/manager/main.go b/vendor/github.com/openshift/cluster-autoscaler-operator/cmd/manager/main.go index 0d8ba3a2c..0dd194cc9 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/cmd/manager/main.go +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/cmd/manager/main.go @@ -4,31 +4,34 @@ import ( "flag" "runtime" - "github.com/golang/glog" "github.com/openshift/cluster-autoscaler-operator/pkg/operator" "github.com/openshift/cluster-autoscaler-operator/pkg/version" - _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" + "k8s.io/klog" ) func printVersion() { - glog.Infof("Go Version: %s", runtime.Version()) - glog.Infof("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH) - glog.Infof("Version: %s", version.String) + klog.Infof("Go Version: %s", runtime.Version()) + klog.Infof("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH) + klog.Infof("Version: %s", version.String) } func main() { + klog.InitFlags(nil) + flag.Set("logtostderr", "true") + flag.Set("alsologtostderr", "true") flag.Parse() + printVersion() config := operator.ConfigFromEnvironment() operator, err := operator.New(config) if err != nil { - glog.Fatal(err) + klog.Fatal(err) } - glog.Info("Starting cluster-autoscaler-operator") + klog.Info("Starting cluster-autoscaler-operator") if err := operator.Start(); err != nil { - glog.Fatal(err) + klog.Fatal(err) } } diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/examples/clusterautoscaler.yaml b/vendor/github.com/openshift/cluster-autoscaler-operator/examples/clusterautoscaler.yaml index 1f06f459b..275f74063 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/examples/clusterautoscaler.yaml +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/examples/clusterautoscaler.yaml @@ -1,5 +1,5 @@ --- -apiVersion: "autoscaling.openshift.io/v1alpha1" +apiVersion: "autoscaling.openshift.io/v1" kind: "ClusterAutoscaler" metadata: name: "default" @@ -13,6 +13,7 @@ spec: memory: min: 4 max: 256 + # GPU is optional and can be omitted gpus: - type: nvidia.com/gpu min: 0 @@ -22,6 +23,9 @@ spec: max: 4 scaleDown: enabled: true + # How long after scale up that scale down evaluation resumes - if omitted defaults to 10 minutes delayAfterAdd: 10s + # How long after node deletion that scale down evaluation resumes - if omitted defaults to 10 seconds delayAfterDelete: 10s + # How long after scale down failure that scale down evaluation resumes - if omitted defaults to 3 minutes delayAfterFailure: 10s diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/examples/machineautoscaler.yaml b/vendor/github.com/openshift/cluster-autoscaler-operator/examples/machineautoscaler.yaml index 941ac6b3b..d4d0d46d1 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/examples/machineautoscaler.yaml +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/examples/machineautoscaler.yaml @@ -1,5 +1,5 @@ --- -apiVersion: "autoscaling.openshift.io/v1alpha1" +apiVersion: "autoscaling.openshift.io/v1beta1" kind: "MachineAutoscaler" metadata: name: "worker-us-east-1a" diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/hack/verify-actuator-pkg.sh b/vendor/github.com/openshift/cluster-autoscaler-operator/hack/verify-actuator-pkg.sh new file mode 100755 index 000000000..d02e70cef --- /dev/null +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/hack/verify-actuator-pkg.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e + +if ! command -v dep 1>/dev/null 2>&1; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh +fi + +if dep check | grep -q cluster-api-actuator-pkg; then + exit 1 +fi +dep ensure -update github.com/openshift/cluster-api-actuator-pkg +git diff --exit-code diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/install/01_clusterautoscaler.crd.yaml b/vendor/github.com/openshift/cluster-autoscaler-operator/install/01_clusterautoscaler.crd.yaml index 7367f4193..5391b1d66 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/install/01_clusterautoscaler.crd.yaml +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/install/01_clusterautoscaler.crd.yaml @@ -105,8 +105,8 @@ spec: type: object status: type: object - version: v1alpha1 + version: v1 versions: - - name: v1alpha1 + - name: v1 served: true storage: true diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/install/02_machineautoscaler.crd.yaml b/vendor/github.com/openshift/cluster-autoscaler-operator/install/02_machineautoscaler.crd.yaml index 129f90bcb..4008d2492 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/install/02_machineautoscaler.crd.yaml +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/install/02_machineautoscaler.crd.yaml @@ -88,8 +88,8 @@ spec: - name type: object type: object - version: v1alpha1 + version: v1beta1 versions: - - name: v1alpha1 + - name: v1beta1 served: true storage: true diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/kustomization.yaml b/vendor/github.com/openshift/cluster-autoscaler-operator/kustomization.yaml index 18d882c62..06e0640bb 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/kustomization.yaml +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/kustomization.yaml @@ -13,4 +13,4 @@ resources: - install/04_deployment.yaml patches: -- cluster-autoscaler-operator-patch.yaml +- test/cluster-autoscaler-operator-patch.yaml diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/addtoscheme_autoscaling_v1.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/addtoscheme_autoscaling_v1.go new file mode 100644 index 000000000..b967ac540 --- /dev/null +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/addtoscheme_autoscaling_v1.go @@ -0,0 +1,10 @@ +package apis + +import ( + v1 "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1" +) + +func init() { + // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back + AddToSchemes = append(AddToSchemes, v1.SchemeBuilder.AddToScheme) +} diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/addtoscheme_autoscaling_v1alpha1.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/addtoscheme_autoscaling_v1beta1.go similarity index 69% rename from vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/addtoscheme_autoscaling_v1alpha1.go rename to vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/addtoscheme_autoscaling_v1beta1.go index 85f3055cf..c7cf713b2 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/addtoscheme_autoscaling_v1alpha1.go +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/addtoscheme_autoscaling_v1beta1.go @@ -1,10 +1,10 @@ package apis import ( - "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1" + "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1" ) func init() { // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back - AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme) + AddToSchemes = append(AddToSchemes, v1beta1.SchemeBuilder.AddToScheme) } diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/clusterautoscaler_types.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/clusterautoscaler_types.go similarity index 99% rename from vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/clusterautoscaler_types.go rename to vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/clusterautoscaler_types.go index 17cd80eff..3a9246618 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/clusterautoscaler_types.go +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/clusterautoscaler_types.go @@ -1,4 +1,4 @@ -package v1alpha1 +package v1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/doc.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/doc.go new file mode 100644 index 000000000..d89992f41 --- /dev/null +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/doc.go @@ -0,0 +1,4 @@ +// Package v1 contains API Schema definitions for the autoscaling v1 API group +// +k8s:deepcopy-gen=package,register +// +groupName=autoscaling.openshift.io +package v1 diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/register.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/register.go similarity index 78% rename from vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/register.go rename to vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/register.go index b78b638f6..fab5db33e 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/register.go +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/register.go @@ -1,9 +1,9 @@ // NOTE: Boilerplate only. Ignore this file. -// Package v1alpha1 contains API Schema definitions for the autoscaling v1alpha1 API group +// Package v1 contains API Schema definitions for the autoscaling v1 API group // +k8s:deepcopy-gen=package,register // +groupName=autoscaling.openshift.io -package v1alpha1 +package v1 import ( "k8s.io/apimachinery/pkg/runtime/schema" @@ -12,7 +12,7 @@ import ( var ( // SchemeGroupVersion is group version used to register these objects - SchemeGroupVersion = schema.GroupVersion{Group: "autoscaling.openshift.io", Version: "v1alpha1"} + SchemeGroupVersion = schema.GroupVersion{Group: "autoscaling.openshift.io", Version: "v1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/zz_generated.deepcopy.go similarity index 65% rename from vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go rename to vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/zz_generated.deepcopy.go index caa5902f3..d20c1b8a1 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/zz_generated.deepcopy.go @@ -18,7 +18,7 @@ limitations under the License. // Code generated by deepcopy-gen. DO NOT EDIT. -package v1alpha1 +package v1 import ( runtime "k8s.io/apimachinery/pkg/runtime" @@ -137,22 +137,6 @@ func (in *ClusterAutoscalerStatus) DeepCopy() *ClusterAutoscalerStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CrossVersionObjectReference) DeepCopyInto(out *CrossVersionObjectReference) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CrossVersionObjectReference. -func (in *CrossVersionObjectReference) DeepCopy() *CrossVersionObjectReference { - if in == nil { - return nil - } - out := new(CrossVersionObjectReference) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GPULimit) DeepCopyInto(out *GPULimit) { *out = *in @@ -169,105 +153,6 @@ func (in *GPULimit) DeepCopy() *GPULimit { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MachineAutoscaler) DeepCopyInto(out *MachineAutoscaler) { - *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 MachineAutoscaler. -func (in *MachineAutoscaler) DeepCopy() *MachineAutoscaler { - if in == nil { - return nil - } - out := new(MachineAutoscaler) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *MachineAutoscaler) 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 *MachineAutoscalerList) DeepCopyInto(out *MachineAutoscalerList) { - *out = *in - out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]MachineAutoscaler, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineAutoscalerList. -func (in *MachineAutoscalerList) DeepCopy() *MachineAutoscalerList { - if in == nil { - return nil - } - out := new(MachineAutoscalerList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *MachineAutoscalerList) 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 *MachineAutoscalerSpec) DeepCopyInto(out *MachineAutoscalerSpec) { - *out = *in - out.ScaleTargetRef = in.ScaleTargetRef - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineAutoscalerSpec. -func (in *MachineAutoscalerSpec) DeepCopy() *MachineAutoscalerSpec { - if in == nil { - return nil - } - out := new(MachineAutoscalerSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MachineAutoscalerStatus) DeepCopyInto(out *MachineAutoscalerStatus) { - *out = *in - if in.LastTargetRef != nil { - in, out := &in.LastTargetRef, &out.LastTargetRef - *out = new(CrossVersionObjectReference) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineAutoscalerStatus. -func (in *MachineAutoscalerStatus) DeepCopy() *MachineAutoscalerStatus { - if in == nil { - return nil - } - out := new(MachineAutoscalerStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceLimits) DeepCopyInto(out *ResourceLimits) { *out = *in diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/zz_generated.defaults.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/zz_generated.defaults.go similarity index 98% rename from vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/zz_generated.defaults.go rename to vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/zz_generated.defaults.go index dd621a3ac..cce2e603a 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/zz_generated.defaults.go +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/zz_generated.defaults.go @@ -18,7 +18,7 @@ limitations under the License. // Code generated by defaulter-gen. DO NOT EDIT. -package v1alpha1 +package v1 import ( runtime "k8s.io/apimachinery/pkg/runtime" diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/zz_generated.openapi.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/zz_generated.openapi.go new file mode 100644 index 000000000..486369f59 --- /dev/null +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/zz_generated.openapi.go @@ -0,0 +1,62 @@ +// +build !ignore_autogenerated + +// Code generated by openapi-gen. DO NOT EDIT. + +// This file was autogenerated by openapi-gen. Do not edit it manually! + +package v1 + +import ( + spec "github.com/go-openapi/spec" + common "k8s.io/kube-openapi/pkg/common" +) + +func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { + return map[string]common.OpenAPIDefinition{ + "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1.ClusterAutoscaler": schema_pkg_apis_autoscaling_v1_ClusterAutoscaler(ref), + } +} + +func schema_pkg_apis_autoscaling_v1_ClusterAutoscaler(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ClusterAutoscaler is the Schema for the clusterautoscalers API", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1.ClusterAutoscalerSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1.ClusterAutoscalerStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1.ClusterAutoscalerSpec", "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1.ClusterAutoscalerStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/doc.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/doc.go deleted file mode 100644 index aec700e8a..000000000 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// Package v1alpha1 contains API Schema definitions for the autoscaling v1alpha1 API group -// +k8s:deepcopy-gen=package,register -// +groupName=autoscaling.openshift.io -package v1alpha1 diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/zz_generated.openapi.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/zz_generated.openapi.go deleted file mode 100644 index 8270b2d18..000000000 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/zz_generated.openapi.go +++ /dev/null @@ -1,107 +0,0 @@ -// +build !ignore_autogenerated - -// Code generated by openapi-gen. DO NOT EDIT. - -// This file was autogenerated by openapi-gen. Do not edit it manually! - -package v1alpha1 - -import ( - spec "github.com/go-openapi/spec" - common "k8s.io/kube-openapi/pkg/common" -) - -func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { - return map[string]common.OpenAPIDefinition{ - "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1.ClusterAutoscaler": schema_pkg_apis_autoscaling_v1alpha1_ClusterAutoscaler(ref), - "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1.MachineAutoscaler": schema_pkg_apis_autoscaling_v1alpha1_MachineAutoscaler(ref), - } -} - -func schema_pkg_apis_autoscaling_v1alpha1_ClusterAutoscaler(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "ClusterAutoscaler is the Schema for the clusterautoscalers API", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "kind": { - SchemaProps: spec.SchemaProps{ - Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", - Type: []string{"string"}, - Format: "", - }, - }, - "apiVersion": { - SchemaProps: spec.SchemaProps{ - Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", - Type: []string{"string"}, - Format: "", - }, - }, - "metadata": { - SchemaProps: spec.SchemaProps{ - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), - }, - }, - "spec": { - SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1.ClusterAutoscalerSpec"), - }, - }, - "status": { - SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1.ClusterAutoscalerStatus"), - }, - }, - }, - }, - }, - Dependencies: []string{ - "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1.ClusterAutoscalerSpec", "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1.ClusterAutoscalerStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, - } -} - -func schema_pkg_apis_autoscaling_v1alpha1_MachineAutoscaler(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "MachineAutoscaler is the Schema for the machineautoscalers API", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "kind": { - SchemaProps: spec.SchemaProps{ - Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", - Type: []string{"string"}, - Format: "", - }, - }, - "apiVersion": { - SchemaProps: spec.SchemaProps{ - Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", - Type: []string{"string"}, - Format: "", - }, - }, - "metadata": { - SchemaProps: spec.SchemaProps{ - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), - }, - }, - "spec": { - SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1.MachineAutoscalerSpec"), - }, - }, - "status": { - SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1.MachineAutoscalerStatus"), - }, - }, - }, - }, - }, - Dependencies: []string{ - "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1.MachineAutoscalerSpec", "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1.MachineAutoscalerStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, - } -} diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/doc.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/doc.go new file mode 100644 index 000000000..7d59acdb1 --- /dev/null +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/doc.go @@ -0,0 +1,4 @@ +// Package v1beta1 contains API Schema definitions for the autoscaling v1beta1 API group +// +k8s:deepcopy-gen=package,register +// +groupName=autoscaling.openshift.io +package v1beta1 diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/machineautoscaler_types.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/machineautoscaler_types.go similarity index 99% rename from vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/machineautoscaler_types.go rename to vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/machineautoscaler_types.go index eddf780ff..fa2fd3969 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1/machineautoscaler_types.go +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/machineautoscaler_types.go @@ -1,4 +1,4 @@ -package v1alpha1 +package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/register.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/register.go new file mode 100644 index 000000000..48b27c0ba --- /dev/null +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/register.go @@ -0,0 +1,19 @@ +// NOTE: Boilerplate only. Ignore this file. + +// Package v1beta1 contains API Schema definitions for the autoscaling v1beta1 API group +// +k8s:deepcopy-gen=package,register +// +groupName=autoscaling.openshift.io +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/runtime/scheme" +) + +var ( + // SchemeGroupVersion is group version used to register these objects + SchemeGroupVersion = schema.GroupVersion{Group: "autoscaling.openshift.io", Version: "v1beta1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} +) diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/zz_generated.deepcopy.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 000000000..1961becd9 --- /dev/null +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,140 @@ +// +build !ignore_autogenerated + +/* +Copyright The Kubernetes 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 v1beta1 + +import ( + 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 *CrossVersionObjectReference) DeepCopyInto(out *CrossVersionObjectReference) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CrossVersionObjectReference. +func (in *CrossVersionObjectReference) DeepCopy() *CrossVersionObjectReference { + if in == nil { + return nil + } + out := new(CrossVersionObjectReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineAutoscaler) DeepCopyInto(out *MachineAutoscaler) { + *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 MachineAutoscaler. +func (in *MachineAutoscaler) DeepCopy() *MachineAutoscaler { + if in == nil { + return nil + } + out := new(MachineAutoscaler) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MachineAutoscaler) 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 *MachineAutoscalerList) DeepCopyInto(out *MachineAutoscalerList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]MachineAutoscaler, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineAutoscalerList. +func (in *MachineAutoscalerList) DeepCopy() *MachineAutoscalerList { + if in == nil { + return nil + } + out := new(MachineAutoscalerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MachineAutoscalerList) 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 *MachineAutoscalerSpec) DeepCopyInto(out *MachineAutoscalerSpec) { + *out = *in + out.ScaleTargetRef = in.ScaleTargetRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineAutoscalerSpec. +func (in *MachineAutoscalerSpec) DeepCopy() *MachineAutoscalerSpec { + if in == nil { + return nil + } + out := new(MachineAutoscalerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineAutoscalerStatus) DeepCopyInto(out *MachineAutoscalerStatus) { + *out = *in + if in.LastTargetRef != nil { + in, out := &in.LastTargetRef, &out.LastTargetRef + *out = new(CrossVersionObjectReference) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineAutoscalerStatus. +func (in *MachineAutoscalerStatus) DeepCopy() *MachineAutoscalerStatus { + if in == nil { + return nil + } + out := new(MachineAutoscalerStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/zz_generated.defaults.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/zz_generated.defaults.go new file mode 100644 index 000000000..73e63fc11 --- /dev/null +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/zz_generated.defaults.go @@ -0,0 +1,32 @@ +// +build !ignore_autogenerated + +/* +Copyright The Kubernetes 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 defaulter-gen. DO NOT EDIT. + +package v1beta1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// RegisterDefaults adds defaulters functions to the given scheme. +// Public to allow building arbitrary schemes. +// All generated defaulters are covering - they call all nested defaulters. +func RegisterDefaults(scheme *runtime.Scheme) error { + return nil +} diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/zz_generated.openapi.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/zz_generated.openapi.go new file mode 100644 index 000000000..2b0bbdd63 --- /dev/null +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1/zz_generated.openapi.go @@ -0,0 +1,62 @@ +// +build !ignore_autogenerated + +// Code generated by openapi-gen. DO NOT EDIT. + +// This file was autogenerated by openapi-gen. Do not edit it manually! + +package v1beta1 + +import ( + spec "github.com/go-openapi/spec" + common "k8s.io/kube-openapi/pkg/common" +) + +func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { + return map[string]common.OpenAPIDefinition{ + "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1.MachineAutoscaler": schema_pkg_apis_autoscaling_v1beta1_MachineAutoscaler(ref), + } +} + +func schema_pkg_apis_autoscaling_v1beta1_MachineAutoscaler(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "MachineAutoscaler is the Schema for the machineautoscalers API", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1.MachineAutoscalerSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1.MachineAutoscalerStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1.MachineAutoscalerSpec", "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1.MachineAutoscalerStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/controller/clusterautoscaler/clusterautoscaler.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/controller/clusterautoscaler/clusterautoscaler.go index 25d825280..279c69823 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/controller/clusterautoscaler/clusterautoscaler.go +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/controller/clusterautoscaler/clusterautoscaler.go @@ -3,7 +3,7 @@ package clusterautoscaler import ( "fmt" - v1alpha1 "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1" + v1 "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1" ) // AutoscalerArg represents a command line argument to the cluster-autoscaler @@ -53,7 +53,7 @@ const ( // AutoscalerArgs returns a slice of strings representing command line arguments // to the cluster-autoscaler corresponding to the values in the given // ClusterAutoscaler resource. -func AutoscalerArgs(ca *v1alpha1.ClusterAutoscaler, cfg *Config) []string { +func AutoscalerArgs(ca *v1.ClusterAutoscaler, cfg *Config) []string { s := &ca.Spec args := []string{ @@ -87,7 +87,7 @@ func AutoscalerArgs(ca *v1alpha1.ClusterAutoscaler, cfg *Config) []string { // ScaleDownArgs returns a slice of strings representing command line arguments // to the cluster-autoscaler corresponding to the values in the given // ScaleDownConfig object. -func ScaleDownArgs(sd *v1alpha1.ScaleDownConfig) []string { +func ScaleDownArgs(sd *v1.ScaleDownConfig) []string { if !sd.Enabled { return []string{ScaleDownEnabledArg.Value(false)} } @@ -118,7 +118,7 @@ func ScaleDownArgs(sd *v1alpha1.ScaleDownConfig) []string { // ResourceArgs returns a slice of strings representing command line arguments // to the cluster-autoscaler corresponding to the values in the given // ResourceLimits object. -func ResourceArgs(rl *v1alpha1.ResourceLimits) []string { +func ResourceArgs(rl *v1.ResourceLimits) []string { args := []string{} if rl.MaxNodesTotal != nil { diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/controller/clusterautoscaler/clusterautoscaler_controller.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/controller/clusterautoscaler/clusterautoscaler_controller.go index c0316bd93..eed126fcc 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/controller/clusterautoscaler/clusterautoscaler_controller.go +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/controller/clusterautoscaler/clusterautoscaler_controller.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/golang/glog" - autoscalingv1alpha1 "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1" + autoscalingv1 "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1" + "github.com/openshift/cluster-autoscaler-operator/pkg/util" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" @@ -14,6 +14,8 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" + "k8s.io/client-go/tools/reference" + "k8s.io/klog" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" @@ -27,7 +29,6 @@ import ( const ( controllerName = "cluster-autoscaler-controller" - criticalPod = "scheduler.alpha.kubernetes.io/critical-pod" caServiceAccount = "cluster-autoscaler" caPriorityClassName = "system-cluster-critical" ) @@ -101,7 +102,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager) error { } // Watch for changes to primary resource ClusterAutoscaler - err = c.Watch(&source.Kind{Type: &autoscalingv1alpha1.ClusterAutoscaler{}}, &handler.EnqueueRequestForObject{}, p) + err = c.Watch(&source.Kind{Type: &autoscalingv1.ClusterAutoscaler{}}, &handler.EnqueueRequestForObject{}, p) if err != nil { return err } @@ -109,7 +110,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager) error { // Watch for changes to secondary resources owned by a ClusterAutoscaler err = c.Watch(&source.Kind{Type: &appsv1.Deployment{}}, &handler.EnqueueRequestForOwner{ IsController: true, - OwnerType: &autoscalingv1alpha1.ClusterAutoscaler{}, + OwnerType: &autoscalingv1.ClusterAutoscaler{}, }) if err != nil { @@ -123,10 +124,10 @@ func (r *Reconciler) AddToManager(mgr manager.Manager) error { // object and makes changes based on the state read and what is in the // ClusterAutoscaler.Spec func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, error) { - glog.Infof("Reconciling ClusterAutoscaler %s\n", request.Name) + klog.Infof("Reconciling ClusterAutoscaler %s\n", request.Name) // Fetch the ClusterAutoscaler instance - ca := &autoscalingv1alpha1.ClusterAutoscaler{} + ca := &autoscalingv1.ClusterAutoscaler{} err := r.client.Get(context.TODO(), request.NamespacedName, ca) if err != nil { if errors.IsNotFound(err) { @@ -134,19 +135,25 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err // reconcile request. Owned objects are automatically // garbage collected. For additional cleanup logic use // finalizers. Return and don't requeue. + klog.Infof("ClusterAutoscaler %s not found, will not reconcile", request.Name) return reconcile.Result{}, nil } // Error reading the object - requeue the request. - glog.Errorf("Error reading ClusterAutoscaler: %v", err) + klog.Errorf("Error reading ClusterAutoscaler: %v", err) return reconcile.Result{}, err } + // caRef is a reference to the ClusterAutoscaler object, but with the + // namespace for cluster-autoscaler deployments set. This keeps events + // generated for these cluster scoped objects out of the default namespace. + caRef := r.objectReference(ca) + _, err = r.GetAutoscaler(ca) if err != nil && !errors.IsNotFound(err) { errMsg := fmt.Sprintf("Error getting cluster-autoscaler deployment: %v", err) - r.recorder.Event(ca, corev1.EventTypeWarning, "FailedGetDeployment", errMsg) - glog.Error(errMsg) + r.recorder.Event(caRef, corev1.EventTypeWarning, "FailedGetDeployment", errMsg) + klog.Error(errMsg) return reconcile.Result{}, err } @@ -154,65 +161,34 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err if errors.IsNotFound(err) { if err := r.CreateAutoscaler(ca); err != nil { errMsg := fmt.Sprintf("Error creating ClusterAutoscaler deployment: %v", err) - r.recorder.Event(ca, corev1.EventTypeWarning, "FailedCreate", errMsg) - glog.Error(errMsg) + r.recorder.Event(caRef, corev1.EventTypeWarning, "FailedCreate", errMsg) + klog.Error(errMsg) return reconcile.Result{}, err } msg := fmt.Sprintf("Created ClusterAutoscaler deployment: %s", r.AutoscalerName(ca)) - r.recorder.Eventf(ca, corev1.EventTypeNormal, "SuccessfulCreate", msg) - glog.V(2).Info(msg) + r.recorder.Eventf(caRef, corev1.EventTypeNormal, "SuccessfulCreate", msg) + klog.Info(msg) return reconcile.Result{}, nil } if err := r.UpdateAutoscaler(ca); err != nil { errMsg := fmt.Sprintf("Error updating cluster-autoscaler deployment: %v", err) - r.recorder.Event(ca, corev1.EventTypeWarning, "FailedUpdate", errMsg) - glog.Error(errMsg) + r.recorder.Event(caRef, corev1.EventTypeWarning, "FailedUpdate", errMsg) + klog.Error(errMsg) return reconcile.Result{}, err } msg := fmt.Sprintf("Updated ClusterAutoscaler deployment: %s", r.AutoscalerName(ca)) - r.recorder.Eventf(ca, corev1.EventTypeNormal, "SuccessfulUpdate", msg) - glog.V(2).Info(msg) + r.recorder.Eventf(caRef, corev1.EventTypeNormal, "SuccessfulUpdate", msg) + klog.Info(msg) return reconcile.Result{}, nil } -// AvailableAndUpdated returns true if all cluster autoscalers are running and at the latest version -// as defined by the operator. -func (r *Reconciler) AvailableAndUpdated() (bool, error) { - ca := &autoscalingv1alpha1.ClusterAutoscaler{} - err := r.client.Get(context.TODO(), types.NamespacedName{Namespace: r.config.Namespace, Name: r.config.Name}, ca) - if err != nil { - if errors.IsNotFound(err) { - // no CA, do nothing - return true, nil - } - return false, err - } - dep, err := r.GetAutoscaler(ca) - if err != nil { - if errors.IsNotFound(err) { - // waiting for deployment to be created - return false, nil - } - return false, err - } - if dep.ObjectMeta.Annotations["release.openshift.io/version"] != r.config.ReleaseVersion { - // still haven't synced the release version - return false, nil - } - if dep.Status.ObservedGeneration < dep.Generation || dep.Status.UpdatedReplicas != dep.Status.Replicas || dep.Status.AvailableReplicas == 0 { - // deployment hasn't rolled out a new controller or we still have the old version hanging around - return false, nil - } - return true, nil -} - // SetConfig sets the given config on the reconciler. func (r *Reconciler) SetConfig(cfg *Config) { r.config = cfg @@ -224,7 +200,7 @@ func (r *Reconciler) SetConfig(cfg *Config) { func (r *Reconciler) NamePredicate(meta metav1.Object) bool { // Only process events for objects matching the configured resource name. if meta.GetName() != r.config.Name { - glog.Warningf("Not processing ClusterAutoscaler %s", meta.GetName()) + klog.Warningf("Not processing ClusterAutoscaler %s", meta.GetName()) return false } @@ -233,8 +209,8 @@ func (r *Reconciler) NamePredicate(meta metav1.Object) bool { // CreateAutoscaler will create the deployment for the given the // ClusterAutoscaler custom resource instance. -func (r *Reconciler) CreateAutoscaler(ca *autoscalingv1alpha1.ClusterAutoscaler) error { - glog.Infof("Creating ClusterAutoscaler deployment: %s\n", r.AutoscalerName(ca)) +func (r *Reconciler) CreateAutoscaler(ca *autoscalingv1.ClusterAutoscaler) error { + klog.Infof("Creating ClusterAutoscaler deployment: %s\n", r.AutoscalerName(ca)) deployment := r.AutoscalerDeployment(ca) @@ -248,7 +224,7 @@ func (r *Reconciler) CreateAutoscaler(ca *autoscalingv1alpha1.ClusterAutoscaler) // UpdateAutoscaler will retrieve the deployment for the given ClusterAutoscaler // custom resource instance and update it to match the expected spec if needed. -func (r *Reconciler) UpdateAutoscaler(ca *autoscalingv1alpha1.ClusterAutoscaler) error { +func (r *Reconciler) UpdateAutoscaler(ca *autoscalingv1.ClusterAutoscaler) error { existingDeployment, err := r.GetAutoscaler(ca) if err != nil { return err @@ -257,18 +233,23 @@ func (r *Reconciler) UpdateAutoscaler(ca *autoscalingv1alpha1.ClusterAutoscaler) existingSpec := existingDeployment.Spec.Template.Spec expectedSpec := r.AutoscalerPodSpec(ca) - // Only comparing podSpec for now. - if equality.Semantic.DeepEqual(existingSpec, expectedSpec) { + // Only comparing podSpec and release version for now. + if equality.Semantic.DeepEqual(existingSpec, expectedSpec) && + util.ReleaseVersionMatches(ca, r.config.ReleaseVersion) { return nil } existingDeployment.Spec.Template.Spec = *expectedSpec + + r.UpdateAnnotations(existingDeployment) + r.UpdateAnnotations(&existingDeployment.Spec.Template) + return r.client.Update(context.TODO(), existingDeployment) } // GetAutoscaler will return the deployment for the given ClusterAutoscaler // custom resource instance. -func (r *Reconciler) GetAutoscaler(ca *autoscalingv1alpha1.ClusterAutoscaler) (*appsv1.Deployment, error) { +func (r *Reconciler) GetAutoscaler(ca *autoscalingv1.ClusterAutoscaler) (*appsv1.Deployment, error) { deployment := &appsv1.Deployment{} nn := r.AutoscalerName(ca) @@ -281,16 +262,31 @@ func (r *Reconciler) GetAutoscaler(ca *autoscalingv1alpha1.ClusterAutoscaler) (* // AutoscalerName returns the expected NamespacedName for the deployment // belonging to the given ClusterAutoscaler. -func (r *Reconciler) AutoscalerName(ca *autoscalingv1alpha1.ClusterAutoscaler) types.NamespacedName { +func (r *Reconciler) AutoscalerName(ca *autoscalingv1.ClusterAutoscaler) types.NamespacedName { return types.NamespacedName{ Name: fmt.Sprintf("cluster-autoscaler-%s", ca.Name), Namespace: r.config.Namespace, } } +// UpdateAnnotations updates the annotations on the given object to the values +// currently expected by the controller. +func (r *Reconciler) UpdateAnnotations(obj metav1.Object) { + annotations := obj.GetAnnotations() + + if annotations == nil { + annotations = map[string]string{} + } + + annotations[util.CriticalPodAnnotation] = "" + annotations[util.ReleaseVersionAnnotation] = r.config.ReleaseVersion + + obj.SetAnnotations(annotations) +} + // AutoscalerDeployment returns the expected deployment belonging to the given // ClusterAutoscaler. -func (r *Reconciler) AutoscalerDeployment(ca *autoscalingv1alpha1.ClusterAutoscaler) *appsv1.Deployment { +func (r *Reconciler) AutoscalerDeployment(ca *autoscalingv1.ClusterAutoscaler) *appsv1.Deployment { namespacedName := r.AutoscalerName(ca) labels := map[string]string{ @@ -299,8 +295,8 @@ func (r *Reconciler) AutoscalerDeployment(ca *autoscalingv1alpha1.ClusterAutosca } annotations := map[string]string{ - criticalPod: "", - "release.openshift.io/version": r.config.ReleaseVersion, + util.CriticalPodAnnotation: "", + util.ReleaseVersionAnnotation: r.config.ReleaseVersion, } podSpec := r.AutoscalerPodSpec(ca) @@ -335,7 +331,7 @@ func (r *Reconciler) AutoscalerDeployment(ca *autoscalingv1alpha1.ClusterAutosca // AutoscalerPodSpec returns the expected podSpec for the deployment belonging // to the given ClusterAutoscaler. -func (r *Reconciler) AutoscalerPodSpec(ca *autoscalingv1alpha1.ClusterAutoscaler) *corev1.PodSpec { +func (r *Reconciler) AutoscalerPodSpec(ca *autoscalingv1.ClusterAutoscaler) *corev1.PodSpec { args := AutoscalerArgs(ca, r.config) if r.config.ExtraArgs != "" { @@ -373,3 +369,21 @@ func (r *Reconciler) AutoscalerPodSpec(ca *autoscalingv1alpha1.ClusterAutoscaler return spec } + +// objectReference returns a reference to the given object, but will set the +// configured deployment namesapce if no namespace was previously set. This is +// useful for referencing cluster scoped objects in events without the events +// being created in the default namespace. +func (r *Reconciler) objectReference(obj runtime.Object) *corev1.ObjectReference { + ref, err := reference.GetReference(r.scheme, obj) + if err != nil { + klog.Errorf("Error creating object reference: %v", err) + return nil + } + + if ref != nil && ref.Namespace == "" { + ref.Namespace = r.config.Namespace + } + + return ref +} diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/controller/machineautoscaler/machineautoscaler_controller.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/controller/machineautoscaler/machineautoscaler_controller.go index 9477b2eb5..c1d87027d 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/controller/machineautoscaler/machineautoscaler_controller.go +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/controller/machineautoscaler/machineautoscaler_controller.go @@ -5,8 +5,7 @@ import ( "errors" "fmt" - "github.com/golang/glog" - "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1" + "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1" "github.com/openshift/cluster-autoscaler-operator/pkg/util" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" @@ -16,6 +15,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/tools/record" + "k8s.io/klog" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" @@ -57,8 +57,8 @@ var ( // supported as targets for a MachineAutocaler instance. func DefaultSupportedTargetGVKs() []schema.GroupVersionKind { return []schema.GroupVersionKind{ - {Group: "cluster.k8s.io", Version: "v1alpha1", Kind: "MachineDeployment"}, - {Group: "cluster.k8s.io", Version: "v1alpha1", Kind: "MachineSet"}, + {Group: "cluster.k8s.io", Version: "v1beta1", Kind: "MachineDeployment"}, + {Group: "cluster.k8s.io", Version: "v1beta1", Kind: "MachineSet"}, {Group: "machine.openshift.io", Version: "v1beta1", Kind: "MachineDeployment"}, {Group: "machine.openshift.io", Version: "v1beta1", Kind: "MachineSet"}, } @@ -96,7 +96,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager) error { } // Watch for changes to primary resource MachineAutoscaler - err = c.Watch(&source.Kind{Type: &v1alpha1.MachineAutoscaler{}}, &handler.EnqueueRequestForObject{}) + err = c.Watch(&source.Kind{Type: &v1beta1.MachineAutoscaler{}}, &handler.EnqueueRequestForObject{}) if err != nil { return err } @@ -120,7 +120,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager) error { // If the type is later registered, a restart of the operator will pick // it up and properly reconcile any MachineAutoscalers referencing it. if err != nil && meta.IsNoMatchError(err) { - glog.Warningf("Removing support for unregistered target type: %s", gvk) + klog.Warningf("Removing support for unregistered target type: %s", gvk) missingGVKs = append(missingGVKs, gvk) } else if err != nil { return err @@ -156,10 +156,10 @@ type Reconciler struct { // makes changes based on the state read and what is in the // MachineAutoscaler.Spec func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, error) { - glog.Infof("Reconciling MachineAutoscaler %s/%s\n", request.Namespace, request.Name) + klog.Infof("Reconciling MachineAutoscaler %s/%s\n", request.Namespace, request.Name) // Fetch the MachineAutoscaler instance - ma := &v1alpha1.MachineAutoscaler{} + ma := &v1beta1.MachineAutoscaler{} err := r.client.Get(context.TODO(), request.NamespacedName, ma) if err != nil { if apierrors.IsNotFound(err) { @@ -171,7 +171,7 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err } // Error reading the object - requeue the request. - glog.Errorf("Error reading MachineAutoscaler: %v", err) + klog.Errorf("Error reading MachineAutoscaler: %v", err) return reconcile.Result{}, err } @@ -187,7 +187,7 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err if err != nil { errMsg := fmt.Sprintf("Error getting target: %v", err) r.recorder.Event(ma, corev1.EventTypeWarning, "FailedGetTarget", errMsg) - glog.Errorf("%s: %s", request.NamespacedName, errMsg) + klog.Errorf("%s: %s", request.NamespacedName, errMsg) return reconcile.Result{}, err } @@ -197,7 +197,7 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err if err != nil { errMsg := fmt.Sprintf("Error setting target owner: %v", err) r.recorder.Event(ma, corev1.EventTypeWarning, "FailedSetOwner", errMsg) - glog.Errorf("%s: %s", request.NamespacedName, errMsg) + klog.Errorf("%s: %s", request.NamespacedName, errMsg) return reconcile.Result{}, err } @@ -212,7 +212,7 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err // status, and it has changed relative to the current target, the // previous target must be finalized, e.g. annotations removed. if ma.Status.LastTargetRef != nil && r.TargetChanged(ma) { - glog.V(2).Infof("%s: Target changed", request.NamespacedName) + klog.V(2).Infof("%s: Target changed", request.NamespacedName) lastTargetRef := objectReference(*ma.Status.LastTargetRef) @@ -223,7 +223,7 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err // retain autoscaling configuration. errMsg := fmt.Sprintf("Error fetching previous target: %v", err) r.recorder.Event(ma, corev1.EventTypeWarning, "FailedGetLastTarget", errMsg) - glog.Errorf("%s: %s", request.NamespacedName, errMsg) + klog.Errorf("%s: %s", request.NamespacedName, errMsg) return reconcile.Result{}, err } @@ -237,7 +237,7 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err if err != nil && !apierrors.IsNotFound(err) { errMsg := fmt.Sprintf("Error finalizing previous target: %v", err) r.recorder.Event(ma, corev1.EventTypeWarning, "FailedFinalizeTarget", errMsg) - glog.Errorf("%s: %s", request.NamespacedName, errMsg) + klog.Errorf("%s: %s", request.NamespacedName, errMsg) return reconcile.Result{}, err } @@ -247,7 +247,7 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err if err := r.SetLastTarget(ma, targetRef); err != nil { errMsg := fmt.Sprintf("Error setting previous target: %v", err) r.recorder.Event(ma, corev1.EventTypeWarning, "FailedSetLastTarget", errMsg) - glog.Errorf("%s: %s", request.NamespacedName, errMsg) + klog.Errorf("%s: %s", request.NamespacedName, errMsg) return reconcile.Result{}, err } @@ -258,7 +258,7 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err if err := r.SetLastTarget(ma, targetRef); err != nil { errMsg := fmt.Sprintf("Error setting previous target: %v", err) r.recorder.Event(ma, corev1.EventTypeWarning, "FailedSetLastTarget", errMsg) - glog.Errorf("%s: %s", request.NamespacedName, errMsg) + klog.Errorf("%s: %s", request.NamespacedName, errMsg) return reconcile.Result{}, err } @@ -266,7 +266,7 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err // Ensure our finalizers have been added. if err := r.EnsureFinalizer(ma); err != nil { - glog.Errorf("Error setting finalizer: %v", err) + klog.Errorf("Error setting finalizer: %v", err) return reconcile.Result{}, err } @@ -276,26 +276,26 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err if err := r.UpdateTarget(target, min, max); err != nil { errMsg := fmt.Sprintf("Error updating target: %v", err) r.recorder.Event(ma, corev1.EventTypeWarning, "FailedUpdateTarget", errMsg) - glog.Errorf("%s: %s", request.NamespacedName, errMsg) + klog.Errorf("%s: %s", request.NamespacedName, errMsg) return reconcile.Result{}, err } msg := fmt.Sprintf("Updated MachineAutoscaler target: %s", target.NamespacedName()) r.recorder.Eventf(ma, corev1.EventTypeNormal, "SuccessfulUpdate", msg) - glog.V(2).Infof("%s: %s", request.NamespacedName, msg) + klog.V(2).Infof("%s: %s", request.NamespacedName, msg) return reconcile.Result{}, nil } // HandleDelete is called by Reconcile to handle MachineAutoscaler deletion, // i.e. finalize the resource and remove finalizers. -func (r *Reconciler) HandleDelete(ma *v1alpha1.MachineAutoscaler) (reconcile.Result, error) { +func (r *Reconciler) HandleDelete(ma *v1beta1.MachineAutoscaler) (reconcile.Result, error) { targetRef := objectReference(ma.Spec.ScaleTargetRef) target, err := r.GetTarget(targetRef) if err != nil && !apierrors.IsNotFound(err) { - glog.Errorf("Error getting target for finalization: %v", err) + klog.Errorf("Error getting target for finalization: %v", err) return reconcile.Result{}, err } @@ -304,13 +304,13 @@ func (r *Reconciler) HandleDelete(ma *v1alpha1.MachineAutoscaler) (reconcile.Res // Ignore 404s, the resource has most likely been deleted. if err != nil && !apierrors.IsNotFound(err) { - glog.Errorf("Error finalizing target: %v", err) + klog.Errorf("Error finalizing target: %v", err) return reconcile.Result{}, err } } if err := r.RemoveFinalizer(ma); err != nil { - glog.Errorf("Error removing finalizer: %v", err) + klog.Errorf("Error removing finalizer: %v", err) return reconcile.Result{}, err } @@ -339,7 +339,7 @@ func (r *Reconciler) GetTarget(ref *corev1.ObjectReference) (*MachineTarget, err target, err := MachineTargetFromObject(obj) if err != nil { - glog.Errorf("Failed to convert object to MachineTarget: %v", err) + klog.Errorf("Failed to convert object to MachineTarget: %v", err) return nil, err } @@ -371,7 +371,7 @@ func (r *Reconciler) FinalizeTarget(target *MachineTarget) error { // TargetChanged indicates whether a MachineAutoscaler's current target has // changed relative to the last observed target noted in the status. -func (r *Reconciler) TargetChanged(ma *v1alpha1.MachineAutoscaler) bool { +func (r *Reconciler) TargetChanged(ma *v1beta1.MachineAutoscaler) bool { currentRef := ma.Spec.ScaleTargetRef lastRef := ma.Status.LastTargetRef @@ -384,8 +384,8 @@ func (r *Reconciler) TargetChanged(ma *v1alpha1.MachineAutoscaler) bool { // SetLastTarget updates the give MachineAutoscaler's status with the given // object as the last observed target. -func (r *Reconciler) SetLastTarget(ma *v1alpha1.MachineAutoscaler, ref *corev1.ObjectReference) error { - ma.Status.LastTargetRef = &v1alpha1.CrossVersionObjectReference{ +func (r *Reconciler) SetLastTarget(ma *v1beta1.MachineAutoscaler, ref *corev1.ObjectReference) error { + ma.Status.LastTargetRef = &v1beta1.CrossVersionObjectReference{ APIVersion: ref.APIVersion, Kind: ref.Kind, Name: ref.Name, @@ -395,7 +395,7 @@ func (r *Reconciler) SetLastTarget(ma *v1alpha1.MachineAutoscaler, ref *corev1.O } // EnsureFinalizer adds finalizers to the given MachineAutoscaler if necessary. -func (r *Reconciler) EnsureFinalizer(ma *v1alpha1.MachineAutoscaler) error { +func (r *Reconciler) EnsureFinalizer(ma *v1beta1.MachineAutoscaler) error { for _, f := range ma.GetFinalizers() { // Bail early if we already have the finalizer. if f == MachineTargetFinalizer { @@ -411,7 +411,7 @@ func (r *Reconciler) EnsureFinalizer(ma *v1alpha1.MachineAutoscaler) error { // RemoveFinalizer removes this packages's finalizers from the given // MachineAutoscaler instance. -func (r *Reconciler) RemoveFinalizer(ma *v1alpha1.MachineAutoscaler) error { +func (r *Reconciler) RemoveFinalizer(ma *v1beta1.MachineAutoscaler) error { f, found := util.FilterString(ma.GetFinalizers(), MachineTargetFinalizer) if found == 0 { @@ -481,17 +481,17 @@ func (r *Reconciler) ValidateReference(obj *corev1.ObjectReference) (bool, error func targetOwnerRequest(a handler.MapObject) []reconcile.Request { target, err := MachineTargetFromObject(a.Object) if err != nil { - glog.Errorf("Failed to convert object to MachineTarget: %v", err) + klog.Errorf("Failed to convert object to MachineTarget: %v", err) return nil } owner, err := target.GetOwner() if err != nil { - glog.V(2).Infof("Will not reconcile: %v", err) + klog.V(2).Infof("Will not reconcile: %v", err) return nil } - glog.V(2).Infof("Queuing reconcile for owner of %s/%s.", + klog.V(2).Infof("Queuing reconcile for owner of %s/%s.", target.GetNamespace(), target.GetName()) return []reconcile.Request{{NamespacedName: owner}} @@ -499,7 +499,7 @@ func targetOwnerRequest(a handler.MapObject) []reconcile.Request { // objectReference returns a new corev1.ObjectReference for the given // CrossVersionObjectReference from a MachineAutoscaler target. -func objectReference(ref v1alpha1.CrossVersionObjectReference) *corev1.ObjectReference { +func objectReference(ref v1beta1.CrossVersionObjectReference) *corev1.ObjectReference { obj := &corev1.ObjectReference{} gvk := schema.FromAPIVersionAndKind(ref.APIVersion, ref.Kind) diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/operator/config.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/operator/config.go index b294a0e71..7ac4b5e33 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/operator/config.go +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/operator/config.go @@ -4,7 +4,7 @@ import ( "os" "strconv" - "github.com/golang/glog" + "k8s.io/klog" ) const ( @@ -136,7 +136,7 @@ func ConfigFromEnvironment() *Config { le, err := strconv.ParseBool(leaderElection) if err != nil { le = DefaultLeaderElection - glog.Errorf("Error parsing LEADER_ELECTION environment variable: %v", err) + klog.Errorf("Error parsing LEADER_ELECTION environment variable: %v", err) } config.LeaderElection = le @@ -170,7 +170,7 @@ func ConfigFromEnvironment() *Config { v, err := strconv.Atoi(caVerbosity) if err != nil { v = DefaultClusterAutoscalerVerbosity - glog.Errorf("Error parsing CLUSTER_AUTOSCALER_VERBOSITY environment variable: %v", err) + klog.Errorf("Error parsing CLUSTER_AUTOSCALER_VERBOSITY environment variable: %v", err) } config.ClusterAutoscalerVerbosity = v diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/operator/operator.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/operator/operator.go index b76785c8e..31eba56d4 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/operator/operator.go +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/operator/operator.go @@ -16,9 +16,7 @@ const OperatorName = "cluster-autoscaler" // Operator represents an instance of the cluster-autoscaler-operator. type Operator struct { config *Config - status *StatusReporter manager manager.Manager - checker AvailableChecker } // New returns a new Operator instance with the given config and a @@ -32,23 +30,6 @@ func New(cfg *Config) (*Operator, error) { return nil, err } - // track set of related namespaces for openshift-must-gather diagnostics - relatedNamespaces := map[string]string{} - relatedNamespaces[cfg.WatchNamespace] = "" - relatedNamespaces[cfg.LeaderElectionNamespace] = "" - relatedNamespaces[cfg.ClusterAutoscalerNamespace] = "" - relatedObjects := []configv1.ObjectReference{} - for k := range relatedNamespaces { - relatedObjects = append(relatedObjects, configv1.ObjectReference{ - Resource: "namespaces", - Name: k, - }) - } - operator.status, err = NewStatusReporter(clientConfig, relatedObjects, cfg.ReleaseVersion) - if err != nil { - return nil, err - } - // Create the controller-manager. managerOptions := manager.Options{ Namespace: cfg.WatchNamespace, @@ -71,9 +52,44 @@ func New(cfg *Config) (*Operator, error) { return nil, err } + statusConfig := &StatusReporterConfig{ + ClusterAutoscalerName: cfg.ClusterAutoscalerName, + ClusterAutoscalerNamespace: cfg.ClusterAutoscalerNamespace, + ReleaseVersion: cfg.ReleaseVersion, + RelatedObjects: operator.RelatedObjects(), + } + + statusReporter, err := NewStatusReporter(operator.manager, statusConfig) + if err != nil { + return nil, err + } + + operator.manager.Add(statusReporter) + return operator, nil } +// RelatedObjects returns a list of objects related to the operator and its +// operands. These are used in the ClusterOperator status. +func (o *Operator) RelatedObjects() []configv1.ObjectReference { + relatedNamespaces := map[string]string{} + + relatedNamespaces[o.config.WatchNamespace] = "" + relatedNamespaces[o.config.LeaderElectionNamespace] = "" + relatedNamespaces[o.config.ClusterAutoscalerNamespace] = "" + + relatedObjects := []configv1.ObjectReference{} + + for namespace := range relatedNamespaces { + relatedObjects = append(relatedObjects, configv1.ObjectReference{ + Resource: "namespaces", + Name: namespace, + }) + } + + return relatedObjects +} + // AddControllers configures the various controllers and adds them to // the operator's manager instance. func (o *Operator) AddControllers() error { @@ -89,8 +105,6 @@ func (o *Operator) AddControllers() error { ExtraArgs: o.config.ClusterAutoscalerExtraArgs, }) - o.checker = ca - if err := ca.AddToManager(o.manager); err != nil { return err } @@ -112,8 +126,5 @@ func (o *Operator) AddControllers() error { func (o *Operator) Start() error { stopCh := signals.SetupSignalHandler() - // Report status to the CVO. - go o.status.Report(stopCh, o.checker) - return o.manager.Start(stopCh) } diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/operator/status.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/operator/status.go index e75dd4ffd..18e2a3bd5 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/operator/status.go +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/operator/status.go @@ -1,18 +1,23 @@ package operator import ( + "context" "fmt" "time" - "github.com/golang/glog" configv1 "github.com/openshift/api/config/v1" osconfig "github.com/openshift/client-go/config/clientset/versioned" + autoscalingv1 "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1" + "github.com/openshift/cluster-autoscaler-operator/pkg/util" cvorm "github.com/openshift/cluster-version-operator/lib/resourcemerge" + appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/client-go/rest" + "k8s.io/klog" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/manager" ) // Reason messages used in status conditions. @@ -23,33 +28,33 @@ const ( ReasonCheckAutoscaler = "UnableToCheckAutoscalers" ) -// applyStatusInterface is used to enable unit testing and does not -// implement all methods of StatusReporter. -type applyStatusInterface interface { - checkMachineAPI() (bool, error) - fail(string, string) error - progressing() error - available(string, string) error -} - // StatusReporter reports the status of the operator to the OpenShift // cluster-version-operator via ClusterOperator resource status. type StatusReporter struct { - client osconfig.Interface - relatedObjects []configv1.ObjectReference - releaseVersion string + client client.Client + configClient osconfig.Interface + config *StatusReporterConfig +} + +// StatusReporterConfig represents the configuration of a given StatusReporter. +type StatusReporterConfig struct { + ClusterAutoscalerName string + ClusterAutoscalerNamespace string + ReleaseVersion string + RelatedObjects []configv1.ObjectReference } // NewStatusReporter returns a new StatusReporter instance. -func NewStatusReporter(cfg *rest.Config, relatedObjects []configv1.ObjectReference, releaseVersion string) (*StatusReporter, error) { +func NewStatusReporter(mgr manager.Manager, cfg *StatusReporterConfig) (*StatusReporter, error) { var err error + reporter := &StatusReporter{ - relatedObjects: relatedObjects, - releaseVersion: releaseVersion, + client: mgr.GetClient(), + config: cfg, } // Create a client for OpenShift config objects. - reporter.client, err = osconfig.NewForConfig(cfg) + reporter.configClient, err = osconfig.NewForConfig(mgr.GetConfig()) if err != nil { return nil, err } @@ -57,6 +62,28 @@ func NewStatusReporter(cfg *rest.Config, relatedObjects []configv1.ObjectReferen return reporter, nil } +// SetReleaseVersion sets the configured release version. +func (r *StatusReporter) SetReleaseVersion(version string) { + r.config.ReleaseVersion = version +} + +// SetRelatedObjects sets the configured related objects. +func (r *StatusReporter) SetRelatedObjects(objs []configv1.ObjectReference) { + r.config.RelatedObjects = objs +} + +// AddRelatedObjects adds to the list of related objects. +func (r *StatusReporter) AddRelatedObjects(objs []configv1.ObjectReference) { + for _, obj := range objs { + r.config.RelatedObjects = append(r.config.RelatedObjects, obj) + } +} + +// GetClusterOperator fetches the the operator's ClusterOperator object. +func (r *StatusReporter) GetClusterOperator() (*configv1.ClusterOperator, error) { + return r.configClient.ConfigV1().ClusterOperators().Get(OperatorName, metav1.GetOptions{}) +} + // GetOrCreateClusterOperator gets, or if necessary, creates the // operator's ClusterOperator object and returns it. func (r *StatusReporter) GetOrCreateClusterOperator() (*configv1.ClusterOperator, error) { @@ -66,196 +93,294 @@ func (r *StatusReporter) GetOrCreateClusterOperator() (*configv1.ClusterOperator }, } - existing, err := r.client.ConfigV1().ClusterOperators(). - Get(OperatorName, metav1.GetOptions{}) + existing, err := r.GetClusterOperator() if errors.IsNotFound(err) { - return r.client.ConfigV1().ClusterOperators().Create(clusterOperator) + return r.configClient.ConfigV1().ClusterOperators().Create(clusterOperator) } return existing, err } -// ApplyConditions applies the given conditions to the ClusterOperator -// resource's status. -func (r *StatusReporter) ApplyConditions(conds []configv1.ClusterOperatorStatusCondition, reachedLevel bool) error { - status := configv1.ClusterOperatorStatus{ - RelatedObjects: r.relatedObjects, +// ApplyStatus applies the given ClusterOperator status to the operator's +// ClusterOperator object if necessary. The currently configured RelatedObjects +// are automatically set on the status. If no ClusterOperator objects exists, +// one is created. +func (r *StatusReporter) ApplyStatus(status configv1.ClusterOperatorStatus) error { + var modified bool + + co, err := r.GetOrCreateClusterOperator() + if err != nil { + return err } - for _, c := range conds { - cvorm.SetOperatorStatusCondition(&status.Conditions, c) + // Set the currently configured related objects. + status.RelatedObjects = r.config.RelatedObjects + + // If no versions were set explicitly, continue reporting previous versions. + if status.Versions == nil { + status.Versions = co.Status.Versions } - if reachedLevel { - status.Versions = []configv1.OperandVersion{ - { - Name: "operator", - Version: r.releaseVersion, - }, + // Update LastTransitionTime for all conditions if necessary. + for i := range status.Conditions { + condType := status.Conditions[i].Type + timestamp := metav1.NewTime(time.Now()) + + c := cvorm.FindOperatorStatusCondition(co.Status.Conditions, condType) + + // If found, and status doesn't match, update. + if c != nil && c.Status != status.Conditions[i].Status { + status.Conditions[i].LastTransitionTime = timestamp + } + + // If found, and status matches, copy previous. + if c != nil && c.Status == status.Conditions[i].Status { + status.Conditions[i].LastTransitionTime = c.LastTransitionTime + } + + // If it's still nil, update it. + if status.Conditions[i].LastTransitionTime.IsZero() { + status.Conditions[i].LastTransitionTime = timestamp } - glog.Infof("Setting operator version to: %v", r.releaseVersion) - } else { - status.Versions = nil - glog.Info("Setting operator version to nil") } - co, err := r.GetOrCreateClusterOperator() - if err != nil { - return err + // If any versions have changed, we need to reset the transition time on the + // Progressing condition whether or not we actually had any work to do. + if !equality.Semantic.DeepEqual(status.Versions, co.Status.Versions) { + util.ResetProgressingTime(&status.Conditions) } - if !equality.Semantic.DeepEqual(co.Status, status) { - glog.Info("operator status not current; Updating operator") - co.Status = status - _, err = r.client.ConfigV1().ClusterOperators().UpdateStatus(co) + // Copy the current ClusterOperator and overwrite the status. + requiredCO := &configv1.ClusterOperator{} + co.DeepCopyInto(requiredCO) + requiredCO.Status = status + + cvorm.EnsureClusterOperatorStatus(&modified, co, *requiredCO) + + if modified { + _, err := r.configClient.ConfigV1().ClusterOperators().UpdateStatus(co) + return err } - return err + return nil } // available reports the operator as available, not progressing, and -// not failing -- optionally setting a reason and message. +// not degraded -- optionally setting a reason and message. This will +// update the reported operator version. It should only be called if +// the operands are fully updated and available. func (r *StatusReporter) available(reason, message string) error { - conditions := []configv1.ClusterOperatorStatusCondition{ - { - Type: configv1.OperatorAvailable, - Status: configv1.ConditionTrue, - Reason: reason, - Message: message, - }, - { - Type: configv1.OperatorProgressing, - Status: configv1.ConditionFalse, + status := configv1.ClusterOperatorStatus{ + Conditions: []configv1.ClusterOperatorStatusCondition{ + { + Type: configv1.OperatorAvailable, + Status: configv1.ConditionTrue, + Reason: reason, + Message: message, + }, + { + Type: configv1.OperatorProgressing, + Status: configv1.ConditionFalse, + }, + { + Type: configv1.OperatorDegraded, + Status: configv1.ConditionFalse, + }, }, - { - Type: configv1.OperatorFailing, - Status: configv1.ConditionFalse, + Versions: []configv1.OperandVersion{ + { + Name: "operator", + Version: r.config.ReleaseVersion, + }, }, } - glog.Info("Setting operator to available") - return r.ApplyConditions(conditions, true) + + klog.Infof("Operator status available: %s", message) + + return r.ApplyStatus(status) } -// Fail reports the operator as failing but available, and not +// degraded reports the operator as degraded but available, and not // progressing -- optionally setting a reason and message. -func (r *StatusReporter) fail(reason, message string) error { - conditions := []configv1.ClusterOperatorStatusCondition{ - { - Type: configv1.OperatorAvailable, - Status: configv1.ConditionTrue, - }, - { - Type: configv1.OperatorProgressing, - Status: configv1.ConditionFalse, - }, - { - Type: configv1.OperatorFailing, - Status: configv1.ConditionTrue, - Reason: reason, - Message: message, +func (r *StatusReporter) degraded(reason, message string) error { + status := configv1.ClusterOperatorStatus{ + Conditions: []configv1.ClusterOperatorStatusCondition{ + { + Type: configv1.OperatorAvailable, + Status: configv1.ConditionTrue, + }, + { + Type: configv1.OperatorProgressing, + Status: configv1.ConditionFalse, + }, + { + Type: configv1.OperatorDegraded, + Status: configv1.ConditionTrue, + Reason: reason, + Message: message, + }, }, } - return r.ApplyConditions(conditions, false) -} + klog.Warningf("Operator status degraded: %s", message) -type AvailableChecker interface { - // AvailableAndUpdated returns true if the reconciler reports all - // cluster autoscalers are at the latest version. - AvailableAndUpdated() (bool, error) + return r.ApplyStatus(status) } // progressing reports the operator as progressing but available, and not -// failing -- optionally setting a reason and message. -func (r *StatusReporter) progressing() error { - glog.Infof("Syncing to version %v", r.releaseVersion) - conditions := []configv1.ClusterOperatorStatusCondition{ - { - Type: configv1.OperatorAvailable, - Status: configv1.ConditionTrue, - }, - { - Type: configv1.OperatorProgressing, - Status: configv1.ConditionTrue, - Reason: ReasonSyncing, - Message: fmt.Sprintf("Syncing to version %v", r.releaseVersion), - }, - { - Type: configv1.OperatorFailing, - Status: configv1.ConditionFalse, +// degraded -- optionally setting a reason and message. +func (r *StatusReporter) progressing(reason, message string) error { + status := configv1.ClusterOperatorStatus{ + Conditions: []configv1.ClusterOperatorStatusCondition{ + { + Type: configv1.OperatorAvailable, + Status: configv1.ConditionTrue, + }, + { + Type: configv1.OperatorProgressing, + Status: configv1.ConditionTrue, + Reason: reason, + Message: message, + }, + { + Type: configv1.OperatorDegraded, + Status: configv1.ConditionFalse, + }, }, } - return r.ApplyConditions(conditions, false) + klog.Infof("Operator status progressing: %s", message) + + return r.ApplyStatus(status) } -// applyStatusInterface required here for test coverage of critical code. -// In actual operation, we are passing in StatusReporter. -func applyStatus(r applyStatusInterface, check AvailableChecker) (bool, error) { - ok, err := r.checkMachineAPI() - if err != nil { - r.fail(ReasonMissingDependency, fmt.Sprintf("error checking machine-api operator status %v", err)) - return false, nil - } - if !ok { - r.fail(ReasonMissingDependency, "machine-api operator not ready") - return false, nil +// Start checks the status of dependencies and reports the operator's status. It +// will poll until stopCh is closed or prerequisites are satisfied, in which +// case it will report the operator as available the configured version and wait +// for stopCh to close before returning. +func (r *StatusReporter) Start(stopCh <-chan struct{}) error { + interval := 15 * time.Second + + // Poll the status of our prerequisites and set our status + // accordingly. Rather than return errors and stop polling, most + // errors here should just be reported in the status message. + pollFunc := func() (bool, error) { + return r.ReportStatus() } - ok, err = check.AvailableAndUpdated() + + err := wait.PollImmediateUntil(interval, pollFunc, stopCh) + + // Block until the stop channel is closed. + <-stopCh + + return err +} + +// ReportStatus checks the status of each dependency and operand and reports the +// appropriate status via the operator's ClusterOperator object. +func (r *StatusReporter) ReportStatus() (bool, error) { + // Check that the machine-api-operator is reporting available. + ok, err := r.CheckMachineAPI() if err != nil { - r.fail(ReasonCheckAutoscaler, fmt.Sprintf("error checking autoscaler operator status: %v", err)) + msg := fmt.Sprintf("error checking machine-api status: %v", err) + r.degraded(ReasonMissingDependency, msg) return false, nil } + if !ok { - r.progressing() + r.degraded(ReasonMissingDependency, "machine-api not ready") return false, nil } - err = r.available(ReasonEmpty, "") + // Check that any CluterAutoscaler deployments are updated and available. + ok, err = r.CheckClusterAutoscaler() if err != nil { + msg := fmt.Sprintf("error checking autoscaler status: %v", err) + r.degraded(ReasonCheckAutoscaler, msg) return false, nil } - return true, nil -} - -// Report checks the status of dependencies and reports the operator's -// status. It will poll until stopCh is closed or prerequisites are -// satisfied, in which case it will report the operator as available -// and return. check is used to verify that the reconciler has reached -// the desired state. -func (r *StatusReporter) Report(stopCh <-chan struct{}, check AvailableChecker) error { - interval := 15 * time.Second - // Poll the status of our prerequisites and set our status - // accordingly. Rather than return errors and stop polling, most - // errors here should just be reported in the status message. - pollFunc := func() (bool, error) { - return applyStatus(r, check) + if !ok { + msg := fmt.Sprintf("updating to %s", r.config.ReleaseVersion) + r.progressing(ReasonSyncing, msg) + return false, nil } - return wait.PollImmediateUntil(interval, pollFunc, stopCh) + msg := fmt.Sprintf("at version %s", r.config.ReleaseVersion) + r.available(ReasonEmpty, msg) + + return true, nil } -// checkMachineAPI checks the status of the machine-api-operator as +// CheckMachineAPI checks the status of the machine-api-operator as // reported to the CVO. It returns true if the operator is available -// and not failing. -func (r *StatusReporter) checkMachineAPI() (bool, error) { - mao, err := r.client.ConfigV1().ClusterOperators(). +// and not degraded. +func (r *StatusReporter) CheckMachineAPI() (bool, error) { + mao, err := r.configClient.ConfigV1().ClusterOperators(). Get("machine-api", metav1.GetOptions{}) if err != nil { - glog.Errorf("failed to get dependency machine-api status: %v", err) + klog.Errorf("failed to get dependency machine-api status: %v", err) return false, err } conds := mao.Status.Conditions if cvorm.IsOperatorStatusConditionTrue(conds, configv1.OperatorAvailable) && - cvorm.IsOperatorStatusConditionFalse(conds, configv1.OperatorFailing) { + (cvorm.IsOperatorStatusConditionFalse(conds, configv1.OperatorFailing) || + cvorm.IsOperatorStatusConditionFalse(conds, configv1.OperatorDegraded)) { return true, nil } - glog.Infof("machine-api-operator not ready yet") + klog.Infof("machine-api-operator not ready yet") return false, nil } + +// CheckClusterAutoscaler checks the status of any cluster-autoscaler +// deployments. It returns a bool indicating whether the deployments are +// available and fully updated to the latest version and an error. +func (r *StatusReporter) CheckClusterAutoscaler() (bool, error) { + ca := &autoscalingv1.ClusterAutoscaler{} + caName := client.ObjectKey{Name: r.config.ClusterAutoscalerName} + + if err := r.client.Get(context.TODO(), caName, ca); err != nil { + if errors.IsNotFound(err) { + klog.Info("No ClusterAutoscaler. Reporting available.") + return true, nil + } + + klog.Errorf("Error getting ClusterAutoscaler: %v", err) + return false, err + } + + deployment := &appsv1.Deployment{} + deploymentName := client.ObjectKey{ + Name: fmt.Sprintf("%s-%s", OperatorName, r.config.ClusterAutoscalerName), + Namespace: r.config.ClusterAutoscalerNamespace, + } + + if err := r.client.Get(context.TODO(), deploymentName, deployment); err != nil { + if errors.IsNotFound(err) { + klog.Info("No ClusterAutoscaler deployment. Reporting unavailable.") + return false, nil + } + + klog.Errorf("Error getting ClusterAutoscaler deployment: %v", err) + return false, err + } + + if !util.ReleaseVersionMatches(deployment, r.config.ReleaseVersion) { + klog.Info("ClusterAutoscaler deployment version not current.") + return false, nil + } + + if !util.DeploymentUpdated(deployment) { + klog.Info("ClusterAutoscaler deployment updating.") + return false, nil + } + + klog.Info("ClusterAutoscaler deployment is available and updated.") + + return true, nil +} diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/util/util.go b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/util/util.go index 775cc61db..558a80611 100644 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/util/util.go +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/pkg/util/util.go @@ -1,5 +1,18 @@ package util +import ( + configv1 "github.com/openshift/api/config/v1" + cvorm "github.com/openshift/cluster-version-operator/lib/resourcemerge" + appsv1 "k8s.io/api/apps/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// Common Kubernetes object annotations. +const ( + ReleaseVersionAnnotation = "release.openshift.io/version" + CriticalPodAnnotation = "scheduler.alpha.kubernetes.io/critical-pod" +) + // FilterString removes any instances of the needle from haystack. It // returns a new slice with all instances of needle removed, and a // count of the number instances encountered. @@ -17,3 +30,53 @@ func FilterString(haystack []string, needle string) ([]string, int) { return newSlice, found } + +// ReleaseVersionMatches checks whether a Kubernetes object has an OpenShift +// release version annotation that matches the given version. +func ReleaseVersionMatches(obj metav1.Object, version string) bool { + annotations := obj.GetAnnotations() + + value, found := annotations[ReleaseVersionAnnotation] + if !found || value != version { + return false + } + + return true +} + +// DeploymentUpdated checks whether a Kubernetes deployment object's replicas +// are fully updated and available. +func DeploymentUpdated(dep *appsv1.Deployment) bool { + if dep.Status.ObservedGeneration < dep.Generation { + return false + } + + if dep.Status.UpdatedReplicas != dep.Status.Replicas { + return false + } + + if dep.Status.AvailableReplicas == 0 { + return false + } + + return true +} + +// ResetProgressingTime finds the Progressing condition in the given slice, or +// creates a default one if none is found, and sets the LastTransitionTime to +// the current time. +func ResetProgressingTime(conds *[]configv1.ClusterOperatorStatusCondition) { + prog := cvorm.FindOperatorStatusCondition(*conds, configv1.OperatorProgressing) + + // If the Progressing condition wasn't found, set a default one. + if prog == nil { + prog = &configv1.ClusterOperatorStatusCondition{ + Type: configv1.OperatorProgressing, + Status: configv1.ConditionFalse, + } + } + + prog.LastTransitionTime = metav1.Now() + + cvorm.SetOperatorStatusCondition(conds, *prog) +} diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/cluster-autoscaler-operator-patch.yaml b/vendor/github.com/openshift/cluster-autoscaler-operator/test/cluster-autoscaler-operator-patch.yaml similarity index 100% rename from vendor/github.com/openshift/cluster-autoscaler-operator/cluster-autoscaler-operator-patch.yaml rename to vendor/github.com/openshift/cluster-autoscaler-operator/test/cluster-autoscaler-operator-patch.yaml diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/test/e2e/main.go b/vendor/github.com/openshift/cluster-autoscaler-operator/test/e2e/main.go deleted file mode 100644 index bbf1179e8..000000000 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/test/e2e/main.go +++ /dev/null @@ -1,111 +0,0 @@ -package main - -import ( - "flag" - "strings" - - "github.com/golang/glog" - osconfigv1 "github.com/openshift/api/config/v1" - "github.com/openshift/cluster-autoscaler-operator/pkg/apis" - "k8s.io/client-go/kubernetes/scheme" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/client/config" -) - -const ( - caName = "default" -) - -var focus string -var namespace string - -func init() { - flag.StringVar(&focus, "focus", "[openshift]", "If set, run only tests containing focus string. E.g. [k8s]") - flag.StringVar(&namespace, "namespace", "openshift-machine-api", "cluster-autoscaler-operator namespace") -} - -var F *Framework - -type Framework struct { - Client client.Client -} - -func newClient() error { - // Get a config to talk to the apiserver - cfg, err := config.GetConfig() - if err != nil { - return err - } - - client, err := client.New(cfg, client.Options{}) - if err != nil { - return err - } - - F = &Framework{Client: client} - - return nil -} - -func main() { - flag.Parse() - - if err := apis.AddToScheme(scheme.Scheme); err != nil { - glog.Fatal(err) - } - - if err := osconfigv1.AddToScheme(scheme.Scheme); err != nil { - glog.Fatal(err) - } - - if err := newClient(); err != nil { - glog.Fatal(err) - } - - if err := runSuite(); err != nil { - glog.Fatal(err) - } -} - -func runSuite() error { - - expectations := []struct { - expect func() error - name string - }{ - { - expect: ExpectOperatorAvailable, - name: "[k8s][openshift] Expect operator to be available", - }, - { - expect: ExpectClusterOperatorStatusAvailable, - name: "[openshift] Expect Cluster Operator status to be available", - }, - { - expect: CreateClusterAutoscaler, - name: "[openshift] Create Cluster Autoscaler resource", - }, - { - expect: ExpectClusterAutoscalerAvailable, - name: "[openshift] Expect Cluster Autoscaler available", - }, - { - expect: ExpectToScaleUpAndDown, - name: "[k8s] Expect to scale up and down", - }, - } - - for _, tc := range expectations { - if strings.HasPrefix(tc.name, focus) { - if err := tc.expect(); err != nil { - glog.Errorf("FAIL: %v: %v", tc.name, err) - return err - } - glog.Infof("PASS: %v", tc.name) - } else { - glog.Infof("SKIPPING: %v", tc.name) - } - } - - return nil -} diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/test/e2e/operator_expectations.go b/vendor/github.com/openshift/cluster-autoscaler-operator/test/e2e/operator_expectations.go deleted file mode 100644 index c595e8140..000000000 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/test/e2e/operator_expectations.go +++ /dev/null @@ -1,325 +0,0 @@ -package main - -import ( - "fmt" - "github.com/openshift/cluster-autoscaler-operator/pkg/operator" - "time" - - "context" - - "github.com/golang/glog" - osconfigv1 "github.com/openshift/api/config/v1" - autoscalingv1alpha1 "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1alpha1" - cvorm "github.com/openshift/cluster-version-operator/lib/resourcemerge" - kappsapi "k8s.io/api/apps/v1" - batchv1 "k8s.io/api/batch/v1" - "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/resource" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/util/wait" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -const nodeGroupSize = 6 - -func clusterAutoscalerResource() *autoscalingv1alpha1.ClusterAutoscaler { - var ( - PodPriorityThreshold int32 = -10 - MaxPodGracePeriod int32 = 60 - MaxNodesTotal int32 = 100 - CoresMin int32 = 16 - CoresMax int32 = 32 - MemoryMin int32 = 32 - MemoryMax int32 = 64 - ) - - return &autoscalingv1alpha1.ClusterAutoscaler{ - TypeMeta: metav1.TypeMeta{ - Kind: "ClusterAutoscaler", - APIVersion: "autoscaling.openshift.io/v1alpha1", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: caName, - Namespace: namespace, - }, - Spec: autoscalingv1alpha1.ClusterAutoscalerSpec{ - MaxPodGracePeriod: &MaxPodGracePeriod, - PodPriorityThreshold: &PodPriorityThreshold, - ResourceLimits: &autoscalingv1alpha1.ResourceLimits{ - MaxNodesTotal: &MaxNodesTotal, - Cores: &autoscalingv1alpha1.ResourceRange{ - Min: CoresMin, - Max: CoresMax, - }, - Memory: &autoscalingv1alpha1.ResourceRange{ - Min: MemoryMin, - Max: MemoryMax, - }, - }, - }, - } -} - -func machineAutoscalerResource() *autoscalingv1alpha1.MachineAutoscaler { - return &autoscalingv1alpha1.MachineAutoscaler{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachineAutoscaler", - APIVersion: "autoscaling.openshift.io/v1alpha1", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: "compute-pool", - Namespace: namespace, - }, - Spec: autoscalingv1alpha1.MachineAutoscalerSpec{ - MinReplicas: 1, - MaxReplicas: nodeGroupSize, - ScaleTargetRef: autoscalingv1alpha1.CrossVersionObjectReference{ - Kind: "MachineSet", - APIVersion: "machine.openshift.io/v1beta1", - Name: "kubemark-machine-pool", - }, - }, - } -} - -func workloadResource() *batchv1.Job { - var backoffLimit int32 = 4 - var completions int32 = 40 - var parallelism int32 = 40 - return &batchv1.Job{ - ObjectMeta: metav1.ObjectMeta{ - Name: "workload", - Namespace: "default", - }, - Spec: batchv1.JobSpec{ - Template: v1.PodTemplateSpec{ - Spec: v1.PodSpec{ - Containers: []v1.Container{ - { - Name: "work", - Image: "busybox", - Command: []string{ - "sleep", - "120", - }, - Resources: v1.ResourceRequirements{ - Requests: v1.ResourceList{ - "cpu": resource.MustParse("500m"), - "memory": resource.MustParse("500Mi"), - }, - }, - }, - }, - RestartPolicy: v1.RestartPolicyNever, - NodeSelector: map[string]string{ - "node-role.kubernetes.io/compute": "", - }, - Tolerations: []v1.Toleration{ - { - Key: "kubemark", - Operator: v1.TolerationOpExists, - }, - }, - }, - }, - BackoffLimit: &backoffLimit, - Completions: &completions, - Parallelism: ¶llelism, - }, - } -} - -func verifyClusterAutoscalerOperatorIsReady() error { - name := "cluster-autoscaler-operator" - key := types.NamespacedName{ - Namespace: namespace, - Name: name, - } - d := &kappsapi.Deployment{} - - err := wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) { - if err := F.Client.Get(context.TODO(), key, d); err != nil { - glog.Errorf("error querying api for Deployment object: %v, retrying...", err) - return false, nil - } - if d.Status.ReadyReplicas < 1 { - return false, nil - } - return true, nil - }) - return err -} - -func verifyClusterAutoscalerIsReady() error { - name := fmt.Sprintf("cluster-autoscaler-%s", caName) - key := types.NamespacedName{ - Namespace: namespace, - Name: name, - } - d := &kappsapi.Deployment{} - - err := wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) { - if err := F.Client.Get(context.TODO(), key, d); err != nil { - glog.Errorf("error querying api for Deployment object: %v, retrying...", err) - return false, nil - } - if d.Status.ReadyReplicas < 1 { - return false, nil - } - return true, nil - }) - return err -} - -func ExpectOperatorAvailable() error { - return verifyClusterAutoscalerOperatorIsReady() -} - -func ExpectClusterOperatorStatusAvailable() error { - name := operator.OperatorName - key := types.NamespacedName{ - Namespace: namespace, - Name: name, - } - clusterOperator := &osconfigv1.ClusterOperator{} - - err := wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) { - if err := F.Client.Get(context.TODO(), key, clusterOperator); err != nil { - glog.Errorf("error querying api for OperatorStatus object: %v, retrying...", err) - return false, nil - } - if cvorm.IsOperatorStatusConditionTrue(clusterOperator.Status.Conditions, osconfigv1.OperatorAvailable) { - return true, nil - } - return false, nil - }) - return err -} - -func CreateClusterAutoscaler() error { - ca := clusterAutoscalerResource() - return F.Client.Create(context.TODO(), ca) -} - -func ExpectClusterAutoscalerAvailable() error { - return verifyClusterAutoscalerIsReady() -} - -func isNodeReady(node *v1.Node) bool { - for _, c := range node.Status.Conditions { - if c.Type == v1.NodeReady { - return c.Status == v1.ConditionTrue - } - } - return false -} - -// ExpectToScaleUpAndDown assumes the cluster autoscaler is already deployed -func ExpectToScaleUpAndDown() error { - tenSeconds := "10s" - - ca := *clusterAutoscalerResource() - // change the min core and memory to 1 so the autoscaler scales down as much as it can - ca.Spec.ResourceLimits.Cores.Min = 1 - ca.Spec.ResourceLimits.Memory.Min = 1 - ca.Spec.ScaleDown = &autoscalingv1alpha1.ScaleDownConfig{ - Enabled: true, - DelayAfterAdd: &tenSeconds, - DelayAfterDelete: &tenSeconds, - DelayAfterFailure: &tenSeconds, - UnneededTime: &tenSeconds, - } - if err := F.Client.Create(context.TODO(), &ca); err != nil { - return fmt.Errorf("unable to deploy ClusterAutoscaler resource: %v", err) - } - - if err := verifyClusterAutoscalerIsReady(); err != nil { - return fmt.Errorf("cluster autoscaler not ready: %v", err) - } - - ma := machineAutoscalerResource() - if err := F.Client.Create(context.TODO(), ma); err != nil { - return fmt.Errorf("unable to deploy MachineAutoscaler resource: %v", err) - } - - workload := workloadResource() - if err := F.Client.Create(context.TODO(), workload); err != nil { - return fmt.Errorf("unable to deploy workload resource: %v", err) - } - - err := wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) { - nodes := v1.NodeList{} - if err := F.Client.List(context.TODO(), &client.ListOptions{}, &nodes); err != nil { - glog.Errorf("error querying api for Node object: %v, retrying...", err) - return false, nil - } - // expecting nodeGroupSize nodes - nodeCounter := 0 - for _, node := range nodes.Items { - if _, exists := node.Labels["node-role.kubernetes.io/compute"]; !exists { - continue - } - - if !isNodeReady(&node) { - continue - } - - nodeCounter++ - } - - if nodeCounter < 6 { - glog.Errorf("Expecting %v nodes with 'node-role.kubernetes.io/compute' label in Ready state, got %v", nodeGroupSize, nodeCounter) - return false, nil - } - - glog.Infof("Expected number (%v) of nodes with 'node-role.kubernetes.io/compute' label in Ready state found", nodeGroupSize) - return true, nil - }) - - if err != nil { - return err - } - - glog.Infof("Succesfully scaled up") - - cascadeDelete := metav1.DeletePropagationForeground - if err := F.Client.Delete(context.TODO(), workload, func(opt *client.DeleteOptions) { opt.PropagationPolicy = &cascadeDelete }); err != nil { - return fmt.Errorf("unable to delete workload resource: %v", err) - } - - if err = wait.PollImmediate(1*time.Second, 10*time.Minute, func() (bool, error) { - nodes := v1.NodeList{} - if err := F.Client.List(context.TODO(), &client.ListOptions{}, &nodes); err != nil { - glog.Errorf("error querying api for Node object: %v, retrying...", err) - return false, nil - } - // expecting nodeGroupSize nodes - nodeCounter := 0 - for _, node := range nodes.Items { - if _, exists := node.Labels["node-role.kubernetes.io/compute"]; !exists { - continue - } - - if !isNodeReady(&node) { - continue - } - - nodeCounter++ - } - - if nodeCounter > 1 { - glog.Errorf("Expecting 1 node with 'node-role.kubernetes.io/compute' label in Ready state, got %v", nodeCounter) - return false, nil - } - - glog.Info("Expected number (1) of nodes with 'node-role.kubernetes.io/compute' label in Ready state found") - return true, nil - }); err != nil { - return err - } - - glog.Infof("Succesfully scaled down") - - return nil -} diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/test/helpers/helpers.go b/vendor/github.com/openshift/cluster-autoscaler-operator/test/helpers/helpers.go new file mode 100644 index 000000000..485210ec8 --- /dev/null +++ b/vendor/github.com/openshift/cluster-autoscaler-operator/test/helpers/helpers.go @@ -0,0 +1,127 @@ +package helpers + +import ( + configv1 "github.com/openshift/api/config/v1" + "github.com/openshift/cluster-autoscaler-operator/pkg/util" + appsv1 "k8s.io/api/apps/v1" +) + +// TestDeployment wraps the appsv1.Deployment type to add helper methods. +type TestDeployment struct { + appsv1.Deployment +} + +// NewTestDeployment returns a new TestDeployment wrapping the given +// appsv1.Deployment object. +func NewTestDeployment(dep *appsv1.Deployment) *TestDeployment { + return &TestDeployment{Deployment: *dep} +} + +// Copy returns a pointer to a new TestDeploymentdeep with a deep copy of the +// originally wrapped appsv1.Deployment object. +func (d *TestDeployment) Copy() *TestDeployment { + newDeployment := &appsv1.Deployment{} + d.Deployment.DeepCopyInto(newDeployment) + + return NewTestDeployment(newDeployment) +} + +// WithAvailableReplicas returns a copy of the object with the AvailableReplicas +// field set to the given value. +func (d *TestDeployment) WithAvailableReplicas(n int32) *TestDeployment { + newDeployment := d.Copy() + newDeployment.Status.AvailableReplicas = n + + return newDeployment +} + +// WithReleaseVersion returns a copy of the object with the release version +// annotation set to the given value. +func (d *TestDeployment) WithReleaseVersion(v string) *TestDeployment { + newDeployment := d.Copy() + annotations := newDeployment.GetAnnotations() + + if annotations == nil { + annotations = map[string]string{} + } + + annotations[util.ReleaseVersionAnnotation] = v + newDeployment.SetAnnotations(annotations) + + return newDeployment +} + +// WithAnnotations returns a copy of the object with the annotations set to the +// given value. +func (d *TestDeployment) WithAnnotations(a map[string]string) *TestDeployment { + newDeployment := d.Copy() + newDeployment.SetAnnotations(a) + + return newDeployment +} + +// Object returns a copy of the wrapped appsv1.Deployment object. +func (d *TestDeployment) Object() *appsv1.Deployment { + return d.Deployment.DeepCopy() +} + +// TestClusterOperator wraps the ClusterOperator type to add helper methods. +type TestClusterOperator struct { + configv1.ClusterOperator +} + +// NewTestClusterOperator returns a new TestDeployment wrapping the given +// OpenShift ClusterOperator object. +func NewTestClusterOperator(co *configv1.ClusterOperator) *TestClusterOperator { + return &TestClusterOperator{ClusterOperator: *co} +} + +// Copy returns a deep copy of the wrapped object. +func (co *TestClusterOperator) Copy() *TestClusterOperator { + newCO := &configv1.ClusterOperator{} + co.ClusterOperator.DeepCopyInto(newCO) + + return NewTestClusterOperator(newCO) +} + +// WithConditions returns a copy of the wrapped ClusterOperator object with the +// status conditions set to the given list. +func (co *TestClusterOperator) WithConditions(conds []configv1.ClusterOperatorStatusCondition) *TestClusterOperator { + newCO := co.Copy() + newCO.Status.Conditions = conds + + return newCO +} + +// WithVersion returns a copy of the object with the "operator" +// OperandVersion's version field set to the given value. +func (co *TestClusterOperator) WithVersion(v string) *TestClusterOperator { + newCO := co.Copy() + + if newCO.Status.Versions == nil { + newCO.Status.Versions = []configv1.OperandVersion{{Name: "operator"}} + } + + found := false + + for i := range newCO.Status.Versions { + if newCO.Status.Versions[i].Name == "operator" { + found = true + newCO.Status.Versions[i].Version = v + } + } + + if !found { + newCO.Status.Versions = append(newCO.Status.Versions, configv1.OperandVersion{ + Name: "operator", + Version: v, + }) + } + + return newCO +} + +// Object returns a copy of the wrapped configv1.ClusterOperator object. +func (co *TestClusterOperator) Object() *configv1.ClusterOperator { + return co.ClusterOperator.DeepCopy() +} diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/test/resources/cluster.yaml b/vendor/github.com/openshift/cluster-autoscaler-operator/test/resources/cluster.yaml deleted file mode 100644 index e1e4f21f5..000000000 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/test/resources/cluster.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -apiVersion: "cluster.k8s.io/v1alpha1" -kind: Cluster -metadata: - name: kubemark - namespace: kube-system -spec: - clusterNetwork: - services: - cidrBlocks: - - "10.0.0.1/24" - pods: - cidrBlocks: - - "10.0.0.2/24" - serviceDomain: example.com diff --git a/vendor/github.com/openshift/cluster-autoscaler-operator/test/resources/machine-set.yaml b/vendor/github.com/openshift/cluster-autoscaler-operator/test/resources/machine-set.yaml deleted file mode 100644 index ece739f16..000000000 --- a/vendor/github.com/openshift/cluster-autoscaler-operator/test/resources/machine-set.yaml +++ /dev/null @@ -1,26 +0,0 @@ ---- -apiVersion: machine.openshift.io/v1beta1 -kind: MachineSet -metadata: - name: kubemark-machine-pool - namespace: kube-system -spec: - replicas: 1 - selector: - matchLabels: - machine.openshift.io/cluster-api-machineset: kubemark-machine-pool - template: - metadata: - labels: - machine.openshift.io/cluster-api-machineset: kubemark-machine-pool - spec: - metadata: - labels: - node-role.kubernetes.io/compute: "" - providerSpec: - value: - apiVersion: kubemarkproviderconfig.k8s.io/v1alpha1 - kind: KubemarkMachineProviderConfig - versions: - kubelet: 1.10.1 - controlPlane: 1.10.1