Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/update-citation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ jobs:
# to push the changes to remote
- uses: actions/create-github-app-token@v3
id: app-token
if: steps.verify-changed-files.outputs.files_changed == 'true' && github.ref == 'refs/heads/main'
if: steps.verify-changed-files.outputs.files_changed == 'true' && github.ref_type == 'tag'
with:
client-id: 4221824
private-key: ${{ secrets.APP_UPDATE_README_HELPER_PRIVATE_KEY }}

- name: Commit changes
if: steps.verify-changed-files.outputs.files_changed == 'true' && github.ref == 'refs/heads/main'
if: steps.verify-changed-files.outputs.files_changed == 'true' && github.ref_type == 'tag'
run: |
git config --local user.email "bot@ceems.com"
git config --local user.name "CEEMS bot"
git add CITATION.cff
git commit -m "chore: Update version in CITATION.cff" -s

- name: Push changes
if: steps.verify-changed-files.outputs.files_changed == 'true' && github.ref == 'refs/heads/main'
if: steps.verify-changed-files.outputs.files_changed == 'true' && github.ref_type == 'tag'
uses: ad-m/github-push-action@master
with:
github_token: ${{ steps.app-token.outputs.token }}
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Installation instructions of CEEMS components can be found in

## 📽️ Demo

<p><a href="https://ceems-demo.myaddr.tools" target="_blank">
<p><a href="https://demo.ceems.dev" target="_blank">
<img src="https://raw.githubusercontent.com/ceems-dev/ceems/main/website/static/img/dashboards/demo_screenshot.png" alt="Access Demo">
</a></p>

Expand All @@ -70,12 +70,12 @@ consumption is estimated by assuming a Thermal Design Power (TDP) value and curr
usage of the instance. Several dashboards have been created in Grafana for visualizing
metrics which are listed below.

