Skip to content

Commit

Permalink
ceph: fixing ClientID of log-collector for RGW instance
Browse files Browse the repository at this point in the history
The Client_ID generated by operator was
different from the log rotate file created
The Clinet_ID= rgwceph.client.rook.ceph.rgw.my.store.a
and log file name= ceph-client.rgw.my.store.a.log
So changed the CLient_ID to ceph-client.rgw.my.store.a for
correct working and this follow the patterns how other modules
Client_ID is generated

Closes: #8692
Signed-off-by: parth-gr <paarora@redhat.com>
  • Loading branch information
parth-gr committed Oct 7, 2021
1 parent 08cb678 commit aa9c6b8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/operator/ceph/object/spec.go
Expand Up @@ -111,7 +111,7 @@ func (c *clusterConfig) makeRGWPodSpec(rgwConfig *rgwConfig) (v1.PodTemplateSpec
if c.clusterSpec.LogCollector.Enabled {
shareProcessNamespace := true
podSpec.ShareProcessNamespace = &shareProcessNamespace
podSpec.Containers = append(podSpec.Containers, *controller.LogCollectorContainer(strings.TrimPrefix(generateCephXUser(fmt.Sprintf("ceph-client.%s", rgwConfig.ResourceName)), "client."), c.clusterInfo.Namespace, *c.clusterSpec))
podSpec.Containers = append(podSpec.Containers, *controller.LogCollectorContainer(getDaemonName(rgwConfig), c.clusterInfo.Namespace, *c.clusterSpec))
}

// Replace default unreachable node toleration
Expand Down Expand Up @@ -611,3 +611,7 @@ func (c *clusterConfig) rgwTLSSecretType(secretName string) (v1.SecretType, erro
}
return "", errors.Wrapf(err, "no Kubernetes secrets referring TLS certificates found")
}

func getDaemonName(rgwConfig *rgwConfig) string {
return fmt.Sprintf("ceph-%s", generateCephXUser(rgwConfig.ResourceName))
}
30 changes: 30 additions & 0 deletions pkg/operator/ceph/object/spec_test.go
Expand Up @@ -379,3 +379,33 @@ func TestCheckRGWKMS(t *testing.T) {
assert.True(t, b)
assert.NoError(t, err)
}

func TestGetDaemonName(t *testing.T) {
context := &clusterd.Context{Clientset: test.New(t, 3)}
store := simpleStore()
tests := []struct {
storeName string
testDaemonName string
daemonID string
}{
{"default", "ceph-client.rgw.default.a", "a"},
{"my-store", "ceph-client.rgw.my.store.b", "b"},
}
for _, tt := range tests {
t.Run(tt.storeName, func(t *testing.T) {
c := &clusterConfig{
context: context,
store: store,
}
c.store.Name = tt.storeName
daemonName := fmt.Sprintf("%s-%s", c.store.Name, tt.daemonID)
resourceName := fmt.Sprintf("%s-%s", AppName, daemonName)
rgwconfig := &rgwConfig{
ResourceName: resourceName,
DaemonID: daemonName,
}
daemon := getDaemonName(rgwconfig)
assert.Equal(t, tt.testDaemonName, daemon)
})
}
}

0 comments on commit aa9c6b8

Please sign in to comment.