Skip to content

Commit

Permalink
Merge pull request #104 from cschwede/run-container-sharder
Browse files Browse the repository at this point in the history
Run container-sharder
  • Loading branch information
cschwede authored Feb 2, 2024
2 parents 1f31bfa + 4809676 commit e08e718
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api/bases/swift.openstack.org_swifts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ spec:
containerImageProxy:
description: Image URL for Swift proxy service
type: string
containerSharderEnabled:
default: false
description: If the container sharder daemon is enabled.
type: boolean
memcachedServers:
default: ""
description: List of memcached servers.
Expand Down
4 changes: 4 additions & 0 deletions api/bases/swift.openstack.org_swiftstorages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ spec:
containerImageProxy:
description: Image URL for Swift proxy service
type: string
containerSharderEnabled:
default: false
description: If the container sharder daemon is enabled.
type: boolean
memcachedServers:
default: ""
description: List of memcached servers.
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta1/swiftstorage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ type SwiftStorageSpec struct {
// +kubebuilder:default=""
// List of memcached servers.
MemcachedServers string `json:"memcachedServers"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=false
// If the container sharder daemon is enabled.
ContainerSharderEnabled bool `json:"containerSharderEnabled"`
}

// SwiftStorageStatus defines the observed state of SwiftStorage
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/swift.openstack.org_swifts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ spec:
containerImageProxy:
description: Image URL for Swift proxy service
type: string
containerSharderEnabled:
default: false
description: If the container sharder daemon is enabled.
type: boolean
memcachedServers:
default: ""
description: List of memcached servers.
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/swift.openstack.org_swiftstorages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ spec:
containerImageProxy:
description: Image URL for Swift proxy service
type: string
containerSharderEnabled:
default: false
description: If the container sharder daemon is enabled.
type: boolean
memcachedServers:
default: ""
description: List of memcached servers.
Expand Down
1 change: 1 addition & 0 deletions controllers/swift_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ func (r *SwiftReconciler) storageCreateOrUpdate(ctx context.Context, instance *s
SwiftConfSecret: instance.Spec.SwiftConfSecret,
NetworkAttachments: instance.Spec.SwiftStorage.NetworkAttachments,
MemcachedServers: memcachedServers,
ContainerSharderEnabled: instance.Spec.SwiftStorage.ContainerSharderEnabled,
}

deployment := &swiftv1.SwiftStorage{
Expand Down
15 changes: 14 additions & 1 deletion pkg/swiftstorage/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func getPorts(port int32, name string) []corev1.ContainerPort {
func getStorageContainers(swiftstorage *swiftv1beta1.SwiftStorage) []corev1.Container {
securityContext := swift.GetSecurityContext()

return []corev1.Container{
containers := []corev1.Container{
{
Name: "ring-sync",
Image: swiftstorage.Spec.ContainerImageProxy,
Expand Down Expand Up @@ -172,6 +172,19 @@ func getStorageContainers(swiftstorage *swiftv1beta1.SwiftStorage) []corev1.Cont
Command: []string{"sh", "-c", "while true; do /usr/bin/swift-recon-cron /etc/swift/object-server.conf -v; sleep 300; done"},
},
}

if swiftstorage.Spec.ContainerSharderEnabled {
containers = append(containers, corev1.Container{
Name: "container-sharder",
Image: swiftstorage.Spec.ContainerImageContainer,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &securityContext,
VolumeMounts: getStorageVolumeMounts(),
Command: []string{"/usr/bin/swift-container-sharder", "/etc/swift/container-server.conf", "-v"},
})
}

return containers
}

func StatefulSet(
Expand Down
2 changes: 2 additions & 0 deletions templates/swiftstorage/config/container-server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ use = egg:swift#recon

[container-sync]

[container-sharder]

[filter:xprofile]
use = egg:swift#xprofile
20 changes: 20 additions & 0 deletions templates/swiftstorage/config/internal-client.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[DEFAULT]

[pipeline:main]
pipeline = catch_errors proxy-logging cache symlink proxy-server

[app:proxy-server]
use = egg:swift#proxy
account_autocreate = true

[filter:symlink]
use = egg:swift#symlink

[filter:cache]
use = egg:swift#memcache

[filter:proxy-logging]
use = egg:swift#proxy_logging

[filter:catch_errors]
use = egg:swift#catch_errors

0 comments on commit e08e718

Please sign in to comment.