Skip to content

Commit b38e2c5

Browse files
author
Joshua Reed
committed
Merging.
2 parents ed57264 + 21fbad7 commit b38e2c5

File tree

63 files changed

+1702
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1702
-201
lines changed

.github/workflows/go-coverage.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Test coverage
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
branches:
7+
- main
8+
pull_request:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-go@v2
16+
with:
17+
go-version: 1.17.8
18+
- name: Run go test with coverage
19+
run: COVER_PROFILE=coverage.txt make test
20+
- name: Codecov upload
21+
uses: codecov/[email protected]
22+
with:
23+
files: ./cover.out

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ linters-settings:
1717
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1818
See the License for the specific language governing permissions and
1919
limitations under the License.
20+
gocyclo:
21+
min-complexity: 15
2022

2123
linters:
2224
enable:
2325
- gosec
2426
- goheader
2527
- revive
28+
- gocyclo
29+
- misspell
2630

2731
run:
2832
issues-exit-code: 1

ATTRIBUTION.txt

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
** cloud.google.com/go/compute/metadata; version v0.93.3 --
33
https://github.com/googleapis/google-cloud-go
44

5-
** github.com/apache/cloudstack-go/v2/cloudstack; version v2.11.1-0.20211020121644-369057554f66 --
5+
** github.com/apache/cloudstack-go/v2/cloudstack; version v2.13.0 --
66
https://github.com/apache/cloudstack-go/v2
77

88
** github.com/Azure/go-autorest/autorest; version v0.11.18 --
@@ -29,7 +29,7 @@ https://github.com/coredns/corefile-migration
2929
** github.com/docker/distribution; version v2.7.1+incompatible --
3030
https://github.com/distribution/distribution
3131

32-
** github.com/go-logr/logr; version v0.4.0 --
32+
** github.com/go-logr/logr; version v1.2.3 --
3333
https://github.com/go-logr/logr
3434

3535
** github.com/golang/groupcache/lru; version v0.0.0-20210331224755-41bb18bfe9da --
@@ -50,7 +50,7 @@ https://github.com/matttproud/golang_protobuf_extensions
5050
** github.com/modern-go/concurrent; version v0.0.0-20180306012644-bacd9c7ef1dd --
5151
https://github.com/modern-go/concurrent
5252

53-
** github.com/modern-go/reflect2; version v1.0.1 --
53+
** github.com/modern-go/reflect2; version v1.0.2 --
5454
https://github.com/modern-go/reflect2
5555

5656
** github.com/opencontainers/go-digest; version v1.0.0 --
@@ -62,7 +62,7 @@ https://github.com/prometheus/client_golang
6262
** github.com/prometheus/client_model/go; version v0.2.0 --
6363
https://github.com/prometheus/client_model
6464

65-
** github.com/prometheus/common; version v0.26.0 --
65+
** github.com/prometheus/common; version v0.28.0 --
6666
https://github.com/prometheus/common
6767

6868
** github.com/prometheus/procfs; version v0.6.0 --
@@ -77,31 +77,28 @@ https://gopkg.in/ini.v1
7777
** gopkg.in/yaml.v2; version v2.4.0 --
7878
https://gopkg.in/yaml.v2
7979

80-
** k8s.io/api; version v0.22.2 --
80+
** k8s.io/api; version v0.23.0 --
8181
https://github.com/kubernetes/api
8282

83-
** k8s.io/apiextensions-apiserver/pkg/apis/apiextensions; version v0.22.2 --
83+
** k8s.io/apiextensions-apiserver/pkg/apis/apiextensions; version v0.23.0 --
8484
https://github.com/kubernetes/apiextensions-apiserver
8585

86-
** k8s.io/apimachinery/pkg; version v0.22.2 --
86+
** k8s.io/apimachinery/pkg; version v0.23.0 --
8787
https://github.com/kubernetes/apimachinery
8888

89-
** k8s.io/client-go; version v0.22.2 --
89+
** k8s.io/client-go; version v0.23.0 --
9090
https://github.com/kubernetes/client-go
9191

9292
** k8s.io/cluster-bootstrap/token; version v0.22.2 --
9393
https://github.com/kubernetes/cluster-bootstrap
9494