- [Overall usage of cluster](https://ceems-demo.myaddr.tools/d/adrenju36n2tcb/cluster-status?orgId=1&from=now-1h&to=now&timezone=browser&var-job=slurm&var-provider=rte&var-country_code=FR&refresh=15m)
- [Usage of different Projects/Accounts by SLURM and Openstack](https://ceems-demo.myaddr.tools/d/cdreu45pp9erkd/user-and-project-stats?orgId=1&from=now-90d&to=now&timezone=browser&refresh=15m)
- [Usage of Openstack resources by a given user and project](https://ceems-demo.myaddr.tools/d/be5x3it7gpx4wf/user-openstack-vm-summary?orgId=1&from=now-90d&to=now&timezone=browser&var-user=pebbles&var-account=bedrock&var-provider=rte)
- [Usage of k8s resources by a given user and project](https://ceems-demo.myaddr.tools/d/eethlvcs613wgf/user-k8s-pods-summary?orgId=1&from=now-90d&to=now&timezone=browser&var-user=bedrock:unknown&var-account=bedrock&var-provider=rte)
- [Usage of SLURM resources by a given user and project](https://ceems-demo.myaddr.tools/d/slurm-job-summary/user-slurm-job-summary?orgId=1&from=now-90d&to=now&timezone=browser&var-user=arnold&var-account=bedrock&var-provider=rte)
- [Usage of LSF resources by a given user and project](https://ceems-demo.myaddr.tools/d/lsf-job-summary/user-lsf-job-summary?orgId=1&from=now-90d&to=now&timezone=browser&var-user=barney&var-account=bedrock&var-provider=owid)
- [Overall usage of cluster](https://demo.ceems.dev/grafana/d/adrenju36n2tcb/cluster-status?orgId=1&from=now-1h&to=now&timezone=browser&var-job=slurm&var-provider=rte&var-country_code=FR&refresh=15m)
- [Usage of different Projects/Accounts by SLURM and Openstack](https://demo.ceems.dev/grafana/d/cdreu45pp9erkd/user-and-project-stats?orgId=1&from=now-90d&to=now&timezone=browser&refresh=15m)
- [Usage of Openstack resources by a given user and project](https://demo.ceems.dev/grafana/d/be5x3it7gpx4wf/user-openstack-vm-summary?orgId=1&from=now-90d&to=now&timezone=browser&var-user=pebbles&var-account=bedrock&var-provider=rte)
- [Usage of k8s resources by a given user and project](https://demo.ceems.dev/grafana/d/eethlvcs613wgf/user-k8s-pods-summary?orgId=1&from=now-90d&to=now&timezone=browser&var-user=bedrock:unknown&var-account=bedrock&var-provider=rte)
- [Usage of SLURM resources by a given user and project](https://demo.ceems.dev/grafana/d/slurm-job-summary/user-slurm-job-summary?orgId=1&from=now-90d&to=now&timezone=browser&var-user=arnold&var-account=bedrock&var-provider=rte)
- [Usage of LSF resources by a given user and project](https://demo.ceems.dev/grafana/d/lsf-job-summary/user-lsf-job-summary?orgId=1&from=now-90d&to=now&timezone=browser&var-user=barney&var-account=bedrock&var-provider=owid)

> [!WARNING]
> All the dashboards provided in the demo instance are only meant to be for demonstrative
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/ceems-dev/perf-utils v0.0.0-20250716113832-99ba71e88ef4
github.com/cilium/ebpf v0.22.0
github.com/containerd/cgroups/v3 v3.1.3
github.com/felixge/fgprof v0.9.5
github.com/go-chi/chi/v5 v5.5.0
github.com/go-chi/httprate v0.16.1
github.com/go-kit/log v0.2.1
Expand Down
19 changes: 19 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ github.com/ceems-dev/pyroscope/ebpf v0.4.12-0.20260907155142-b0d0b2f6973b h1:vvo
github.com/ceems-dev/pyroscope/ebpf v0.4.12-0.20260907155142-b0d0b2f6973b/go.mod h1:6D5qcb97IPmyOAB8DOS58WMTTEI/g9Qw/AZlWoVaBHw=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chromedp/cdproto v0.0.0-20230802225258-3cf4e6d46a89/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs=
github.com/chromedp/chromedp v0.9.2/go.mod h1:LkSXJKONWTCHAfQasKFUZI+mxqS4tZqhmtGzzhLsnLs=
github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww=
github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ=
github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk=
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
github.com/cilium/ebpf v0.22.0 h1:v2ktp0roffpMOj2MMf3idtCQZOsAoC4BJbAJN+ke2bY=
github.com/cilium/ebpf v0.22.0/go.mod h1:CDzZbe2hC5JjlDC+CY3KFCzlYwN4gbxppYM+Z10bQt4=
github.com/containerd/cgroups/v3 v3.1.3 h1:eUNflyMddm18+yrDmZPn3jI7C5hJ9ahABE5q6dyLYXQ=
Expand All @@ -36,6 +42,8 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes=
github.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/felixge/fgprof v0.9.5 h1:8+vR6yu2vvSKn08urWyEuxx75NWPEvybbkBirEpsbVY=
github.com/felixge/fgprof v0.9.5/go.mod h1:yKl+ERSa++RYOs32d8K6WEXCB4uXdLls4ZaZPpayhMM=
github.com/fxamacker/cbor/v2 v2.9.1 h1:2rWm8B193Ll4VdjsJY28jxs70IdDsHRWgQYAI80+rMQ=
github.com/fxamacker/cbor/v2 v2.9.1/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
github.com/go-chi/chi/v5 v5.5.0 h1:xdKQ1dJmVJsmgahrXSKhUx8NyVPzpwdlyrrQFpMPJgg=
Expand Down Expand Up @@ -86,6 +94,9 @@ github.com/go-openapi/testify/v2 v2.6.0 h1:5PKH2HE7YJ/LuRPQGvSxBRlFXNQhSetBLlGAg
github.com/go-openapi/testify/v2 v2.6.0/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw=
github.com/go-quicktest/qt v1.101.1-0.20240301121107-c6c8733fa1e6 h1:teYtXy9B7y5lHTp8V9KPxpYRAVA7dozigQcMiBust1s=
github.com/go-quicktest/qt v1.101.1-0.20240301121107-c6c8733fa1e6/go.mod h1:p4lGIVX+8Wa6ZPNDvqcxq36XpUDLh42FLetFU7odllI=
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
Expand All @@ -101,6 +112,7 @@ github.com/google/gnostic-models v0.7.1/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7O
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
github.com/google/pprof v0.0.0-20260906184651-6331bc6350fe h1:QAinXoAFJdGQYztXn3VpFey7KCwpedbZ/EkzbplQ0cY=
github.com/google/pprof v0.0.0-20260906184651-6331bc6350fe/go.mod h1:jl5iWTm0/hd5PjEYEOuwAJ57L/CibdZfrqZ5XA5GrCk=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
Expand All @@ -117,12 +129,14 @@ github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
github.com/ianlancetaylor/demangle v0.0.0-20251118225945-96ee0021ea0f h1:Fnl4pzx8SR7k7JuzyW8lEtSFH6EQ8xgcypgIn8pcGIE=
github.com/ianlancetaylor/demangle v0.0.0-20251118225945-96ee0021ea0f/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
github.com/jedib0t/go-pretty/v6 v6.8.3 h1:yVSk5aemoYHCvcrtqyXklwqcgHQIQzmy/oUzFlmffSQ=
github.com/jedib0t/go-pretty/v6 v6.8.3/go.mod h1:YwC5CE4fJ1HFUDeivSV1r//AmANFHyqczZk+U6BDALU=
github.com/jellydator/ttlcache/v3 v3.4.1 h1:bOdXmXiycyK6E6Qjyuj5vl+/vU3SCOoDs8a86NbHjAQ=
github.com/jellydator/ttlcache/v3 v3.4.1/go.mod h1:j7LO12PNghFg5+0v9budMAT4rDK4JY969jb9vOdOBBk=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=
Expand All @@ -141,8 +155,10 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1yfhB7XSJJKlFZKl/J+dCPAknuiaGOshXAs=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.52 h1:wVbm2Qnf4OXkqhBTSPuCRZDRnxfbVrrmiCEroVdog8U=
Expand All @@ -169,6 +185,7 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg=
github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/planetscale/vtprotobuf v0.6.1-0.20250313105119-ba97887b0a25 h1:S1hI5JiKP7883xBzZAr1ydcxrKNSVNm7+3+JwjxZEsg=
Expand Down Expand Up @@ -255,6 +272,8 @@ golang.org/x/oauth2 v0.37.0/go.mod h1:IxwZNxUULJmpBFf9K/9NTMSIfZZuvuTy1gGxhigP/5
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
golang.org/x/term v0.47.0 h1:cpyOwQkr2Nzxe2p6KnrTG7Ei2wtzjsuSjhpXXepZ/BM=
Expand Down
54 changes: 51 additions & 3 deletions internal/security/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import (
"os"
"os/user"
"path/filepath"
"regexp"
"slices"
"strconv"
"syscall"

"github.com/ceems-dev/ceems/internal/osexec"
"github.com/steiler/acls"
"github.com/wneessen/go-fileperm"
"kernel.org/pub/linux/libs/security/libcap/cap"
Expand All @@ -22,6 +24,9 @@ const (
deleteACLCtx = "delete_acl_entries"
)

// Systemd regex matcher.
var systemdVersionRegex = regexp.MustCompile(`(?m)systemd\s(\d+)`)

type deleteACLEntriesCtxData struct {
acls []acl
}
Expand All @@ -46,6 +51,7 @@ type Manager struct {
caps []cap.Value
acls []acl
securityContexts map[string]*SecurityContext
systemctlBinPath string
}

// NewManager returns a new instance of security manager.
Expand All @@ -54,8 +60,9 @@ func NewManager(c *Config, logger *slog.Logger) (*Manager, error) {

// Start a new instance of manager
manager := &Manager{
logger: logger,
caps: c.Caps,
logger: logger,
caps: c.Caps,
systemctlBinPath: "systemctl",
}

// Get current user
Expand Down Expand Up @@ -221,7 +228,7 @@ func (m *Manager) DropPrivileges(enableEffective bool) error {
// Get if the current process has any capabilities at all
// by comparing against a new capability set
// If no capabilities found, nothing to do, return
isPriv, err := existing.Cf(cap.NewSet())
isPriv, err := existing.Cf(m.defaultCaps())
if err == nil && isPriv == 0 {
return nil
}
Expand Down Expand Up @@ -368,6 +375,47 @@ func (m *Manager) pathsReachable() error {
return nil
}

// defaultCaps returns default capabilities a process should have. As of systemd >= 254,
// desktop environments will have cap_wake_alarm=i by default.
// Ref: https://github.com/systemd/systemd/issues/41386
func (m *Manager) defaultCaps() *cap.Set {
// Get systemd version
output, err := osexec.ExecuteWithTimeout(m.systemctlBinPath, []string{"--version"}, 2, nil)
if err != nil {
m.logger.Warn("Failed to get systemd version", "err", err)

return cap.NewSet()
}

// Find matches
matches := systemdVersionRegex.FindStringSubmatch(string(output))
if len(matches) == 2 {
// Convert version string to int
val, err := strconv.ParseInt(matches[1], 10, 64)
if err == nil {
// If systemd version is >= 254 and if we are in desktop environment, there
// will be cap_wake_alaram by default.
// This can happen when running with systemctl --user mode. But this is a
// edge case and there is no reason for people to run ceems_api_server
// in that mode.
// To detect if we are in headless or Desktop mode, use XDG_SESSION_DESKTOP
// which is more realiable than DISPLAY.
// Ref: https://superuser.com/questions/1074068/what-is-the-difference-between-desktop-session-xdg-session-desktop-and-xdg-cur/1643180#1643180
// Ref: https://www.freedesktop.org/software/systemd/man/latest/pam_systemd.html
if val >= 254 && os.Getenv("XDG_SESSION_DESKTOP") != "" {
capSet, err := cap.FromText("cap_wake_alarm=i")
if err == nil {
return capSet
}

return cap.NewSet()
}
}
}

return cap.NewSet()
}

// DropCapabilities drops any existing capabilities on the process.
func DropCapabilities() error {
return setCapabilities(nil, false)
Expand Down
Loading
Loading