Skip to content

Commit

Permalink
Support property-namespace
Browse files Browse the repository at this point in the history
In Operator v2, we changed the way Kubernetes properties are added to LINSTOR
Nodes: Instead of using Aux/<label> properties, these are now found in
Aux/topology/<label>.

This commit adds the --property-namespace option, which can be used to
configure the property namespace. This fixes an issue with Operator v2
deployments where the Affinity Controller would remove affinity settings
because it could not find the matching properties in LINSTOR.

Signed-off-by: Moritz "WanzenBug" Wanzenböck <moritz.wanzenboeck@linbit.com>
  • Loading branch information
WanzenBug committed May 4, 2023
1 parent c84682a commit c5a449f
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 430 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.3.0] -- 2023-05-04

### Added
- Support for `--property-namespace`, as used by Operator v2 to configure LINSTOR CSI.

## [0.2.2] -- 2022-06-02

### Changed
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.4
FROM --platform=$BUILDPLATFORM golang:1.18 as builder
FROM --platform=$BUILDPLATFORM golang:1.20 as builder

WORKDIR /src/
COPY go.* /src/
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ The following options can be set on the chart:
|-------------------------------|----------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| `replicaCount` | Number of replicas to deploy. | `1` |
| `options.v` | Set verbosity for controller | `2` |
| `options.reconcile-rate` | Set the reconcile rate, i.e. how often the cluster state will be checked and updated | `15s` |
| `options.resync-rate` | How often the controller will resync it's internal cache of Kubernetes resources | `15m` |
| `options.reconcileRate` | Set the reconcile rate, i.e. how often the cluster state will be checked and updated | `15s` |
| `options.resyncRate` | How often the controller will resync it's internal cache of Kubernetes resources | `15m` |
| `options.propertyNamespace` | Namespace used by LINSTOR CSI to store Kubernetes Node Labels | `Aux` |
| `linstor.Endpoint` | URL of the LINSTOR Controller API. | `""` (auto-detected when using Piraeus-Operator) |
| `linstor.clientSecret` | TLS secret to use to authenticate with the LINSTOR API | `""` (auto-detected when using Piraeus-Operator) |
| `image.repository` | Repository to pull the linstor-affinity-controller image from. | `quay.io/piraeusdatastore/linstor-affinity-controller` |
Expand Down
17 changes: 10 additions & 7 deletions cmd/linstor-affinity-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os/signal"
"time"

linstor "github.com/LINBIT/golinstor"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
k8scli "k8s.io/component-base/cli"
Expand All @@ -18,7 +19,7 @@ func NewControllerCommand() *cobra.Command {
cfgflags := genericclioptions.NewConfigFlags(false)
var reconcileRate, resyncRate, timeout time.Duration
var electorCfg leaderelection.Config
var bindAddress string
var bindAddress, propertyNamespace string

cmd := &cobra.Command{
Use: "linstor-volume-controller",
Expand All @@ -38,12 +39,13 @@ func NewControllerCommand() *cobra.Command {
}

ctrl, err := controller.NewReconciler(&controller.Config{
RestCfg: cfg,
ResyncRate: resyncRate,
ReconcileRate: reconcileRate,
Timeout: timeout,
LeaderElector: elector,
BindAddress: bindAddress,
RestCfg: cfg,
ResyncRate: resyncRate,
ReconcileRate: reconcileRate,
Timeout: timeout,
LeaderElector: elector,
BindAddress: bindAddress,
PropertyNamespace: propertyNamespace,
})
if err != nil {
return err
Expand All @@ -58,6 +60,7 @@ func NewControllerCommand() *cobra.Command {
cmd.Flags().DurationVar(&resyncRate, "resync-rate", 5*time.Minute, "how often the internal object cache should be resynchronized")
cmd.Flags().DurationVar(&timeout, "timeout", 1*time.Minute, "how long a single reconcile attempt can take")
cmd.Flags().StringVar(&bindAddress, "bind-address", "[::]:8000", "the address to use for /healthz and /readyz probes")
cmd.Flags().StringVar(&propertyNamespace, "property-namespace", linstor.NamespcAuxiliary, "The property namespace used by LINSTOR CSI")
electorCfg.AddFlags(cmd.Flags())

return cmd
Expand Down
106 changes: 55 additions & 51 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,83 +1,87 @@
module github.com/piraeusdatastore/linstor-affinity-controller

go 1.18
go 1.20

require (
github.com/LINBIT/golinstor v0.41.3
github.com/container-storage-interface/spec v1.5.0
github.com/piraeusdatastore/linstor-csi v0.19.1
github.com/spf13/cobra v1.4.0
k8s.io/api v0.24.0
k8s.io/apimachinery v0.24.0
k8s.io/cli-runtime v0.24.0
k8s.io/client-go v0.24.0
k8s.io/component-base v0.24.0
k8s.io/klog/v2 v2.60.1
github.com/LINBIT/golinstor v0.48.0
github.com/container-storage-interface/spec v1.6.0
github.com/piraeusdatastore/linstor-csi v1.0.1
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
k8s.io/api v0.27.1
k8s.io/apimachinery v0.27.1
k8s.io/cli-runtime v0.27.1
k8s.io/client-go v0.27.1
k8s.io/component-base v0.27.1
k8s.io/klog/v2 v2.100.1
)

require (
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/donovanhide/eventsource v0.0.0-20210830082556-c59027999da0 // indirect
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // 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.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/haySwim/data v0.2.0 // indirect
github.com/imdario/mergo v0.3.5 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/moul/http2curl v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.7.0 // indirect
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/xlab/treeprint v1.1.0 // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.0.0-20220222200937-f2425489ef4c // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.0.0-20220630143837-2104d58473e0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368 // indirect
google.golang.org/grpc v1.43.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
google.golang.org/genproto v0.0.0-20220630174209-ad1d48641aa7 // indirect
google.golang.org/grpc v1.51.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
k8s.io/mount-utils v0.23.0 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/kustomize/api v0.11.4 // indirect
sigs.k8s.io/kustomize/kyaml v0.13.6 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a // indirect
k8s.io/mount-utils v0.24.2 // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
moul.io/http2curl/v2 v2.3.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.13.2 // indirect
sigs.k8s.io/kustomize/kyaml v0.14.1 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit c5a449f

Please sign in to comment.