diff --git a/crds/lvmlogicalvolume.yaml b/crds/lvmlogicalvolume.yaml index afe5019e..53446721 100644 --- a/crds/lvmlogicalvolume.yaml +++ b/crds/lvmlogicalvolume.yaml @@ -45,6 +45,8 @@ spec: x-kubernetes-validations: - rule: self == oldSelf message: Value is immutable. + minLength: 1 + pattern: '^[a-z0-9]([a-z0-9-.]{0,251}[a-z0-9])?$' type: type: string x-kubernetes-validations: diff --git a/images/agent/Dockerfile b/images/agent/Dockerfile index 164441b5..bf5ac7ec 100644 --- a/images/agent/Dockerfile +++ b/images/agent/Dockerfile @@ -1,4 +1,4 @@ -ARG GOLANG_20_ALPINE_BUILDER=registry.deckhouse.io/base_images/golang:1.20.5-alpine3.18@sha256:51a47fb0851397db2f506c15c426735bc23de31177cbdd962880c0879d1906a4 +ARG GOLANG_ALPINE_BUILDER=registry.deckhouse.io/base_images/golang:1.22.1-alpine@sha256:0de6cf7cceab6ecbf0718bdfb675b08b78113c3709c5e4b99456cdb2ae8c2495 ARG UBUNTU_UTILS_BUILDER=registry.deckhouse.io/base_images/ubuntu:jammy-20221130@sha256:c14c3b1242536729ce5227ff833144977b4e378723858fb73a4cf40ea6daaf6a ARG BASE_IMAGE=registry.deckhouse.io/base_images/scratch@sha256:b054705fcc9f2205777d80a558d920c0b4209efdc3163c22b5bfcb5dda1db5fc @@ -38,7 +38,7 @@ RUN ./configure --prefix /opt/deckhouse/sds --with-udev && \ ################################# -FROM $GOLANG_20_ALPINE_BUILDER as agent-builder +FROM $GOLANG_ALPINE_BUILDER as agent-builder WORKDIR /go/src ADD go.mod . diff --git a/images/agent/api/v1alpha1/block_device.go b/images/agent/api/v1alpha1/block_device.go index 5d332d8e..c6ddb4b4 100644 --- a/images/agent/api/v1alpha1/block_device.go +++ b/images/agent/api/v1alpha1/block_device.go @@ -17,7 +17,6 @@ limitations under the License. package v1alpha1 import ( - "k8s.io/api/policy/v1beta1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -39,7 +38,7 @@ type BlockDeviceList struct { type BlockDeviceStatus struct { Type string `json:"type"` - FsType v1beta1.FSType `json:"fsType"` + FsType string `json:"fsType"` NodeName string `json:"nodeName"` Consumable bool `json:"consumable"` PVUuid string `json:"pvUUID"` diff --git a/images/agent/config/config.go b/images/agent/config/config.go index ccf4d7ff..1b61cebe 100644 --- a/images/agent/config/config.go +++ b/images/agent/config/config.go @@ -41,6 +41,7 @@ type Options struct { MetricsPort string BlockDeviceScanInterval time.Duration VolumeGroupScanInterval time.Duration + LLVRequeInterval time.Duration } func NewConfig() (*Options, error) { @@ -71,6 +72,7 @@ func NewConfig() (*Options, error) { opts.BlockDeviceScanInterval = 5 opts.VolumeGroupScanInterval = 5 + opts.LLVRequeInterval = 5 return &opts, nil } diff --git a/images/agent/go.mod b/images/agent/go.mod index f37d2e95..810e3b6b 100644 --- a/images/agent/go.mod +++ b/images/agent/go.mod @@ -1,21 +1,21 @@ module sds-node-configurator -go 1.20 +go 1.22.1 require ( - github.com/go-logr/logr v1.3.0 + github.com/go-logr/logr v1.4.1 github.com/google/go-cmp v0.6.0 - github.com/onsi/ginkgo/v2 v2.11.0 - github.com/onsi/gomega v1.27.10 - github.com/prometheus/client_golang v1.17.0 + github.com/onsi/ginkgo/v2 v2.14.0 + github.com/onsi/gomega v1.30.0 + github.com/prometheus/client_golang v1.18.0 github.com/stretchr/testify v1.8.4 - k8s.io/api v0.28.4 - k8s.io/apiextensions-apiserver v0.28.4 - k8s.io/apimachinery v0.28.4 - k8s.io/client-go v0.28.4 + k8s.io/api v0.29.4 + k8s.io/apiextensions-apiserver v0.29.4 + k8s.io/apimachinery v0.29.4 + k8s.io/client-go v0.29.4 k8s.io/klog/v2 v2.110.1 k8s.io/utils v0.0.0-20231127182322-b307cd553661 - sigs.k8s.io/controller-runtime v0.16.3 + sigs.k8s.io/controller-runtime v0.17.3 ) require ( @@ -24,7 +24,7 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect - github.com/evanphx/json-patch/v5 v5.7.0 // indirect + github.com/evanphx/json-patch/v5 v5.8.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-openapi/jsonpointer v0.20.0 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect @@ -32,7 +32,7 @@ require ( github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect @@ -52,20 +52,20 @@ require ( github.com/prometheus/procfs v0.12.0 // indirect github.com/spf13/pflag v1.0.5 // indirect golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect - golang.org/x/net v0.19.0 // indirect + golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.15.0 // indirect - golang.org/x/sys v0.15.0 // indirect - golang.org/x/term v0.15.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.16.0 // indirect + golang.org/x/tools v0.16.1 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/component-base v0.28.4 // indirect + k8s.io/component-base v0.29.4 // indirect k8s.io/kube-openapi v0.0.0-20231129212854-f0671cc7e66a // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect diff --git a/images/agent/go.sum b/images/agent/go.sum index 922b8639..03407c29 100644 --- a/images/agent/go.sum +++ b/images/agent/go.sum @@ -13,13 +13,15 @@ github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxER github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch/v5 v5.7.0 h1:nJqP7uwL84RJInrohHfW0Fx3awjbm8qZeFv0nW9SYGc= -github.com/evanphx/json-patch/v5 v5.7.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= +github.com/evanphx/json-patch/v5 v5.8.0 h1:lRj6N9Nci7MvzrXuX6HFzU8XjmhPiXPlsKEy1u0KQro= +github.com/evanphx/json-patch/v5 v5.8.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/zapr v1.2.4 h1:QHVo+6stLbfJmYGkQ7uGHUCu5hnAFAj6mDe6Ea0SeOo= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= +github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonpointer v0.20.0 h1:ESKJdU9ASRfaPNOPRx12IUyA1vn3R9GiE3KYD14BXdQ= github.com/go-openapi/jsonpointer v0.20.0/go.mod h1:6PGzBjjIIumbLYysB73Klnms1mwnU4G3YHOECG3CedA= @@ -36,8 +38,8 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -62,6 +64,7 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -77,16 +80,16 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= -github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= +github.com/onsi/ginkgo/v2 v2.14.0 h1:vSmGj2Z5YPb9JwCWT6z6ihcUvDhuXLc3sJiqd3jMKAY= +github.com/onsi/ginkgo/v2 v2.14.0/go.mod h1:JkUdW7JkN0V6rFvsHcJ478egV3XH9NxpD27Hal/PhZw= +github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= +github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= -github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= +github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= +github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= @@ -94,6 +97,7 @@ github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGy github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -109,9 +113,12 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -121,15 +128,14 @@ golang.org/x/exp v0.0.0-20231127185646-65229373498e/go.mod h1:iRJReGqOEeBhDZGkGb golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ= golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -144,12 +150,12 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= -golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -163,8 +169,8 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM= -golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= +golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -175,8 +181,8 @@ google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAs google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= @@ -188,24 +194,24 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.28.4 h1:8ZBrLjwosLl/NYgv1P7EQLqoO8MGQApnbgH8tu3BMzY= -k8s.io/api v0.28.4/go.mod h1:axWTGrY88s/5YE+JSt4uUi6NMM+gur1en2REMR7IRj0= -k8s.io/apiextensions-apiserver v0.28.4 h1:AZpKY/7wQ8n+ZYDtNHbAJBb+N4AXXJvyZx6ww6yAJvU= -k8s.io/apiextensions-apiserver v0.28.4/go.mod h1:pgQIZ1U8eJSMQcENew/0ShUTlePcSGFq6dxSxf2mwPM= -k8s.io/apimachinery v0.28.4 h1:zOSJe1mc+GxuMnFzD4Z/U1wst50X28ZNsn5bhgIIao8= -k8s.io/apimachinery v0.28.4/go.mod h1:wI37ncBvfAoswfq626yPTe6Bz1c22L7uaJ8dho83mgg= -k8s.io/client-go v0.28.4 h1:Np5ocjlZcTrkyRJ3+T3PkXDpe4UpatQxj85+xjaD2wY= -k8s.io/client-go v0.28.4/go.mod h1:0VDZFpgoZfelyP5Wqu0/r/TRYcLYuJ2U1KEeoaPa1N4= -k8s.io/component-base v0.28.4 h1:c/iQLWPdUgI90O+T9TeECg8o7N3YJTiuz2sKxILYcYo= -k8s.io/component-base v0.28.4/go.mod h1:m9hR0uvqXDybiGL2nf/3Lf0MerAfQXzkfWhUY58JUbU= +k8s.io/api v0.29.4 h1:WEnF/XdxuCxdG3ayHNRR8yH3cI1B/llkWBma6bq4R3w= +k8s.io/api v0.29.4/go.mod h1:DetSv0t4FBTcEpfA84NJV3g9a7+rSzlUHk5ADAYHUv0= +k8s.io/apiextensions-apiserver v0.29.4 h1:M7hbuHU/ckbibR7yPbe6DyNWgTFKNmZDbdZKD8q1Smk= +k8s.io/apiextensions-apiserver v0.29.4/go.mod h1:TTDC9fB+0kHY2rogf5hgBR03KBKCwED+GHUsXGpR7SM= +k8s.io/apimachinery v0.29.4 h1:RaFdJiDmuKs/8cm1M6Dh1Kvyh59YQFDcFuFTSmXes6Q= +k8s.io/apimachinery v0.29.4/go.mod h1:i3FJVwhvSp/6n8Fl4K97PJEP8C+MM+aoDq4+ZJBf70Y= +k8s.io/client-go v0.29.4 h1:79ytIedxVfyXV8rpH3jCBW0u+un0fxHDwX5F9K8dPR8= +k8s.io/client-go v0.29.4/go.mod h1:kC1thZQ4zQWYwldsfI088BbK6RkxK+aF5ebV8y9Q4tk= +k8s.io/component-base v0.29.4 h1:xeKzuuHI/1tjleu5jycDAcYbhAxeGHCQBZUY2eRIkOo= +k8s.io/component-base v0.29.4/go.mod h1:pYjt+oEZP9gtmwSikwAJgfSBikqKX2gOqRat0QjmQt0= k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= k8s.io/kube-openapi v0.0.0-20231129212854-f0671cc7e66a h1:ZeIPbyHHqahGIbeyLJJjAUhnxCKqXaDY+n89Ms8szyA= k8s.io/kube-openapi v0.0.0-20231129212854-f0671cc7e66a/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= k8s.io/utils v0.0.0-20231127182322-b307cd553661 h1:FepOBzJ0GXm8t0su67ln2wAZjbQ6RxQGZDnzuLcrUTI= k8s.io/utils v0.0.0-20231127182322-b307cd553661/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/controller-runtime v0.16.3 h1:2TuvuokmfXvDUamSx1SuAOO3eTyye+47mJCigwG62c4= -sigs.k8s.io/controller-runtime v0.16.3/go.mod h1:j7bialYoSn142nv9sCOJmQgDXQXxnroFU4VnX/brVJ0= +sigs.k8s.io/controller-runtime v0.17.3 h1:65QmN7r3FWgTxDMz9fvGnO1kbf2nu+acg9p2R9oYYYk= +sigs.k8s.io/controller-runtime v0.17.3/go.mod h1:N0jpP5Lo7lMTF9aL56Z/B2oWBJjey6StQM0jRbKQXtY= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= diff --git a/images/agent/pkg/controller/block_device.go b/images/agent/pkg/controller/block_device.go index 420fc803..e65869fb 100644 --- a/images/agent/pkg/controller/block_device.go +++ b/images/agent/pkg/controller/block_device.go @@ -31,7 +31,6 @@ import ( "strings" "time" - "k8s.io/api/policy/v1beta1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kclient "sigs.k8s.io/controller-runtime/pkg/client" @@ -148,7 +147,7 @@ func hasBlockDeviceDiff(res v1alpha1.BlockDeviceStatus, candidate internal.Block candidate.Model != res.Model || candidate.HotPlug != res.HotPlug || candidate.Type != res.Type || - v1beta1.FSType(candidate.FSType) != res.FsType || + candidate.FSType != res.FsType || candidate.MachineId != res.MachineID } @@ -502,7 +501,7 @@ func UpdateAPIBlockDevice(ctx context.Context, kc kclient.Client, metrics monito }, Status: v1alpha1.BlockDeviceStatus{ Type: candidate.Type, - FsType: v1beta1.FSType(candidate.FSType), + FsType: candidate.FSType, NodeName: candidate.NodeName, Consumable: candidate.Consumable, PVUuid: candidate.PVUuid, @@ -546,7 +545,7 @@ func CreateAPIBlockDevice(ctx context.Context, kc kclient.Client, metrics monito }, Status: v1alpha1.BlockDeviceStatus{ Type: candidate.Type, - FsType: v1beta1.FSType(candidate.FSType), + FsType: candidate.FSType, NodeName: candidate.NodeName, Consumable: candidate.Consumable, PVUuid: candidate.PVUuid, diff --git a/images/agent/pkg/controller/controller_reconcile_test.go b/images/agent/pkg/controller/controller_reconcile_test.go index 69c0034b..d257e55a 100644 --- a/images/agent/pkg/controller/controller_reconcile_test.go +++ b/images/agent/pkg/controller/controller_reconcile_test.go @@ -18,14 +18,14 @@ package controller_test import ( "context" - "k8s.io/apimachinery/pkg/api/resource" "sds-node-configurator/internal" "sds-node-configurator/pkg/controller" "sds-node-configurator/pkg/monitoring" + "k8s.io/apimachinery/pkg/api/resource" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "k8s.io/api/policy/v1beta1" ) var _ = Describe("Storage Controller", func() { @@ -75,7 +75,7 @@ var _ = Describe("Storage Controller", func() { Expect(blockDevice.Status.Rota).To(Equal(candidate.Rota)) Expect(blockDevice.Status.Model).To(Equal(candidate.Model)) Expect(blockDevice.Status.Type).To(Equal(candidate.Type)) - Expect(blockDevice.Status.FsType).To(Equal(v1beta1.FSType(candidate.FSType))) + Expect(blockDevice.Status.FsType).To(Equal(candidate.FSType)) Expect(blockDevice.Status.MachineID).To(Equal(candidate.MachineId)) }) diff --git a/images/agent/pkg/controller/lvm_logical_volume_watcher.go b/images/agent/pkg/controller/lvm_logical_volume_watcher.go index c85ebe13..fac623e5 100644 --- a/images/agent/pkg/controller/lvm_logical_volume_watcher.go +++ b/images/agent/pkg/controller/lvm_logical_volume_watcher.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "reflect" + "strings" "sds-node-configurator/api/v1alpha1" "sds-node-configurator/config" @@ -15,7 +16,9 @@ import ( "time" "github.com/google/go-cmp/cmp" + k8serr "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" + "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/workqueue" "k8s.io/utils/strings/slices" "sigs.k8s.io/controller-runtime/pkg/client" @@ -58,9 +61,21 @@ func RunLVMLogicalVolumeWatcherController( c, err := controller.New(lvmLogicalVolumeWatcherCtrlName, mgr, controller.Options{ Reconciler: reconcile.Func(func(ctx context.Context, request reconcile.Request) (reconcile.Result, error) { - return reconcile.Result{}, nil + log.Debug(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] Reconciler starts reconciliation of LLV: %s", request.Name)) + shouldRequeue, err := ReconcileLVMLogicalVolume(ctx, cl, log, metrics, cfg, request) + if err != nil { + log.Error(err, fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] an error occurred while reconciling LLV: %s", request.Name)) + } + if shouldRequeue { + log.Info(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] requeue reconciliation of LLV: %s after %s", request.Name, cfg.LLVRequeInterval)) + return reconcile.Result{RequeueAfter: cfg.LLVRequeInterval}, nil + } + log.Debug(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] ends reconciliation of LLV: %s without requeue", request.Name)) + return reconcile.Result{Requeue: false}, nil }), + MaxConcurrentReconciles: 10, }) + if err != nil { log.Error(err, "[RunLVMLogicalVolumeWatcherController] unable to create controller") return nil, err @@ -68,38 +83,15 @@ func RunLVMLogicalVolumeWatcherController( err = c.Watch(source.Kind(cache, &v1alpha1.LVMLogicalVolume{}), handler.Funcs{ CreateFunc: func(ctx context.Context, e event.CreateEvent, q workqueue.RateLimitingInterface) { - log.Info(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] CreateFunc starts reconciliation of LLV: %s", e.Object.GetName())) - - llv, ok := e.Object.(*v1alpha1.LVMLogicalVolume) - if !ok { - err = errors.New("unable to cast event object to a given type") - log.Error(err, "[CreateFunc] an error occurred while handling create event") - return - } - - lvg, err := getLVMVolumeGroup(ctx, cl, metrics, "", llv.Spec.LvmVolumeGroupName) - if err != nil { - log.Error(err, "[CreateFunc] unable to get a LVMVolumeGroup") - err = updateLVMLogicalVolumePhase(ctx, cl, log, metrics, llv, failedStatusPhase, fmt.Sprintf("Unable to get selected LVMVolumeGroup, err: %s", err.Error())) - if err != nil { - log.Error(err, "[CreateFunc] unable to update a LVMLogicalVolume Phase") - } - return - } - - if !belongsToNode(lvg, cfg.NodeName) { - log.Debug(fmt.Sprintf("[CreateFunc] the LVMVolumeGroup %s does not belongs to the current node: %s. Reconciliation stopped", lvg.Name, cfg.NodeName)) - return - } - log.Debug(fmt.Sprintf("[CreateFunc] the LVMVolumeGroup %s belongs to the current node: %s", lvg.Name, cfg.NodeName)) + log.Debug(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] CreateFunc starts reconciliation of LLV: %s", e.Object.GetName())) + request := reconcile.Request{NamespacedName: types.NamespacedName{Namespace: e.Object.GetNamespace(), Name: e.Object.GetName()}} - runEventReconcile(ctx, cl, log, metrics, llv, lvg) - - log.Info(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] CreateFunc ends reconciliation of LLV: %s", llv.Name)) + q.Add(request) + log.Debug(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] CreateFunc ends reconciliation of LLV: %s", e.Object.GetName())) }, UpdateFunc: func(ctx context.Context, e event.UpdateEvent, q workqueue.RateLimitingInterface) { - log.Info(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] UpdateFunc starts reconciliation of LLV: %s", e.ObjectNew.GetName())) + log.Debug(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] UpdateFunc starts reconciliation of LLV: %s", e.ObjectNew.GetName())) oldLLV, ok := e.ObjectOld.(*v1alpha1.LVMLogicalVolume) if !ok { @@ -125,32 +117,52 @@ func RunLVMLogicalVolumeWatcherController( } if reflect.DeepEqual(oldLLV.Spec, newLLV.Spec) && newLLV.DeletionTimestamp == nil { - log.Info(fmt.Sprintf("[UpdateFunc] the LVMLogicalVolume %s has not been changed", newLLV.Name)) - log.Info(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] UpdateFunc ends reconciliation of LLV: %s", newLLV.Name)) + log.Debug(fmt.Sprintf("[UpdateFunc] the LVMLogicalVolume %s has not been changed", newLLV.Name)) + log.Debug(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] UpdateFunc ends reconciliation of LLV: %s", newLLV.Name)) return } + log.Debug(fmt.Sprintf("[UpdateFunc] the LVMLogicalVolume %s has been changed. Add to the queue", newLLV.Name)) - lvg, err := getLVMVolumeGroup(ctx, cl, metrics, "", newLLV.Spec.LvmVolumeGroupName) - if err != nil { - log.Error(err, fmt.Sprintf("[UpdateFunc] unable to get the LVMVolumeGroup, name: %s", newLLV.Spec.LvmVolumeGroupName)) - err = updateLVMLogicalVolumePhase(ctx, cl, log, metrics, newLLV, failedStatusPhase, fmt.Sprintf("Unable to get selected LVMVolumeGroup, err: %s", err.Error())) - if err != nil { - log.Error(err, "[UpdateFunc] unable to updateLVMLogicalVolumePhase") - } - return - } + request := reconcile.Request{NamespacedName: types.NamespacedName{Namespace: newLLV.Namespace, Name: newLLV.Name}} + q.Add(request) + log.Debug(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] UpdateFunc ends reconciliation of LLV: %s", newLLV.Name)) + }, + // DeleteFunc: func(ctx context.Context, e event.DeleteEvent, q workqueue.RateLimitingInterface) { + // log.Info(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] DeleteFunc starts reconciliation of LLV: %s", e.Object.GetName())) + + // llv, ok := e.Object.(*v1alpha1.LVMLogicalVolume) + // if !ok { + // err = errors.New("unable to cast event object to a given type") + // log.Error(err, "[DeleteFunc] an error occurs while handling update event") + // return + // } + // log.Trace("[RunLVMLogicalVolumeWatcherController] DeleteFunc got LVMLogicalVolume: ", llv.Name, llv) - if !belongsToNode(lvg, cfg.NodeName) { - log.Debug(fmt.Sprintf("[UpdateFunc] the LVMVolumeGroup %s does not belongs to the current node: %s. Reconciliation stopped", lvg.Name, cfg.NodeName)) - return - } - log.Debug(fmt.Sprintf("[UpdateFunc] the LVMVolumeGroup %s belongs to the current node: %s", lvg.Name, cfg.NodeName)) + // lvg, err := getLVMVolumeGroup(ctx, cl, metrics, "", llv.Spec.LvmVolumeGroupName) + // if err != nil { + // log.Error(err, fmt.Sprintf("[DeleteFunc] unable to get the LVMVolumeGroup, name: %q. Skip deletion of the LVMLogicalVolume %q", llv.Spec.LvmVolumeGroupName, llv.Name)) + // err = updateLVMLogicalVolumePhase(ctx, cl, log, metrics, llv, failedStatusPhase, fmt.Sprintf("Unable to get selected LVMVolumeGroup, err: %s", err.Error())) + // if err != nil { + // log.Error(err, "[DeleteFunc] unable to update LVMLogicalVolume Phase") + // } + // return + // } - runEventReconcile(ctx, cl, log, metrics, newLLV, lvg) + // if !belongsToNode(lvg, cfg.NodeName) { + // log.Debug(fmt.Sprintf("[DeleteFunc] the LVMVolumeGroup %s does not belongs to the current node: %s. Skip deletion of the LVMLogicalVolume %q", lvg.Name, cfg.NodeName)) + // return + // } + // log.Debug(fmt.Sprintf("[DeleteFunc] the LVMVolumeGroup %s belongs to the current node: %s", lvg.Name, cfg.NodeName)) - log.Info(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] UpdateFunc ends reconciliation of LLV: %s", newLLV.Name)) - }, + // err = deleteLVIfExists(log, lvg.Spec.ActualVGNameOnTheNode, llv.Spec.ActualLVNameOnTheNode) + // if err != nil { + // log.Error(err, fmt.Sprintf("[DeleteFunc] an error occured while trying to delete LV for LVMLogicalVolume %s", llv.Name)) + // } + + // log.Info(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] DeleteFunc ends reconciliation of LLV: %s", llv.Name)) + // }, }) + if err != nil { log.Error(err, "[RunLVMLogicalVolumeWatcherController] the controller is unable to watch") return nil, err @@ -159,40 +171,6 @@ func RunLVMLogicalVolumeWatcherController( return c, err } -func runEventReconcile(ctx context.Context, cl client.Client, log logger.Logger, metrics monitoring.Metrics, llv *v1alpha1.LVMLogicalVolume, lvg *v1alpha1.LvmVolumeGroup) { - log.Trace("[runEventReconcile] starts reconciliation. Identify reconcile func. vgName: "+lvg.Spec.ActualVGNameOnTheNode+", llv:", llv.Name, llv) - recType, err := identifyReconcileFunc(log, lvg.Spec.ActualVGNameOnTheNode, llv) - if err != nil { - log.Error(err, "[runEventReconcile] an error occurs while identify reconcile func") - err = updateLVMLogicalVolumePhase(ctx, cl, log, metrics, llv, failedStatusPhase, fmt.Sprintf("An error occurred while identifying the reconcile func, err: %s", err.Error())) - if err != nil { - log.Error(err, "[runEventReconcile] unable to update a LVMLogicalVolume Phase") - } - return - } - - switch recType { - case CreateReconcile: - log.Debug(fmt.Sprintf("[runEventReconcile] CreateReconcile starts reconciliation for the LVMLogicalVolume: %s", llv.Name)) - reconcileLLVCreateFunc(ctx, cl, log, metrics, llv, lvg) - case UpdateReconcile: - log.Debug(fmt.Sprintf("[runEventReconcile] UpdateReconcile starts reconciliation for the LVMLogicalVolume: %s", llv.Name)) - reconcileLLVUpdateFunc(ctx, cl, log, metrics, llv, lvg) - case DeleteReconcile: - log.Debug(fmt.Sprintf("[runEventReconcile] DeleteReconcile starts reconciliation for the LVMLogicalVolume: %s", llv.Name)) - reconcileLLVDeleteFunc(ctx, cl, log, metrics, llv, lvg) - default: - log.Debug(fmt.Sprintf("[runEventReconcile] the LVMLogicalVolume %s should not be reconciled", llv.Name)) - if llv.Status.Phase != createdStatusPhase { - log.Warning(fmt.Sprintf("[runEventReconcile] the LVMLogicalVolume %s should not be reconciled but has an unexpected phase: %s. Setting the phase to %s", llv.Name, llv.Status.Phase, createdStatusPhase)) - err = updateLVMLogicalVolumePhase(ctx, cl, log, metrics, llv, createdStatusPhase, "") - if err != nil { - log.Error(err, fmt.Sprintf("[runEventReconcile] unable to update the LVMLogicalVolume %s", llv.Name)) - } - } - } -} - func identifyReconcileFunc(log logger.Logger, vgName string, llv *v1alpha1.LVMLogicalVolume) (reconcileType, error) { should, err := shouldReconcileByCreateFunc(log, vgName, llv) if err != nil { @@ -228,11 +206,17 @@ func reconcileLLVDeleteFunc( ) { log.Info("[reconcileLLVDeleteFunc] starts reconciliation") + // The controller won't remove the LLV resource and LV volume till the resource has any other finalizer. + if len(llv.Finalizers) != 1 || + llv.Finalizers[0] != internal.SdsNodeConfiguratorFinalizer { + log.Debug(fmt.Sprintf("[reconcileLLVDeleteFunc] unable to delete LVMLogicalVolume %s for now due to it has any other finalizer", llv.Name)) + return + } + vgName := lvg.Spec.ActualVGNameOnTheNode lvName := llv.Spec.ActualLVNameOnTheNode err := deleteLVIfExists(log, vgName, lvName) - if err != nil { log.Error(err, fmt.Sprintf("[reconcileLLVDeleteFunc] unable to delete the LV %s in VG %s", lvName, vgName)) err = updateLVMLogicalVolumePhase(ctx, cl, log, metrics, llv, failedStatusPhase, fmt.Sprintf("Unable to delete the the LV %s in VG %s, err: %s", lvName, vgName, err.Error())) @@ -633,8 +617,8 @@ func shouldReconcileByCreateFunc(log logger.Logger, vgName string, llv *v1alpha1 } lv, err := FindLV(log, vgName, llv.Spec.ActualLVNameOnTheNode) - if err != nil { - return false, err + if err == nil && lv != nil && lv.LVName == llv.Spec.ActualLVNameOnTheNode { + return false, nil } if lv != nil { @@ -735,20 +719,88 @@ func updateLVMLogicalVolume(ctx context.Context, metrics monitoring.Metrics, cl } func FindLV(log logger.Logger, vgName, lvName string) (*internal.LVData, error) { - lvs, cmd, _, err := utils.GetAllLVs() + log.Debug(fmt.Sprintf("[FindLV] Try to find LV: %s in VG: %s", lvName, vgName)) + lv, cmd, _, err := utils.GetLV(vgName, lvName) + log.Debug(fmt.Sprintf("[FindLV] runs cmd: %s", cmd)) if err != nil { - log.Error(err, "[shouldReconcileByCreateFunc] unable to GetAllLVs") - return &internal.LVData{}, err + if strings.Contains(err.Error(), "Failed to find logical volume") { + log.Debug("[FindLV] LV not found") + return nil, nil + } + log.Error(err, "[shouldReconcileByCreateFunc] unable to GetLV") + return nil, err } + return &lv, nil - log.Debug(fmt.Sprintf("[FindLV] Try to find LV: %s in VG: %s", lvName, vgName)) - for _, lv := range lvs { - log.Trace(fmt.Sprintf("[FindLV] processing LV: %s, VG: %s", lv.LVName, lv.VGName)) - if lv.VGName == vgName && lv.LVName == lvName { - return &lv, nil +} + +func ReconcileLVMLogicalVolume(ctx context.Context, cl client.Client, log logger.Logger, metrics monitoring.Metrics, cfg config.Options, request reconcile.Request) (bool, error) { + llv := &v1alpha1.LVMLogicalVolume{} + err := cl.Get(ctx, request.NamespacedName, llv) + if err != nil { + if k8serr.IsNotFound(err) { + log.Debug(fmt.Sprintf("[ReconcileLVMLogicalVolume] LVMLogicalVolume %s not found. Object has probably been deleted.", request.NamespacedName)) + return false, nil + } + return true, fmt.Errorf("[ReconcileLVMLogicalVolume] unable to get LVMLogicalVolume: %w", err) + } + + lvg, err := getLVMVolumeGroup(ctx, cl, metrics, "", llv.Spec.LvmVolumeGroupName) + if err != nil { + if k8serr.IsNotFound(err) { + log.Debug(fmt.Sprintf("[ReconcileLVMLogicalVolume] LVMVolumeGroup %s not found for LVMLogicalVolume %s", llv.Spec.LvmVolumeGroupName, llv.Name)) + err = updateLVMLogicalVolumePhase(ctx, cl, log, metrics, llv, failedStatusPhase, fmt.Sprintf("Unable to get selected LVMVolumeGroup %s, err: %s", llv.Spec.LvmVolumeGroupName, err.Error())) + if err != nil { + return true, fmt.Errorf("[ReconcileLVMLogicalVolume] unable to update the LVMLogicalVolume %s status.phase to %s: %w", llv.Name, failedStatusPhase, err) + } + return true, nil + } + reconcileErr := fmt.Errorf("[ReconcileLVMLogicalVolume] unable to get LVMVolumeGroup %s: %w", llv.Spec.LvmVolumeGroupName, err) + updateErr := updateLVMLogicalVolumePhase(ctx, cl, log, metrics, llv, failedStatusPhase, fmt.Sprintf("Unable to get selected LVMVolumeGroup, err: %s", err.Error())) + if updateErr != nil { + return true, fmt.Errorf("%s. Also failed to update LVMLogicalVolume %s status.phase to %s: %w", reconcileErr, llv.Name, failedStatusPhase, updateErr) } + return false, reconcileErr } - return &internal.LVData{}, nil + if !belongsToNode(lvg, cfg.NodeName) { + log.Debug(fmt.Sprintf("[ReconcileLVMLogicalVolume] the LVMVolumeGroup %s does not belongs to the current node: %s. Reconciliation stopped", lvg.Name, cfg.NodeName)) + return false, nil + } + + log.Info(fmt.Sprintf("[ReconcileLVMLogicalVolume] the LVMVolumeGroup %s belongs to the current node: %s. Reconciliation continues", lvg.Name, cfg.NodeName)) + log.Debug("[ReconcileLVMLogicalVolume] Identify reconcile func. vgName: "+lvg.Spec.ActualVGNameOnTheNode+", llv:", llv.Name, llv) + + recType, err := identifyReconcileFunc(log, lvg.Spec.ActualVGNameOnTheNode, llv) + if err != nil { + reconcileErr := fmt.Errorf("[ReconcileLVMLogicalVolume] unable to identify the reconcile func: %w", err) + updateErr := updateLVMLogicalVolumePhase(ctx, cl, log, metrics, llv, failedStatusPhase, fmt.Sprintf("An error occurred while identifying the reconcile func, err: %s", err.Error())) + if updateErr != nil { + return true, fmt.Errorf("%s. Also failed to update LVMLogicalVolume %s status.phase to %s: %w", reconcileErr, llv.Name, failedStatusPhase, updateErr) + } + return false, reconcileErr + } + + switch recType { + case CreateReconcile: + log.Debug(fmt.Sprintf("[runEventReconcile] CreateReconcile starts reconciliation for the LVMLogicalVolume: %s", llv.Name)) + reconcileLLVCreateFunc(ctx, cl, log, metrics, llv, lvg) + case UpdateReconcile: + log.Debug(fmt.Sprintf("[runEventReconcile] UpdateReconcile starts reconciliation for the LVMLogicalVolume: %s", llv.Name)) + reconcileLLVUpdateFunc(ctx, cl, log, metrics, llv, lvg) + case DeleteReconcile: + log.Debug(fmt.Sprintf("[runEventReconcile] DeleteReconcile starts reconciliation for the LVMLogicalVolume: %s", llv.Name)) + reconcileLLVDeleteFunc(ctx, cl, log, metrics, llv, lvg) + default: + log.Debug(fmt.Sprintf("[runEventReconcile] the LVMLogicalVolume %s should not be reconciled", llv.Name)) + if llv.Status.Phase != createdStatusPhase { + log.Warning(fmt.Sprintf("[runEventReconcile] the LVMLogicalVolume %s should not be reconciled but has an unexpected phase: %s. Setting the phase to %s", llv.Name, llv.Status.Phase, createdStatusPhase)) + err = updateLVMLogicalVolumePhase(ctx, cl, log, metrics, llv, createdStatusPhase, "") + if err != nil { + return true, fmt.Errorf("[runEventReconcile] unable to update the LVMLogicalVolume %s status.phase to %s: %w", llv.Name, createdStatusPhase, err) + } + } + } + return false, nil } diff --git a/images/agent/pkg/controller/lvm_volume_group_discover.go b/images/agent/pkg/controller/lvm_volume_group_discover.go index a50edcb2..6e9f2572 100644 --- a/images/agent/pkg/controller/lvm_volume_group_discover.go +++ b/images/agent/pkg/controller/lvm_volume_group_discover.go @@ -87,9 +87,9 @@ func RunLVMVolumeGroupDiscoverController( blockDevices, err := GetAPIBlockDevices(ctx, cl, metrics) if err != nil { log.Error(err, "[RunLVMVolumeGroupDiscoverController] unable to GetAPIBlockDevices") - for _, lvm := range currentLVMVGs { - if err = turnLVMVGHealthToNonOperational(ctx, cl, lvm, err); err != nil { - log.Error(err, fmt.Sprintf(`[RunLVMVolumeGroupDiscoverController] unable to change health param in LVMVolumeGroup, name: "%s"`, lvm.Name)) + for _, lvg := range currentLVMVGs { + if err = turnLVMVGHealthToNonOperational(ctx, cl, lvg, err); err != nil { + log.Error(err, fmt.Sprintf(`[RunLVMVolumeGroupDiscoverController] unable to change health param in LVMVolumeGroup, name: "%s"`, lvg.Name)) } } continue @@ -97,9 +97,9 @@ func RunLVMVolumeGroupDiscoverController( if len(blockDevices) == 0 { log.Error(fmt.Errorf("no block devices found"), "[RunLVMVolumeGroupDiscoverController] unable to get block devices") - for _, lvm := range currentLVMVGs { - if err = turnLVMVGHealthToNonOperational(ctx, cl, lvm, fmt.Errorf("no block devices found")); err != nil { - log.Error(err, fmt.Sprintf(`[RunLVMVolumeGroupDiscoverController] unable to change health param in LVMVolumeGroup, name: "%s"`, lvm.Name)) + for _, lvg := range currentLVMVGs { + if err = turnLVMVGHealthToNonOperational(ctx, cl, lvg, fmt.Errorf("no block devices found")); err != nil { + log.Error(err, fmt.Sprintf(`[RunLVMVolumeGroupDiscoverController] unable to change health param in LVMVolumeGroup, name: "%s"`, lvg.Name)) } } continue @@ -110,9 +110,10 @@ func RunLVMVolumeGroupDiscoverController( candidates, err := GetLVMVolumeGroupCandidates(log, metrics, blockDevices, cfg.NodeName) if err != nil { log.Error(err, "[RunLVMVolumeGroupDiscoverController] unable to run GetLVMVolumeGroupCandidates") - for _, lvm := range filteredResources { - if err = turnLVMVGHealthToNonOperational(ctx, cl, lvm, err); err != nil { - log.Error(err, fmt.Sprintf(`[RunLVMVolumeGroupDiscoverController] unable to change health param in LVMVolumeGroup, name: "%s"`, lvm.Name)) + for _, lvg := range filteredResources { + log.Trace(fmt.Sprintf("[RunLVMVolumeGroupDiscoverController] turn LVMVolumeGroup %q to non operational. LVG struct: %+v ", lvg.Name, lvg)) + if err = turnLVMVGHealthToNonOperational(ctx, cl, lvg, err); err != nil { + log.Error(err, fmt.Sprintf(`[RunLVMVolumeGroupDiscoverController] unable to change health param in LVMVolumeGroup, name: "%s"`, lvg.Name)) } } continue diff --git a/images/agent/pkg/controller/lvm_volume_group_watcher.go b/images/agent/pkg/controller/lvm_volume_group_watcher.go index c74f48a1..09a5df86 100644 --- a/images/agent/pkg/controller/lvm_volume_group_watcher.go +++ b/images/agent/pkg/controller/lvm_volume_group_watcher.go @@ -26,7 +26,6 @@ import ( "sds-node-configurator/pkg/logger" "sds-node-configurator/pkg/monitoring" "sds-node-configurator/pkg/utils" - "strings" "time" "sds-node-configurator/config" @@ -201,18 +200,17 @@ func ReconcileLVMVG( } if lvg == nil { err = errors.New("nil pointer detected") - log.Error(err, "[ReconcileLVMVG] requested LVMVG group in nil") + log.Error(err, fmt.Sprintf("[ReconcileLVMVG] requested LVMVolumeGroup %s is nil", objectName)) return true, err } isOwnedByNode, status, err := CheckLVMVGNodeOwnership(ctx, cl, metrics, lvg, objectNameSpace, nodeName) - if err != nil { - log.Error(err, fmt.Sprintf("[ReconcileLVMVG] error CheckLVMVGNodeOwnership, resource name: %s", lvg.Name)) + log.Error(err, fmt.Sprintf("[ReconcileLVMVG] error CheckLVMVGNodeOwnership, LVMVolumeGroup name: %s", lvg.Name)) if status.Health == NonOperational { health := status.Health message := status.Message - log.Error(err, fmt.Sprintf("[ReconcileLVMVG] ValidateLVMGroup, resource name: %s, health: %s, phase: %s, message: %s", lvg.Name, health, status.Phase, message)) + log.Error(err, fmt.Sprintf("[ReconcileLVMVG] ValidateLVMGroup, LVMVolumeGroup name: %s, health: %s, phase: %s, message: %s", lvg.Name, health, status.Phase, message)) err = updateLVMVolumeGroupHealthStatus(ctx, cl, metrics, lvg.Name, lvg.Namespace, message, health) if err != nil { log.Error(err, fmt.Sprintf("[ReconcileLVMVG] error update LVMVolumeGroup %s", lvg.Name)) @@ -223,54 +221,82 @@ func ReconcileLVMVG( } if !isOwnedByNode { - log.Debug(fmt.Sprintf("[ReconcileLVMVG] resource is not owned by node, name: %s, skip it", lvg.Name)) + log.Debug(fmt.Sprintf("[ReconcileLVMVG] LVMVolumeGroup %s is not owned by the current node, skip it", lvg.Name)) return false, nil } - log.Info("[ReconcileLVMVG] validation passed") + var totalVGSize int64 + for _, bdName := range lvg.Spec.BlockDeviceNames { + bd, err := getBlockDevice(ctx, cl, metrics, "", bdName) + if err != nil { + log.Error(err, fmt.Sprintf("[ReconcileLVMVG] unable to get BlockDevice %s for LVMVolumeGroup %s", bdName, lvg.Name)) + return true, err + } + + totalVGSize += bd.Status.Size.Value() + } + + var totalThinPoolSize int64 + for _, tp := range lvg.Spec.ThinPools { + totalThinPoolSize += tp.Size.Value() + } + + resizeDelta, _ := utils.QuantityToBytes(internal.ResizeDelta) - annotationMark := 0 - for k := range lvg.Annotations { - if strings.Contains(k, delAnnotation) { - annotationMark++ + if totalThinPoolSize+resizeDelta >= totalVGSize { + err := errors.New("required space for thin pools is more than VG size") + log.Error(err, fmt.Sprintf("[ReconcileLVMVG] validation fails for LVMVolumeGroup %s", lvg.Name)) + + err = updateLVMVolumeGroupHealthStatus(ctx, cl, metrics, lvg.Name, "", err.Error(), NonOperational) + if err != nil { + log.Error(err, fmt.Sprintf("[ReconcileLVMVG] unable to update LVMVolumeGroup %s", lvg.Name)) + return true, err } + + return false, err } - if annotationMark != 0 { + log.Info(fmt.Sprintf("[ReconcileLVMVG] LVMVolumeGroup %s validation passed", lvg.Name)) + + _, exist := lvg.Annotations[delAnnotation] + log.Debug(fmt.Sprintf("[ReconcileLVMVG] LVMVolumeGroup %s contains contains delete annotation: %t", lvg.Name, exist)) + if exist { // lock - log.Info(fmt.Sprintf("[ReconcileLVMVG] create event: %s", EventActionDeleting)) + log.Info(fmt.Sprintf("[ReconcileLVMVG] create event %s for LVMVolumeGroup %s", EventActionDeleting, lvg.Name)) err = CreateEventLVMVolumeGroup(ctx, cl, metrics, EventReasonDeleting, EventActionDeleting, nodeName, lvg) if err != nil { log.Error(err, "[ReconcileLVMVG] error CreateEventLVMVolumeGroup") return true, err } - err := DeleteVG(lvg.Spec.ActualVGNameOnTheNode, log, metrics) + err = DeleteVG(lvg.Spec.ActualVGNameOnTheNode, log, metrics) if err != nil { - log.Error(err, fmt.Sprintf("[ReconcileLVMVG] delete VG, name: %s", lvg.Spec.ActualVGNameOnTheNode)) + log.Error(err, fmt.Sprintf("[ReconcileLVMVG] delete VG %s of LVMVolumeGroup %s", lvg.Spec.ActualVGNameOnTheNode, lvg.Name)) return true, err } - log.Info(fmt.Sprintf("[ReconcileLVMVG] VG deleted, name: %s", lvg.Spec.ActualVGNameOnTheNode)) + log.Info(fmt.Sprintf("[ReconcileLVMVG] VG %s deleted of LVMVolumeGroup %s", lvg.Spec.ActualVGNameOnTheNode, lvg.Name)) return false, nil } - log.Info("[ReconcileLVMVG] start reconciliation VG process") - log.Info(fmt.Sprintf("[ReconcileLVMVG] create event: %s", EventActionProvisioning)) + log.Info(fmt.Sprintf("[ReconcileLVMVG] start reconciliation VG process for LVMVolumeGroup %s", lvg.Name)) + log.Info(fmt.Sprintf("[ReconcileLVMVG] create event %s for LVMVolumeGroup %s", EventActionProvisioning, lvg.Name)) err = CreateEventLVMVolumeGroup(ctx, cl, metrics, EventReasonProvisioning, EventActionProvisioning, nodeName, lvg) if err != nil { - log.Error(err, "[ReconcileLVMVG] error CreateEventLVMVolumeGroup") + log.Error(err, fmt.Sprintf("[ReconcileLVMVG] error CreateEvent for LVMVolumeGroup %s", lvg.Name)) return true, err } - log.Info(fmt.Sprintf(`[ReconcileLVMVG] event was created for resource, name: %s`, lvg.Name)) + log.Info(fmt.Sprintf(`[ReconcileLVMVG] event was created for LVMVolumeGroup %s`, lvg.Name)) isVgExist, vg, err := GetVGFromNode(lvg.Spec.ActualVGNameOnTheNode, log, metrics) if err != nil { - log.Error(err, fmt.Sprintf("[ReconcileLVMVG] error ExistVG, name: %s", lvg.Spec.ActualVGNameOnTheNode)) + log.Error(err, fmt.Sprintf("[ReconcileLVMVG] unable to get VG %s from the node for LVMVolumeGroup %s", lvg.Spec.ActualVGNameOnTheNode, lvg.Name)) return true, err } + + log.Trace(fmt.Sprintf("VG %s of LVMVolumeGroup %s does exist: %t", lvg.Spec.ActualVGNameOnTheNode, lvg.Name, isVgExist)) if isVgExist { - log.Debug("[ReconcileLVMVG] start UpdateLVMVolumeGroupTagsName for r " + lvg.Name) + log.Debug(fmt.Sprintf("[ReconcileLVMVG] start UpdateLVMVolumeGroupTagsName for LVMVolumeGroup %s", lvg.Name)) updated, err := UpdateLVMVolumeGroupTagsName(log, metrics, vg, lvg) if err != nil { log.Error(err, fmt.Sprintf("[ReconcileLVMVG] unable to update VG tags on VG, name: %s", lvg.Spec.ActualVGNameOnTheNode)) @@ -375,7 +401,7 @@ func ReconcileLVMVG( } if lvg.Spec.ThinPools != nil { - log.Info("[ReconcileLVMVG] reconcile thin pool") + log.Info(fmt.Sprintf("[ReconcileLVMVG] reconcile thin pools for LVMVolumeGroup %s", lvg.Name)) statusThinPoolMap := make(map[string]v1alpha1.StatusThinPool) for _, statusThinPool := range lvg.Status.ThinPools { @@ -383,11 +409,10 @@ func ReconcileLVMVG( } for _, specThinPool := range lvg.Spec.ThinPools { - log.Debug(fmt.Sprintf("[ReconcileLVMVG] Start reconcile thin pool: %s", specThinPool.Name)) - log.Debug(fmt.Sprintf("[ReconcileLVMVG] thin pool size: %d", specThinPool.Size.Value())) + log.Debug(fmt.Sprintf("[ReconcileLVMVG] Start reconcile thin pool %s of LVMVolumeGroup %s", specThinPool.Name, lvg.Name)) + log.Debug(fmt.Sprintf("[ReconcileLVMVG] LVMVolumeGroup %s thin pool %s size: %d", lvg.Name, specThinPool.Name, specThinPool.Size.Value())) statusThinPool, ok := statusThinPoolMap[specThinPool.Name] - if !ok { log.Info(fmt.Sprintf("[ReconcileLVMVG] create event: %s", EventActionCreating)) err = CreateEventLVMVolumeGroup(ctx, cl, metrics, EventReasonCreating, EventActionCreating, nodeName, lvg) @@ -433,35 +458,35 @@ func ReconcileLVMVG( } } else { - log.Info(fmt.Sprintf("[ReconcileLVMVG] create event: %s", EventActionCreating)) + log.Info(fmt.Sprintf("[ReconcileLVMVG] create event %s for LVMVolumeGroup %s", EventActionCreating, lvg.Name)) err = CreateEventLVMVolumeGroup(ctx, cl, metrics, EventReasonCreating, EventActionCreating, nodeName, lvg) if err != nil { - log.Error(err, fmt.Sprintf("[ReconcileLVMVG] error CreateEventLVMVolumeGroup, resource name: %s", lvg.Name)) + log.Error(err, fmt.Sprintf("[ReconcileLVMVG] error CreateEvent for LVMVolumeGroup %s", lvg.Name)) } - log.Debug("[ReconcileLVMVG] Start CreateVGComplex function for resource " + lvg.Name) - err := CreateVGComplex(ctx, cl, metrics, lvg, log) + log.Debug(fmt.Sprintf("[ReconcileLVMVG] Start CreateVGComplex function for LVMVolumeGroup %s", lvg.Name)) + err = CreateVGComplex(ctx, cl, metrics, lvg, log) if err != nil { - log.Error(err, fmt.Sprintf("[ReconcileLVMVG] unable to CreateVGComplex for resource, name: %s", lvg.Name)) + log.Error(err, fmt.Sprintf("[ReconcileLVMVG] unable to CreateVGComplex for LVMVolumeGroup: %s", lvg.Name)) if err = updateLVMVolumeGroupHealthStatus(ctx, cl, metrics, lvg.Name, lvg.Namespace, err.Error(), NonOperational); err != nil { - log.Error(err, fmt.Sprintf("[ReconcileLVMVG] unable to update LVMVolumeGroupStatus, resource name: %s", lvg.Name)) + log.Error(err, fmt.Sprintf("[ReconcileLVMVG] unable to update Status for LVMVolumeGroup: %s", lvg.Name)) } return true, err } if len(lvg.Spec.ThinPools) != 0 { - for _, v := range lvg.Spec.ThinPools { + for _, thinPool := range lvg.Spec.ThinPools { start := time.Now() - command, err := utils.CreateThinPool(v, lvg.Spec.ActualVGNameOnTheNode) + command, err := utils.CreateThinPool(thinPool, lvg.Spec.ActualVGNameOnTheNode) metrics.UtilsCommandsDuration(LVMVolumeGroupWatcherCtrlName, "lvcreate").Observe(metrics.GetEstimatedTimeInSeconds(start)) metrics.UtilsCommandsExecutionCount(LVMVolumeGroupWatcherCtrlName, "lvcreate").Inc() log.Debug(command) if err != nil { metrics.UtilsCommandsErrorsCount(LVMVolumeGroupWatcherCtrlName, "lvcreate").Inc() - log.Error(err, fmt.Sprintf("[ReconcileLVMVG] error CreateThinPool, thin pool: %s", v.Name)) + log.Error(err, fmt.Sprintf("[ReconcileLVMVG] unable to create a thin pool %s for LVMVolumeGroup %s", thinPool.Name, lvg.Name)) if err = updateLVMVolumeGroupHealthStatus(ctx, cl, metrics, lvg.Name, lvg.Namespace, err.Error(), NonOperational); err != nil { - log.Error(err, fmt.Sprintf("[ReconcileLVMVG] unable to update LVMVolumeGroupStatus, resource name: %s", lvg.Name)) + log.Error(err, fmt.Sprintf("[ReconcileLVMVG] unable to update Status for LVMVolumeGroup %s", lvg.Name)) } return true, err }