Skip to content

Commit

Permalink
Merge pull request #106 from cschwede/add-default-config-overwrite
Browse files Browse the repository at this point in the history
Add DefaultConfigOverwrite option
  • Loading branch information
cschwede authored Feb 21, 2024
2 parents 5490720 + e24c676 commit a7018fa
Show file tree
Hide file tree
Showing 21 changed files with 120 additions and 29 deletions.
6 changes: 6 additions & 0 deletions api/bases/swift.openstack.org_swiftproxies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ spec:
containerImageProxy:
description: Swift Proxy Container Image URL
type: string
defaultConfigOverwrite:
additionalProperties:
type: string
description: DefaultConfigOverwrite - can be used to add additionalfiles.
Those get added to the service config dir in /etc/<servicename>-conf.d
type: object
memcachedServers:
default: ""
description: List of memcached servers.
Expand Down
12 changes: 12 additions & 0 deletions api/bases/swift.openstack.org_swifts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ spec:
containerImageProxy:
description: Swift Proxy Container Image URL
type: string
defaultConfigOverwrite:
additionalProperties:
type: string
description: DefaultConfigOverwrite - can be used to add additionalfiles.
Those get added to the service config dir in /etc/<servicename>-conf.d
type: object
memcachedServers:
default: ""
description: List of memcached servers.
Expand Down Expand Up @@ -393,6 +399,12 @@ spec:
default: false
description: If the container sharder daemon is enabled.
type: boolean
defaultConfigOverwrite:
additionalProperties:
type: string
description: DefaultConfigOverwrite - can be used to add additionalfiles.
Those get added to the service config dir in /etc/<servicename>-conf.d
type: object
memcachedServers:
default: ""
description: List of memcached servers.
Expand Down
6 changes: 6 additions & 0 deletions api/bases/swift.openstack.org_swiftstorages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ spec:
default: false
description: If the container sharder daemon is enabled.
type: boolean
defaultConfigOverwrite:
additionalProperties:
type: string
description: DefaultConfigOverwrite - can be used to add additionalfiles.
Those get added to the service config dir in /etc/<servicename>-conf.d
type: object
memcachedServers:
default: ""
description: List of memcached servers.
Expand Down
4 changes: 4 additions & 0 deletions api/v1beta1/swiftproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ type SwiftProxySpec struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
// TLS - Parameters related to the TLS
TLS tls.API `json:"tls,omitempty"`

// DefaultConfigOverwrite - can be used to add additionalfiles. Those get
// added to the service config dir in /etc/<servicename>-conf.d
DefaultConfigOverwrite map[string]string `json:"defaultConfigOverwrite,omitempty"`
}

// ProxyOverrideSpec to override the generated manifest of several child resources.
Expand Down
4 changes: 4 additions & 0 deletions api/v1beta1/swiftstorage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ type SwiftStorageSpec struct {
// +kubebuilder:default=false
// If the container sharder daemon is enabled.
ContainerSharderEnabled bool `json:"containerSharderEnabled"`

// DefaultConfigOverwrite - can be used to add additionalfiles. Those get
// added to the service config dir in /etc/<servicename>-conf.d
DefaultConfigOverwrite map[string]string `json:"defaultConfigOverwrite,omitempty"`
}