95-
** k8s.io/component-base; version v0.22.2 --
95+
** k8s.io/component-base; version v0.23.0 --
9696
https://github.com/kubernetes/component-base
9797

98-
** k8s.io/klog; version v1.0.0 --
98+
** k8s.io/klog/v2; version v2.30.0 --
9999
https://github.com/kubernetes/klog
100100

101-
** k8s.io/klog/v2; version v2.9.0 --
102-
https://github.com/kubernetes/klog
103-
104-
** k8s.io/kube-openapi/pkg/util/proto; version v0.0.0-20210421082810-95288971da7e --
101+
** k8s.io/kube-openapi/pkg; version v0.0.0-20211115234752-e816edb12b65 --
105102
https://github.com/kubernetes/kube-openapi
106103

107104
** k8s.io/utils; version v0.0.0-20210930125809-cb0fa318a74b --
@@ -113,10 +110,13 @@ https://github.com/kubernetes-sigs/cluster-api
113110
** sigs.k8s.io/cluster-api; version v1.0.0 --
114111
https://github.com/kubernetes-sigs/cluster-api
115112

116-
** sigs.k8s.io/controller-runtime; version v0.10.2 --
113+
** sigs.k8s.io/controller-runtime; version v0.11.1 --
117114
https://github.com/kubernetes-sigs/controller-runtime
118115

119-
** sigs.k8s.io/structured-merge-diff/v4; version v4.1.2 --
116+
** sigs.k8s.io/json; version v0.0.0-20211020170558-c049b76a60c6 --
117+
https://github.com/kubernetes-sigs/json
118+
119+
** sigs.k8s.io/structured-merge-diff/v4; version v4.2.0 --
120120
https://github.com/kubernetes-sigs/structured-merge-diff
121121

122122

@@ -425,7 +425,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
425425

426426
------
427427

428-
** github.com/evanphx/json-patch; version v4.11.0+incompatible --
428+
** github.com/evanphx/json-patch; version v4.12.0+incompatible --
429429
https://github.com/evanphx/json-patch
430430

431431
Copyright (c) 2014, Evan Phoenix
@@ -665,7 +665,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
665665

666666
------
667667

668-
** github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg; version v0.26.0 --
668+
** github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg; version v0.28.0 --
669669
https://github.com/prometheus/common
670670

671671
Copyright (c) 2011, Open Knowledge Foundation Ltd.
@@ -738,31 +738,31 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
738738
** golang.org/go; version go1.16 --
739739
https://github.com/golang/go
740740

741-
** golang.org/x/crypto/pkcs12; version v0.0.0-20210817164053-32db794688a5 --
741+
** golang.org/x/crypto/pkcs12; version v0.0.0-20210921155107-089bfa567519 --
742742
https://go.googlesource.com/crypto
743743

744-
** golang.org/x/net; version v0.0.0-20210520170846-37e1c6afe023 --
744+
** golang.org/x/net; version v0.0.0-20220225172249-27dd8689420f --
745745
https://go.googlesource.com/net
746746

747747
** golang.org/x/oauth2; version v0.0.0-20210819190943-2bc19b11175f --
748748
https://go.googlesource.com/oauth2
749749

750-
** golang.org/x/sys; version v0.0.0-20210823070655-63515b42dcdf --
750+
** golang.org/x/sys; version v0.0.0-20220319134239-a9b59b0215f8 --
751751
https://go.googlesource.com/sys
752752

753-
** golang.org/x/term; version v0.0.0-20210220032956-6a3ed077a48d --
753+
** golang.org/x/term; version v0.0.0-20210927222741-03fcf44c2211 --
754754
https://go.googlesource.com/term
755755

756-
** golang.org/x/text; version v0.3.6 --
756+
** golang.org/x/text; version v0.3.7 --
757757
https://go.googlesource.com/text
758758

759759
** golang.org/x/time/rate; version v0.0.0-20210723032227-1f47c861a9ac --
760760
https://go.googlesource.com/time
761761

762-
** k8s.io/apimachinery/third_party/forked/golang; version v0.22.2 --
762+
** k8s.io/apimachinery/third_party/forked/golang; version v0.23.0 --
763763
https://github.com/kubernetes/apimachinery
764764

