Skip to content

Commit

Permalink
core: enable annotations on crash collector
Browse files Browse the repository at this point in the history
The crash collector daemon had missed the ability to
add custom annotations via the cephcluster CR, as already
supported for all the other daemons.

Signed-off-by: Travis Nielsen <[email protected]>
  • Loading branch information
travisn committed Sep 17, 2024
1 parent 2787733 commit fa2941d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions pkg/apis/ceph.rook.io/v1/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ func GetCmdReporterAnnotations(a AnnotationsSpec) Annotations {
return mergeAllAnnotationsWithKey(a, KeyCmdReporter)
}

// GetCrashCollectorAnnotations returns the Annotations for the crash collector
func GetCrashCollectorAnnotations(a AnnotationsSpec) Annotations {
return mergeAllAnnotationsWithKey(a, KeyCrashCollector)
}

func GetClusterMetadataAnnotations(a AnnotationsSpec) Annotations {
return a[KeyClusterMetadata]
}
Expand Down
11 changes: 8 additions & 3 deletions pkg/apis/ceph.rook.io/v1/annotations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ func TestCephAnnotationsMerge(t *testing.T) {

// Merge with "all"
testAnnotations = AnnotationsSpec{
"all": {"allkey1": "allval1", "allkey2": "allval2"},
"mgr": {"mgrkey": "mgrval"},
"cmdreporter": {"myversions": "detect"},
"all": {"allkey1": "allval1", "allkey2": "allval2"},
"mgr": {"mgrkey": "mgrval"},
"cmdreporter": {"myversions": "detect"},
"crashcollector": {"crash": "crashval"},
}
a = GetMonAnnotations(testAnnotations)
assert.Equal(t, "allval1", a["allkey1"])
Expand All @@ -75,6 +76,10 @@ func TestCephAnnotationsMerge(t *testing.T) {
assert.Equal(t, "detect", b["myversions"])
assert.Equal(t, "allval1", b["allkey1"])
assert.Equal(t, "allval2", b["allkey2"])
c := GetCrashCollectorAnnotations(testAnnotations)
assert.Equal(t, "crashval", c["crash"])
assert.Equal(t, "allval1", c["allkey1"])
assert.Equal(t, "allval2", c["allkey2"])
}

func TestAnnotationsSpec(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions pkg/operator/ceph/cluster/nodedaemon/crash.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (r *ReconcileNode) createOrUpdateCephCrash(node corev1.Node, tolerations []
ServiceAccountName: k8sutil.DefaultServiceAccount,
},
}
cephv1.GetCrashCollectorAnnotations(cephCluster.Spec.Annotations).ApplyToObjectMeta(&deploy.Spec.Template.ObjectMeta)

return nil
}
Expand Down

0 comments on commit fa2941d

Please sign in to comment.