// SwiftStorageStatus defines the observed state of SwiftStorage
Expand Down
14 changes: 14 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions config/crd/bases/swift.openstack.org_swiftproxies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ spec:
containerImageProxy:
description: Swift Proxy Container Image URL
type: string
defaultConfigOverwrite:
additionalProperties:
type: string
description: DefaultConfigOverwrite - can be used to add additionalfiles.
Those get added to the service config dir in /etc/<servicename>-conf.d
type: object
memcachedServers:
default: ""
description: List of memcached servers.
Expand Down
12 changes: 12 additions & 0 deletions config/crd/bases/swift.openstack.org_swifts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ spec:
containerImageProxy:
description: Swift Proxy Container Image URL
type: string
defaultConfigOverwrite:
additionalProperties:
type: string
description: DefaultConfigOverwrite - can be used to add additionalfiles.
Those get added to the service config dir in /etc/<servicename>-conf.d
type: object
memcachedServers:
default: ""
description: List of memcached servers.
Expand Down Expand Up @@ -393,6 +399,12 @@ spec:
default: false
description: If the container sharder daemon is enabled.
type: boolean
defaultConfigOverwrite:
additionalProperties:
type: string
description: DefaultConfigOverwrite - can be used to add additionalfiles.
Those get added to the service config dir in /etc/<servicename>-conf.d
type: object
memcachedServers:
default: ""
description: List of memcached servers.
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/swift.openstack.org_swiftstorages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ spec:
default: false
description: If the container sharder daemon is enabled.
type: boolean
defaultConfigOverwrite:
additionalProperties:
type: string
description: DefaultConfigOverwrite - can be used to add additionalfiles.
Those get added to the service config dir in /etc/<servicename>-conf.d
type: object
memcachedServers:
default: ""
description: List of memcached servers.
Expand Down
22 changes: 12 additions & 10 deletions controllers/swift_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ func (r *SwiftReconciler) storageCreateOrUpdate(ctx context.Context, instance *s
NetworkAttachments: instance.Spec.SwiftStorage.NetworkAttachments,
MemcachedServers: memcachedServers,
ContainerSharderEnabled: instance.Spec.SwiftStorage.ContainerSharderEnabled,
DefaultConfigOverwrite: instance.Spec.SwiftStorage.DefaultConfigOverwrite,
}