765-
** k8s.io/client-go/third_party/forked/golang/template; version v0.22.2 --
765+
** k8s.io/client-go/third_party/forked/golang/template; version v0.23.0 --
766766
https://github.com/kubernetes/client-go
767767

768768
Copyright (c) 2009 The Go Authors. All rights reserved.
@@ -862,6 +862,39 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
862862

863863
------
864864

865+
** k8s.io/utils/internal/third_party/forked/golang/net; version v0.0.0-20210930125809-cb0fa318a74b --
866+
https://github.com/kubernetes/utils
867+
868+
Copyright (c) 2012 The Go Authors. All rights reserved.
869+
870+
Redistribution and use in source and binary forms, with or without
871+
modification, are permitted provided that the following conditions are
872+
met:
873+
874+
* Redistributions of source code must retain the above copyright
875+
notice, this list of conditions and the following disclaimer.
876+
* Redistributions in binary form must reproduce the above
877+
copyright notice, this list of conditions and the following disclaimer
878+
in the documentation and/or other materials provided with the
879+
distribution.
880+
* Neither the name of Google Inc. nor the names of its
881+
contributors may be used to endorse or promote products derived from
882+
this software without specific prior written permission.
883+
884+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
885+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
886+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
887+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
888+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
889+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
890+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
891+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
892+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
893+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
894+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
895+
896+
------
897+
865898
** github.com/davecgh/go-spew/spew; version v1.1.1 --
866899
https://github.com/davecgh/go-spew
867900

@@ -903,11 +936,11 @@ Copyright (c) 2012 Dave Grijalva
903936
https://github.com/gobuffalo/flect
904937
Copyright (c) 2019 Mark Bates
905938

906-
** github.com/json-iterator/go; version v1.1.11 --
939+
** github.com/json-iterator/go; version v1.1.12 --
907940
https://github.com/json-iterator/go
908941
Copyright (c) 2016 json-iterator
909942

910-
** github.com/onsi/gomega; version v1.17.0 --
943+
** github.com/onsi/gomega; version v1.19.0 --
911944
https://github.com/onsi/gomega
912945
Copyright (c) 2013-2014 Onsi Fakhouri
913946

Makefile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,11 @@ vet: ## Run go vet on the whole project.
114114
go vet ./...
115115

