From fc9081ede1793899dba0d4d86ccc18f2c5226352 Mon Sep 17 00:00:00 2001 From: Aleksandr Zimin Date: Tue, 27 Feb 2024 10:52:51 +0300 Subject: [PATCH] Prepare code for production release Signed-off-by: Aleksandr Zimin --- images/sds-lvm-controller/Makefile | 41 ------------------- images/sds-lvm-csi/driver/controller.go | 4 +- .../cmd/cmd/access_log.go | 16 ++++++++ .../cmd/cmd/access_log_test.go | 16 ++++++++ .../cmd/cmd/root.go | 27 +++++++++--- images/sds-lvm-scheduler-extender/cmd/main.go | 16 ++++++++ .../pkg/scheduler/api.go | 16 ++++++++ .../pkg/scheduler/filter.go | 16 ++++++++ .../pkg/scheduler/filter_test.go | 16 ++++++++ .../pkg/scheduler/prioritize.go | 16 ++++++++ .../pkg/scheduler/prioritize_test.go | 16 ++++++++ .../pkg/scheduler/route.go | 16 ++++++++ .../pkg/scheduler/route_test.go | 16 ++++++++ .../src/validators/podSchedulerMutation.go | 17 ++++++++ 14 files changed, 201 insertions(+), 48 deletions(-) delete mode 100644 images/sds-lvm-controller/Makefile diff --git a/images/sds-lvm-controller/Makefile b/images/sds-lvm-controller/Makefile deleted file mode 100644 index 492f3644..00000000 --- a/images/sds-lvm-controller/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -SHELL := /bin/bash -TEST-ARGS=-race -timeout 30s -count 1 -base_golang_20_alpine := golang:1.20-alpine3.18 -repo_fox := registry.flant.com/deckhouse/storage -image_name := sds-lvm - - -deployment_name=sds-lvm-controller -deployment_container_name=sds-lvm-controller -namespace=d8-sds-lvm -system_namespace=d8-system -pull_secret_name=fox-registry - -USER := $(shell whoami) -image_tag := sds-lvm-controller-$(USER) - -run: ## run go - go run -race ./cmd/main.go - -test: - go test $(TEST-ARGS) ./... - -fox_build_and_push: - docker build --build-arg="BASE_GOLANG_20_ALPINE_BUILDER=$(base_golang_20_alpine)" . -t $(repo_fox)/$(image_name):$(image_tag) - docker push $(repo_fox)/$(image_name):$(image_tag) - -redeploy: - kubectl -n $(namespace) rollout restart deployment $(deployment_name) - kubectl -n $(namespace) rollout restart daemonset $(daemonset_name) - -switch_to_local_dev: - kubectl -n $(system_namespace) scale deployment deckhouse --replicas=0 - kubectl -n $(namespace) patch deployment $(deployment_name) -p \ - '{"spec": {"template": {"spec": {"containers": [{"name": "$(deployment_container_name)", "image": "$(repo_fox)/$(image_name):$(image_tag)"}]}}}}' - kubectl -n $(namespace) patch deployment $(deployment_name) -p \ - '{"spec": {"template": {"spec": {"containers": [{"name": "$(deployment_container_name)", "imagePullPolicy": "Always"}]}}}}' - kubectl -n $(namespace) patch deployment $(deployment_name) --type='json' \ - -p='[{"op": "add", "path": "/spec/template/spec/imagePullSecrets", "value": [{"name": "$(pull_secret_name)"}]}]' - - -.PHONY: switch_to_local_dev diff --git a/images/sds-lvm-csi/driver/controller.go b/images/sds-lvm-csi/driver/controller.go index a3fd7fea..1d91c699 100644 --- a/images/sds-lvm-csi/driver/controller.go +++ b/images/sds-lvm-csi/driver/controller.go @@ -125,7 +125,7 @@ func (d *Driver) CreateVolume(ctx context.Context, request *csi.CreateVolumeRequ d.log.Error(err, "error WaitForStatusUpdate") return nil, err } - d.log.Trace(fmt.Sprintf("stop waiting CreateLVMLogicalVolume, attempt сounter = %d ", attemptCounter)) + d.log.Trace(fmt.Sprintf("stop waiting CreateLVMLogicalVolume, attempt counter = %d ", attemptCounter)) volumeCtx := make(map[string]string, len(request.Parameters)) for k, v := range request.Parameters { @@ -309,7 +309,7 @@ func (d *Driver) ControllerExpandVolume(ctx context.Context, request *csi.Contro d.log.Error(err, "error WaitForStatusUpdate") return nil, err } - d.log.Info(fmt.Sprintf("finish resize LVMLogicalVolume, attempt сounter = %d ", attemptCounter)) + d.log.Info(fmt.Sprintf("finish resize LVMLogicalVolume, attempt counter = %d ", attemptCounter)) return &csi.ControllerExpandVolumeResponse{ CapacityBytes: request.CapacityRange.RequiredBytes, diff --git a/images/sds-lvm-scheduler-extender/cmd/cmd/access_log.go b/images/sds-lvm-scheduler-extender/cmd/cmd/access_log.go index e1902e75..061f721b 100644 --- a/images/sds-lvm-scheduler-extender/cmd/cmd/access_log.go +++ b/images/sds-lvm-scheduler-extender/cmd/cmd/access_log.go @@ -1,3 +1,19 @@ +/* +Copyright 2024 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package cmd import ( diff --git a/images/sds-lvm-scheduler-extender/cmd/cmd/access_log_test.go b/images/sds-lvm-scheduler-extender/cmd/cmd/access_log_test.go index 7801df03..b19b40b8 100644 --- a/images/sds-lvm-scheduler-extender/cmd/cmd/access_log_test.go +++ b/images/sds-lvm-scheduler-extender/cmd/cmd/access_log_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2024 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package cmd import ( diff --git a/images/sds-lvm-scheduler-extender/cmd/cmd/root.go b/images/sds-lvm-scheduler-extender/cmd/cmd/root.go index 80265eb9..dd5efd35 100644 --- a/images/sds-lvm-scheduler-extender/cmd/cmd/root.go +++ b/images/sds-lvm-scheduler-extender/cmd/cmd/root.go @@ -1,12 +1,25 @@ +/* +Copyright 2024 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package cmd import ( "context" "errors" "fmt" - v1 "k8s.io/api/core/v1" - sv1 "k8s.io/api/storage/v1" - "k8s.io/apimachinery/pkg/runtime" "net/http" "os" "os/signal" @@ -14,12 +27,16 @@ import ( "sds-lvm-scheduler-extender/pkg/kubutils" "sds-lvm-scheduler-extender/pkg/logger" "sds-lvm-scheduler-extender/pkg/scheduler" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" "sync" "syscall" "time" + v1 "k8s.io/api/core/v1" + sv1 "k8s.io/api/storage/v1" + "k8s.io/apimachinery/pkg/runtime" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/spf13/cobra" apiruntime "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/yaml" diff --git a/images/sds-lvm-scheduler-extender/cmd/main.go b/images/sds-lvm-scheduler-extender/cmd/main.go index 030baa14..8a3b0cac 100644 --- a/images/sds-lvm-scheduler-extender/cmd/main.go +++ b/images/sds-lvm-scheduler-extender/cmd/main.go @@ -1,3 +1,19 @@ +/* +Copyright 2024 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package main import "sds-lvm-scheduler-extender/cmd/cmd" diff --git a/images/sds-lvm-scheduler-extender/pkg/scheduler/api.go b/images/sds-lvm-scheduler-extender/pkg/scheduler/api.go index 8cb6e128..bd4dea1d 100644 --- a/images/sds-lvm-scheduler-extender/pkg/scheduler/api.go +++ b/images/sds-lvm-scheduler-extender/pkg/scheduler/api.go @@ -1,3 +1,19 @@ +/* +Copyright 2024 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package scheduler import ( diff --git a/images/sds-lvm-scheduler-extender/pkg/scheduler/filter.go b/images/sds-lvm-scheduler-extender/pkg/scheduler/filter.go index 6768828e..b8811529 100644 --- a/images/sds-lvm-scheduler-extender/pkg/scheduler/filter.go +++ b/images/sds-lvm-scheduler-extender/pkg/scheduler/filter.go @@ -1,3 +1,19 @@ +/* +Copyright 2024 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package scheduler import ( diff --git a/images/sds-lvm-scheduler-extender/pkg/scheduler/filter_test.go b/images/sds-lvm-scheduler-extender/pkg/scheduler/filter_test.go index 81bd9363..e9608c7f 100644 --- a/images/sds-lvm-scheduler-extender/pkg/scheduler/filter_test.go +++ b/images/sds-lvm-scheduler-extender/pkg/scheduler/filter_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2024 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package scheduler import ( diff --git a/images/sds-lvm-scheduler-extender/pkg/scheduler/prioritize.go b/images/sds-lvm-scheduler-extender/pkg/scheduler/prioritize.go index c56fa9fc..031e07a8 100644 --- a/images/sds-lvm-scheduler-extender/pkg/scheduler/prioritize.go +++ b/images/sds-lvm-scheduler-extender/pkg/scheduler/prioritize.go @@ -1,3 +1,19 @@ +/* +Copyright 2024 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package scheduler import ( diff --git a/images/sds-lvm-scheduler-extender/pkg/scheduler/prioritize_test.go b/images/sds-lvm-scheduler-extender/pkg/scheduler/prioritize_test.go index d3eabd32..9bc89339 100644 --- a/images/sds-lvm-scheduler-extender/pkg/scheduler/prioritize_test.go +++ b/images/sds-lvm-scheduler-extender/pkg/scheduler/prioritize_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2024 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package scheduler import ( diff --git a/images/sds-lvm-scheduler-extender/pkg/scheduler/route.go b/images/sds-lvm-scheduler-extender/pkg/scheduler/route.go index c6cd38bf..11494907 100644 --- a/images/sds-lvm-scheduler-extender/pkg/scheduler/route.go +++ b/images/sds-lvm-scheduler-extender/pkg/scheduler/route.go @@ -1,3 +1,19 @@ +/* +Copyright 2024 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package scheduler import ( diff --git a/images/sds-lvm-scheduler-extender/pkg/scheduler/route_test.go b/images/sds-lvm-scheduler-extender/pkg/scheduler/route_test.go index 53bcc801..7a15c47e 100644 --- a/images/sds-lvm-scheduler-extender/pkg/scheduler/route_test.go +++ b/images/sds-lvm-scheduler-extender/pkg/scheduler/route_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2024 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package scheduler import ( diff --git a/images/webhooks/src/validators/podSchedulerMutation.go b/images/webhooks/src/validators/podSchedulerMutation.go index 60216f12..ed34fafe 100644 --- a/images/webhooks/src/validators/podSchedulerMutation.go +++ b/images/webhooks/src/validators/podSchedulerMutation.go @@ -1,7 +1,24 @@ +/* +Copyright 2024 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package validators import ( "context" + "github.com/slok/kubewebhook/v2/pkg/model" kwhmutating "github.com/slok/kubewebhook/v2/pkg/webhook/mutating" corev1 "k8s.io/api/core/v1"