deployment := &swiftv1.SwiftStorage{
Expand All @@ -421,16 +422,17 @@ func (r *SwiftReconciler) storageCreateOrUpdate(ctx context.Context, instance *s
func (r *SwiftReconciler) proxyCreateOrUpdate(ctx context.Context, instance *swiftv1.Swift, memcachedServers string) (*swiftv1.SwiftProxy, controllerutil.OperationResult, error) {

swiftProxySpec := swiftv1.SwiftProxySpec{
Replicas: instance.Spec.SwiftProxy.Replicas,
ContainerImageProxy: instance.Spec.SwiftProxy.ContainerImageProxy,
Secret: instance.Spec.SwiftProxy.Secret,
ServiceUser: instance.Spec.SwiftProxy.ServiceUser,
PasswordSelectors: instance.Spec.SwiftProxy.PasswordSelectors,
SwiftConfSecret: instance.Spec.SwiftConfSecret,
Override: instance.Spec.SwiftProxy.Override,
NetworkAttachments: instance.Spec.SwiftProxy.NetworkAttachments,
MemcachedServers: memcachedServers,
TLS: instance.Spec.SwiftProxy.TLS,
Replicas: instance.Spec.SwiftProxy.Replicas,
ContainerImageProxy: instance.Spec.SwiftProxy.ContainerImageProxy,
Secret: instance.Spec.SwiftProxy.Secret,
ServiceUser: instance.Spec.SwiftProxy.ServiceUser,
PasswordSelectors: instance.Spec.SwiftProxy.PasswordSelectors,
SwiftConfSecret: instance.Spec.SwiftConfSecret,
Override: instance.Spec.SwiftProxy.Override,
NetworkAttachments: instance.Spec.SwiftProxy.NetworkAttachments,
MemcachedServers: memcachedServers,
TLS: instance.Spec.SwiftProxy.TLS,
DefaultConfigOverwrite: instance.Spec.SwiftProxy.DefaultConfigOverwrite,
}

deployment := &swiftv1.SwiftProxy{
Expand Down
2 changes: 1 addition & 1 deletion pkg/swiftproxy/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func Deployment(
ReadinessProbe: readinessProbe,
LivenessProbe: livenessProbe,
VolumeMounts: volumeMounts,
Command: []string{"/usr/bin/swift-proxy-server", "/etc/swift/proxy-server.conf", "-v"},
Command: []string{"/usr/bin/swift-proxy-server", "/etc/swift/proxy-server.conf.d", "-v"},
},
},
},
Expand Down
5 changes: 5 additions & 0 deletions pkg/swiftproxy/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ func SecretTemplates(
httpdVhostConfig[endpt.String()] = endptConfig
}
templateParameters["VHosts"] = httpdVhostConfig
customData := map[string]string{}
for key, data := range instance.Spec.DefaultConfigOverwrite {
customData[key] = data
}

return []util.Template{
{
Expand All @@ -64,6 +68,7 @@ func SecretTemplates(
InstanceType: instance.Kind,
ConfigOptions: templateParameters,
Labels: labels,
CustomData: customData,
},
{
Name: fmt.Sprintf("%s-scripts", instance.Name),
Expand Down
30 changes: 15 additions & 15 deletions pkg/swiftstorage/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,31 @@ func getStorageContainers(swiftstorage *swiftv1beta1.SwiftStorage) []corev1.Cont
SecurityContext: &securityContext,
Ports: getPorts(swift.AccountServerPort, "account"),
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"/usr/bin/swift-account-server", "/etc/swift/account-server.conf", "-v"},
Command: []string{"/usr/bin/swift-account-server", "/etc/swift/account-server.conf.d", "-v"},
},
{
Name: "account-replicator",
Image: swiftstorage.Spec.ContainerImageAccount,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &securityContext,
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"/usr/bin/swift-account-replicator", "/etc/swift/account-server.conf", "-v"},
Command: []string{"/usr/bin/swift-account-replicator", "/etc/swift/account-server.conf.d", "-v"},
},
{
Name: "account-auditor",
Image: swiftstorage.Spec.ContainerImageAccount,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &securityContext,
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"/usr/bin/swift-account-auditor", "/etc/swift/account-server.conf", "-v"},
Command: []string{"/usr/bin/swift-account-auditor", "/etc/swift/account-server.conf.d", "-v"},
},
{
Name: "account-reaper",
Image: swiftstorage.Spec.ContainerImageAccount,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &securityContext,
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"/usr/bin/swift-account-reaper", "/etc/swift/account-server.conf", "-v"},
Command: []string{"/usr/bin/swift-account-reaper", "/etc/swift/account-server.conf.d", "-v"},
},
{
Name: "container-server",
Expand All @@ -87,31 +87,31 @@ func getStorageContainers(swiftstorage *swiftv1beta1.SwiftStorage) []corev1.Cont
SecurityContext: &securityContext,
Ports: getPorts(swift.ContainerServerPort, "container"),
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"/usr/bin/swift-container-server", "/etc/swift/container-server.conf", "-v"},
Command: []string{"/usr/bin/swift-container-server", "/etc/swift/container-server.conf.d", "-v"},
},
{
Name: "container-replicator",
Image: swiftstorage.Spec.ContainerImageContainer,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &securityContext,
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"/usr/bin/swift-container-replicator", "/etc/swift/container-server.conf", "-v"},
Command: []string{"/usr/bin/swift-container-replicator", "/etc/swift/container-server.conf.d", "-v"},
},
{
Name: "container-auditor",
Image: swiftstorage.Spec.ContainerImageContainer,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &securityContext,
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"/usr/bin/swift-container-replicator", "/etc/swift/container-server.conf", "-v"},
Command: []string{"/usr/bin/swift-container-replicator", "/etc/swift/container-server.conf.d", "-v"},
},
{
Name: "container-updater",
Image: swiftstorage.Spec.ContainerImageContainer,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &securityContext,
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"/usr/bin/swift-container-replicator", "/etc/swift/container-server.conf", "-v"},
Command: []string{"/usr/bin/swift-container-replicator", "/etc/swift/container-server.conf.d", "-v"},
},
{
Name: "object-server",
Expand All @@ -120,39 +120,39 @@ func getStorageContainers(swiftstorage *swiftv1beta1.SwiftStorage) []corev1.Cont
SecurityContext: &securityContext,
Ports: getPorts(swift.ObjectServerPort, "object"),
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"/usr/bin/swift-object-server", "/etc/swift/object-server.conf", "-v"},
Command: []string{"/usr/bin/swift-object-server", "/etc/swift/object-server.conf.d", "-v"},
},
{
Name: "object-replicator",
Image: swiftstorage.Spec.ContainerImageObject,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &securityContext,
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"/usr/bin/swift-object-replicator", "/etc/swift/object-server.conf", "-v"},
Command: []string{"/usr/bin/swift-object-replicator", "/etc/swift/object-server.conf.d", "-v"},
},
{
Name: "object-auditor",
Image: swiftstorage.Spec.ContainerImageObject,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &securityContext,
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"/usr/bin/swift-object-replicator", "/etc/swift/object-server.conf", "-v"},
Command: []string{"/usr/bin/swift-object-replicator", "/etc/swift/object-server.conf.d", "-v"},
},
{
Name: "object-updater",
Image: swiftstorage.Spec.ContainerImageObject,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &securityContext,
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"/usr/bin/swift-object-replicator", "/etc/swift/object-server.conf", "-v"},
Command: []string{"/usr/bin/swift-object-replicator", "/etc/swift/object-server.conf.d", "-v"},
},
{
Name: "object-expirer",
Image: swiftstorage.Spec.ContainerImageProxy,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &securityContext,
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"/usr/bin/swift-object-expirer", "/etc/swift/object-expirer.conf", "-v"},
Command: []string{"/usr/bin/swift-object-expirer", "/etc/swift/object-expirer.conf.d", "-v"},
},
{
Name: "rsync",
Expand All @@ -169,7 +169,7 @@ func getStorageContainers(swiftstorage *swiftv1beta1.SwiftStorage) []corev1.Cont
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &securityContext,
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"sh", "-c", "while true; do /usr/bin/swift-recon-cron /etc/swift/object-server.conf -v; sleep 300; done"},
Command: []string{"sh", "-c", "while true; do /usr/bin/swift-recon-cron /etc/swift/object-server.conf.d -v; sleep 300; done"},
},
}