116116
.PHONY: lint
117-
lint: bin/golangci-lint generate-mocks ## Run linting for the project.
117+
lint: bin/golangci-lint bin/staticcheck generate-mocks ## Run linting for the project.
118118
go fmt ./...
119119
go vet ./...
120120
golangci-lint run -v --timeout 360s ./...
121+
staticcheck ./...
121122
@ # The below string of commands checks that ginkgo isn't present in the controllers.
122123
@(grep ginkgo ${PROJECT_DIR}/controllers/cloudstack*_controller.go && \
123124
echo "Remove ginkgo from controllers. This is probably an artifact of testing." \
@@ -137,13 +138,20 @@ undeploy: bin/kustomize ## Undeploy controller from the K8s cluster specified in
137138
##@ Binaries
138139

139140
.PHONY: binaries
140-
binaries: bin/controller-gen bin/kustomize bin/ginkgo bin/golangci-lint bin/mockgen bin/kubectl ## Locally install all needed bins.
141+
binaries: bin/controller-gen bin/kustomize bin/ginkgo bin/golangci-lint bin/staticcheck bin/mockgen bin/kubectl ## Locally install all needed bins.
141142
bin/controller-gen: ## Install controller-gen to bin.
142143
GOBIN=$(PROJECT_DIR)/bin go install sigs.k8s.io/controller-tools/cmd/[email protected]
143144
bin/golangci-lint: ## Install golangci-lint to bin.
144-
GOBIN=$(PROJECT_DIR)/bin go install github.com/golangci/golangci-lint/cmd/[email protected]
145-
bin/ginkgo: ## Install ginkgo to bin.
145+
GOBIN=$(PROJECT_DIR)/bin go install github.com/golangci/golangci-lint/cmd/[email protected]
146+
bin/staticcheck: ## Install staticcheck to bin.
147+
GOBIN=$(PROJECT_DIR)/bin go install honnef.co/go/tools/cmd/[email protected]
148+
bin/ginkgo: bin/ginkgo_v1 bin/ginkgo_v2 ## Install ginkgo to bin.
149+
bin/ginkgo_v2:
150+
GOBIN=$(PROJECT_DIR)/bin go install github.com/onsi/ginkgo/v2/[email protected]
151+
mv $(PROJECT_DIR)/bin/ginkgo $(PROJECT_DIR)/bin/ginkgo_v2
152+
bin/ginkgo_v1:
146153
GOBIN=$(PROJECT_DIR)/bin go install github.com/onsi/ginkgo/[email protected]
154+
mv $(PROJECT_DIR)/bin/ginkgo $(PROJECT_DIR)/bin/ginkgo_v1
147155
bin/mockgen:
148156
GOBIN=$(PROJECT_DIR)/bin go install github.com/golang/mock/[email protected]
149157
bin/kustomize: ## Install kustomize to bin.
@@ -171,7 +179,7 @@ export KUBEBUILDER_ASSETS=$(PROJECT_DIR)/bin
171179
test: generate-mocks lint bin/ginkgo bin/kubectl bin/kube-apiserver bin/etcd ## Run tests. At the moment this is only unit tests.
172180
@./hack/testing_ginkgo_recover_statements.sh --add # Add ginkgo.GinkgoRecover() statements to controllers.
173181
@# The following is a slightly funky way to make sure the ginkgo statements are removed regardless the test results.
174-
@cd ./test/unit && ginkgo -v ./... -coverprofile cover.out; EXIT_STATUS=$$?;\
182+
@cd ./test/unit && ginkgo_v2 -v ./... -coverprofile cover.out; EXIT_STATUS=$$?;\
175183
cd ../../ && ./hack/testing_ginkgo_recover_statements.sh --remove; exit $$EXIT_STATUS
176184

177185
.PHONY: generate-mocks
@@ -204,13 +212,13 @@ e2e-cluster-templates: $(CLUSTER_TEMPLATES_OUTPUT_FILES) ## Generate cluster tem
204212
cluster-template%yaml: bin/kustomize $(CLUSTER_TEMPLATES_INPUT_FILES)
205213
kustomize build --load-restrictor LoadRestrictionsNone $(basename $@) > $@
206214

207-
e2e-essentials: bin/ginkgo e2e-cluster-templates kind-cluster ## Fulfill essential tasks for e2e testing.
215+
e2e-essentials: bin/ginkgo_v1 e2e-cluster-templates kind-cluster ## Fulfill essential tasks for e2e testing.
208216
IMG=$(IMG_LOCAL) make manifests docker-build docker-push
209217

210218
JOB ?= .*
211219
run-e2e: e2e-essentials ## Run e2e testing. JOB is an optional REGEXP to select certainn test cases to run. e.g. JOB=PR-Blocking, JOB=Conformance
212220
cd test/e2e && \
213-
ginkgo -v -trace -tags=e2e -focus=$(JOB) -skip=Conformance -nodes=1 --noColor=false ./... -- \
221+
ginkgo_v1 -v -trace -tags=e2e -focus=$(JOB) -skip=Conformance -nodes=1 -noColor=false ./... -- \
214222
-e2e.artifacts-folder=${PROJECT_DIR}/_artifacts \
215223
-e2e.config=${PROJECT_DIR}/test/e2e/config/cloudstack.yaml \
216224
-e2e.skip-resource-cleanup=false -e2e.use-existing-cluster=true

api/v1beta1/cloudstackmachine_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ type CloudStackResourceIdentifier struct {
101101

102102
type CloudStackResourceDiskOffering struct {
103103
CloudStackResourceIdentifier `json:",inline"`
104+
// Desired disk size. Used if disk offering is customizable as indicated by the ACS field 'Custom Disk Size'.
105+
// +optional
106+
CustomSize int64 `json:"customSizeInGB"`
104107
// mount point the data disk uses to mount. The actual partition, mkfs and mount are done by cloud-init generated by kubeadmConfig.
105108
MountPath string `json:"mountPath"`
106109
// device name of data disk, for example /dev/vdb

api/v1beta1/cloudstackmachine_webhook.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ func (r *CloudStackMachine) ValidateCreate() error {
6565

6666
errorList = webhookutil.EnsureAtLeastOneFieldExists(r.Spec.Offering.ID, r.Spec.Offering.Name, "Offering", errorList)
6767
errorList = webhookutil.EnsureAtLeastOneFieldExists(r.Spec.Template.ID, r.Spec.Template.Name, "Template", errorList)
68+
if len(r.Spec.DiskOffering.ID) > 0 || len(r.Spec.DiskOffering.Name) > 0 {
69+
errorList = webhookutil.EnsureIntFieldsAreNotNegative(r.Spec.DiskOffering.CustomSize, "customSizeInGB", errorList)
70+
}
6871

6972
return webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
7073
}
@@ -83,6 +86,7 @@ func (r *CloudStackMachine) ValidateUpdate(old runtime.Object) error {
8386

8487
errorList = webhookutil.EnsureBothFieldsAreEqual(r.Spec.Offering.ID, r.Spec.Offering.Name, oldSpec.Offering.ID, oldSpec.Offering.Name, "offering", errorList)
8588
errorList = webhookutil.EnsureBothFieldsAreEqual(r.Spec.DiskOffering.ID, r.Spec.DiskOffering.Name, oldSpec.DiskOffering.ID, oldSpec.DiskOffering.Name, "diskOffering", errorList)
89+
errorList = webhookutil.EnsureIntFieldsAreNotNegative(r.Spec.DiskOffering.CustomSize, "customSizeInGB", errorList)
8690
errorList = webhookutil.EnsureStringFieldsAreEqual(r.Spec.DiskOffering.MountPath, oldSpec.DiskOffering.MountPath, "mountPath", errorList)
8791
errorList = webhookutil.EnsureStringFieldsAreEqual(r.Spec.DiskOffering.Device, oldSpec.DiskOffering.Device, "device", errorList)
8892
errorList = webhookutil.EnsureStringFieldsAreEqual(r.Spec.DiskOffering.Filesystem, oldSpec.DiskOffering.Filesystem, "filesystem", errorList)

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackmachines.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ spec:
116116
diskOffering:
117117
description: CloudStack disk offering to use.
118118
properties:
119+
customSizeInGB:
120+
description: disk size if disk offering is custom disk (need to
121+
specify disk size by users)
122+
format: int64
123+
type: integer
119124
device:
120125
description: device name of data disk, for example /dev/vdb
121126
type: string

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackmachinestatecheckers.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ spec:
3535
metadata:
3636
type: object
3737
spec:
38-
description: CloudStackMachineStateCheckerSpec defines the desired state
39-
of CloudStackMachineStateChecker
38+
description: CloudStackMachineStateCheckerSpec
4039
properties:
4140
instanceID:
4241
description: CloudStack machine instance ID

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackmachinetemplates.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ spec:
103103
diskOffering:
104104
description: CloudStack disk offering to use.
105105
properties:
106+
customSizeInGB:
107+
description: disk size if disk offering is custom disk
108+
(need to specify disk size by users)
109+
format: int64
110+
type: integer
106111
device:
107112
description: device name of data disk, for example /dev/vdb
108113
type: string

controllers/cloudstackaffinitygroup_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (reconciler *CloudStackAffinityGroupReconciler) Reconcile(ctx context.Conte
6363

6464
func (r *CloudStackAGReconciliationRunner) Reconcile() (ctrl.Result, error) {
6565
controllerutil.AddFinalizer(r.ReconciliationSubject, infrav1.AffinityGroupFinalizer)
66-
affinityGroup := &cloud.AffinityGroup{Name: r.ReconciliationSubject.Spec.Name, Type: "host affinity"}
66+
affinityGroup := &cloud.AffinityGroup{Name: r.ReconciliationSubject.Spec.Name, Type: r.ReconciliationSubject.Spec.Type}
6767
if err := r.CSUser.GetOrCreateAffinityGroup(affinityGroup); err != nil {
6868
return ctrl.Result{}, err
6969
}

0 commit comments

Comments
 (0)