-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding hwloc metric * hwloc should be system family Signed-off-by: vsoch <[email protected]>
- Loading branch information
Showing
14 changed files
with
265 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Hwloc Example | ||
|
||
Let's run an interactive metric with hwloc. | ||
|
||
## Usage | ||
|
||
Create a cluster and install JobSet to it. | ||
|
||
```bash | ||
kind create cluster | ||
VERSION=v0.2.0 | ||
kubectl apply --server-side -f https://github.com/kubernetes-sigs/jobset/releases/download/$VERSION/manifests.yaml | ||
``` | ||
|
||
Install the operator (from the development manifest here): | ||
|
||
```bash | ||
$ kubectl apply -f ../../dist/metrics-operator-dev.yaml | ||
``` | ||
|
||
How to see metrics operator logs: | ||
|
||
```bash | ||
$ kubectl logs -n metrics-system metrics-controller-manager-859c66464c-7rpbw | ||
``` | ||
|
||
Then create the metrics set. This is going to run lstopo and save the image application.png in the container root! | ||
Note that you can customize the command as an option "command" (e.g., to run something else). | ||
|
||
```bash | ||
kubectl apply -f metrics.yaml | ||
``` | ||
|
||
Wait until you see pods created by the job and then running (there should be one with two containers, one for the app lammps and the other for the stats): | ||
|
||
```bash | ||
kubectl get pods | ||
``` | ||
```diff | ||
NAME READY STATUS RESTARTS AGE | ||
- metricset-sample-m-0-0-mkwrh 0/1 ContainerCreating 0 2m20s | ||
+ metricset-sample-m-0-0-mkwrh 1/1 Running 0 3m10s | ||
``` | ||
|
||
This container doesn't have interesting logs unless your command generates output. For the default, we generate "application.png" and can | ||
save it here: | ||
|
||
```bash | ||
$ kubectl cp metricset-sample-m-0-0-9h7b7:/architecture.png architecture.png | ||
``` | ||
And there it is! | ||
|
||
![architecture.png](architecture.png) | ||
|
||
When you are done, cleanup! | ||
|
||
```bash | ||
kubectl delete -f metrics.yaml | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: flux-framework.org/v1alpha2 | ||
kind: MetricSet | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: metricset | ||
app.kubernetes.io/instance: metricset-sample | ||
name: metricset-sample | ||
spec: | ||
logging: | ||
interactive: true | ||
metrics: | ||
- name: sys-hwloc | ||
|
||
# These are the default and do not need to be provided | ||
listOptions: | ||
commands: | ||
- lstopo architecture.png | ||
- hwloc-ls machine.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
Copyright 2023 Lawrence Livermore National Security, LLC | ||
(c.f. AUTHORS, NOTICE.LLNS, COPYING) | ||
SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
package sys | ||
|
||
import ( | ||
"fmt" | ||
|
||
api "github.com/converged-computing/metrics-operator/api/v1alpha2" | ||
"github.com/converged-computing/metrics-operator/pkg/metadata" | ||
metrics "github.com/converged-computing/metrics-operator/pkg/metrics" | ||
"github.com/converged-computing/metrics-operator/pkg/specs" | ||
"k8s.io/apimachinery/pkg/util/intstr" | ||
) | ||
|
||
const ( | ||
hwlocIdentifier = "sys-hwloc" | ||
hwlocSummary = "install hwloc for inspecting hardware locality" | ||
hwlocContainer = "ghcr.io/converged-computing/metric-hwloc:latest" | ||
) | ||
|
||
type Hwloc struct { | ||
metrics.SingleApplication | ||
|
||
// Custom Options | ||
commands []string | ||
} | ||
|
||
func (m Hwloc) Url() string { | ||
return "https://www.open-mpi.org/projects/hwloc/tutorials/20120702-POA-hwloc-tutorial.html" | ||
} | ||
|
||
func (m *Hwloc) Famliy() string { | ||
return metrics.SystemFamily | ||
} | ||
|
||
// Set custom options / attributes for the metric | ||
func (m *Hwloc) SetOptions(metric *api.Metric) { | ||
|
||
m.Identifier = hwlocIdentifier | ||
m.Summary = hwlocSummary | ||
m.Container = hwlocContainer | ||
|
||
// Defaults for lstopo command | ||
m.ResourceSpec = &metric.Resources | ||
m.AttributeSpec = &metric.Attributes | ||
m.commands = []string{"lstopo architecture.png", "hwloc-ls machine.xml"} | ||
|
||
cmd, ok := metric.ListOptions["command"] | ||
if ok { | ||
m.commands = []string{} | ||
for _, val := range cmd { | ||
m.commands = append(m.commands, val.StrVal) | ||
} | ||
} | ||
} | ||
|
||
func (m Hwloc) ListOptions() map[string][]intstr.IntOrString { | ||
opts := map[string][]intstr.IntOrString{} | ||
for _, val := range m.commands { | ||
opts["commands"] = append(opts["commands"], intstr.FromString(val)) | ||
} | ||
return opts | ||
} | ||
|
||
func (m Hwloc) PrepareContainers( | ||
spec *api.MetricSet, | ||
metric *metrics.Metric, | ||
) []*specs.ContainerSpec { | ||
|
||
// Metadata to add to beginning of run | ||
meta := metrics.Metadata(spec, metric) | ||
|
||
// Assemble commands into separate things | ||
commands := "" | ||
for _, cmd := range m.commands { | ||
commands += fmt.Sprintf("\necho %s\n%s\n echo '%s'", cmd, cmd, metadata.Separator) | ||
} | ||
preBlock := `#!/bin/bash | ||
echo "%s" | ||
. /root/.profile | ||
export PATH=/opt/view/bin:$PATH | ||
echo "%s" | ||
%s | ||
echo "%s" | ||
ls | ||
` | ||
|
||
interactive := metadata.Interactive(spec.Spec.Logging.Interactive) | ||
preBlock = fmt.Sprintf( | ||
preBlock, | ||
meta, | ||
metadata.CollectionStart, | ||
commands, | ||
metadata.CollectionEnd, | ||
) | ||
postBlock := fmt.Sprintf("\n%s\n", interactive) | ||
return m.ApplicationContainerSpec(preBlock, "", postBlock) | ||
} | ||
|
||
func init() { | ||
base := metrics.BaseMetric{ | ||
Identifier: hwlocIdentifier, | ||
Summary: hwlocSummary, | ||
Container: hwlocContainer, | ||
} | ||
app := metrics.SingleApplication{BaseMetric: base} | ||
Hwloc := Hwloc{SingleApplication: app} | ||
metrics.Register(&Hwloc) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
Copyright 2023 Lawrence Livermore National Security, LLC | ||
(c.f. AUTHORS, NOTICE.LLNS, COPYING) | ||
SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
package sys | ||
|
||
import ( | ||
"log" | ||
|
||
"go.uber.org/zap" | ||
) | ||
|
||
// Consistent logging identifiers that should be echoed to have newline after | ||
var ( | ||
handle *zap.Logger | ||
logger *zap.SugaredLogger | ||
) | ||
|
||
func init() { | ||
handle, err := zap.NewProduction() | ||
if err != nil { | ||
log.Fatalf("can't initialize zap logger: %v", err) | ||
} | ||
logger = handle.Sugar() | ||
defer handle.Sync() | ||
} |