Expand All @@ -180,7 +180,7 @@ func getStorageContainers(swiftstorage *swiftv1beta1.SwiftStorage) []corev1.Cont
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &securityContext,
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"/usr/bin/swift-container-sharder", "/etc/swift/container-server.conf", "-v"},
Command: []string{"/usr/bin/swift-container-sharder", "/etc/swift/container-server.conf.d", "-v"},
})
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/swiftstorage/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func ConfigMapTemplates(instance *swiftv1beta1.SwiftStorage, labels map[string]s
templateParameters := make(map[string]interface{})
templateParameters["MemcachedServers"] = memcachedServers

customData := map[string]string{}
for key, data := range instance.Spec.DefaultConfigOverwrite {
customData[key] = data
}

return []util.Template{
{
Name: fmt.Sprintf("%s-config-data", instance.Name),
Expand All @@ -34,6 +39,7 @@ func ConfigMapTemplates(instance *swiftv1beta1.SwiftStorage, labels map[string]s
InstanceType: instance.Kind,
Labels: labels,
ConfigOptions: templateParameters,
CustomData: customData,
},
{
Name: fmt.Sprintf("%s-scripts", instance.Name),
Expand Down
12 changes: 10 additions & 2 deletions templates/common/ring-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
TARFILE="/var/lib/config-data/rings/swiftrings.tar.gz"
MTIME="0"

# This is done only initially, should be done by Kolla probably
cp -t /etc/swift/ /var/lib/config-data/default/* /var/lib/config-data/swiftconf/*
# This is done only initially, will be done by Kolla eventually
mkdir /etc/swift/account-server.conf.d /etc/swift/container-server.conf.d /etc/swift/object-server.conf.d /etc/swift/object-expirer.conf.d /etc/swift/proxy-server.conf.d

cp -t /etc/swift/ /var/lib/config-data/swiftconf/swift.conf /var/lib/config-data/default/internal-client.conf /var/lib/config-data/default/rsyncd.conf

cp -t /etc/swift/account-server.conf.d/ /var/lib/config-data/default/*account-server*.conf
cp -t /etc/swift/container-server.conf.d/ /var/lib/config-data/default/*container-server*.conf
cp -t /etc/swift/object-server.conf.d/ /var/lib/config-data/default/*object-server*.conf
cp -t /etc/swift/object-expirer.conf.d/ /var/lib/config-data/default/*object-expirer*.conf
cp -t /etc/swift/proxy-server.conf.d/ /var/lib/config-data/default/*proxy-server*.conf

while true; do
if [ -e $TARFILE ] ; then
Expand Down
Loading

0 comments on commit a7018fa

Please sign in to comment.