Skip to content

Commit

Permalink
feat: allow custom hostlist and main host
Browse files Browse the repository at this point in the history
Problem: to support hostNetwork we need to be able to customize
the hostlist and the main hostname.
Solution: expose these (along with hostNetwork and others) to
the MiniCluster CRD

Signed-off-by: vsoch <[email protected]>
  • Loading branch information
vsoch committed Aug 16, 2024
1 parent a7fce05 commit 11c9d68
Show file tree
Hide file tree
Showing 69 changed files with 3,187 additions and 6,141 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ api: generate api
go run hack/python-sdk/main.go ${API_VERSION} > ${SWAGGER_API_JSON}
rm -rf ./sdk/python/${API_VERSION}/fluxoperator/model/*
rm -rf ./sdk/python/${API_VERSION}/fluxoperator/test/test_*.py
java -jar ${SWAGGER_JAR} generate -i ${SWAGGER_API_JSON} -g python-legacy -o ./sdk/python/${API_VERSION} -c ./hack/python-sdk/swagger_config.json --git-repo-id flux-operator --git-user-id flux-framework
java -jar ${SWAGGER_JAR} generate -i ${SWAGGER_API_JSON} -g python -o ./sdk/python/${API_VERSION} -c ./hack/python-sdk/swagger_config.json --git-repo-id flux-operator --git-user-id flux-framework

# These were needed for the python (not python-legacy)
# cp ./hack/python-sdk/fluxoperator/* ./sdk/python/${API_VERSION}/fluxoperator/model/
Expand Down
24 changes: 24 additions & 0 deletions api/v1alpha2/minicluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ type PodSpec struct {
// Resources include limits and requests
// +optional
Resources ContainerResource `json:"resources"`

// Security
// +optional
HostIPC bool `json:"hostIPC,omitempty"`

// +optional
HostNetwork bool `json:"hostNetwork,omitempty"`
}

// MiniClusterStatus defines the observed state of Flux
Expand Down Expand Up @@ -316,6 +323,10 @@ type FluxSpec struct {
// +optional
NoWaitSocket bool `json:"noWaitSocket"`

// Provide a custom hostlist - useful if hostNetwork is set to true
// +optional
Hostlist string `json:"hostlist"`

// Complete workers when they fail
// This is ideal if you don't want them to restart
// +optional
Expand Down Expand Up @@ -354,6 +365,10 @@ type FluxSpec struct {
// this is intended for bursting to remote clusters
//+optional
BrokerConfig string `json:"brokerConfig"`

// If a different primary host is indicated
//+optional
MainHost string `json:"mainHost"`
}

// FluxScheduler attributes
Expand Down Expand Up @@ -706,6 +721,15 @@ func (f *MiniCluster) EntrypointConfigMapName() string {
return f.Name + entrypointSuffix
}

// MainHost returns the main Hostname of the cluster
func (f *MiniCluster) MainHost() string {
mainHost := fmt.Sprintf("%s-0", f.Name)
if f.Spec.Flux.MainHost != "" {
mainHost = f.Spec.Flux.MainHost
}
return mainHost
}

// Validate ensures we have data that is needed, and sets defaults if needed
func (f *MiniCluster) Validate() bool {
fmt.Println()
Expand Down
17 changes: 17 additions & 0 deletions api/v1alpha2/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,22 @@
"type": "string",
"default": ""
},
"hostlist": {
"description": "Provide a custom hostlist - useful if hostNetwork is set to true",
"type": "string",
"default": ""
},
"logLevel": {
"description": "Log level to use for flux logging (only in non TestMode)",
"type": "integer",
"format": "int32",
"default": 6
},
"mainHost": {
"description": "If a different primary host is indicated",
"type": "string",
"default": ""
},
"minimalService": {
"description": "Only expose the broker service (to reduce load on DNS)",
"type": "boolean",
Expand Down Expand Up @@ -748,6 +758,13 @@
"description": "Automatically mount the service account name",
"type": "boolean"
},
"hostIPC": {
"description": "Security",
"type": "boolean"
},
"hostNetwork": {
"type": "boolean"
},
"labels": {
"description": "Labels for each pod",
"type": "object",
Expand Down
29 changes: 29 additions & 0 deletions api/v1alpha2/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions chart/templates/minicluster-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,18 @@ spec:
This is not recommended in favor of providing the secret
name as curveCertSecret, below
type: string
hostlist:
description: Provide a custom hostlist - useful if hostNetwork is
set to true
type: string
logLevel:
default: 6
description: Log level to use for flux logging (only in non TestMode)
format: int32
type: integer
mainHost:
description: If a different primary host is indicated
type: string
minimalService:
description: Only expose the broker service (to reduce load on DNS)
type: boolean
Expand Down Expand Up @@ -534,6 +541,11 @@ spec:
automountServiceAccountToken:
description: Automatically mount the service account name
type: boolean
hostIPC:
description: Security
type: boolean
hostNetwork:
type: boolean
labels:
additionalProperties:
type: string
Expand Down
12 changes: 12 additions & 0 deletions config/crd/bases/flux-framework.org_miniclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,18 @@ spec:
This is not recommended in favor of providing the secret
name as curveCertSecret, below
type: string
hostlist:
description: Provide a custom hostlist - useful if hostNetwork
is set to true
type: string
logLevel:
default: 6
description: Log level to use for flux logging (only in non TestMode)
format: int32
type: integer
mainHost:
description: If a different primary host is indicated
type: string
minimalService:
description: Only expose the broker service (to reduce load on
DNS)
Expand Down Expand Up @@ -537,6 +544,11 @@ spec:
automountServiceAccountToken:
description: Automatically mount the service account name
type: boolean
hostIPC:
description: Security
type: boolean
hostNetwork:
type: boolean
labels:
additionalProperties:
type: string
Expand Down
2 changes: 2 additions & 0 deletions controllers/flux/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func NewMiniClusterJob(cluster *api.MiniCluster) (*batchv1.Job, error) {
RestartPolicy: corev1.RestartPolicyOnFailure,
NodeSelector: cluster.Spec.Pod.NodeSelector,
SchedulerName: cluster.Spec.Pod.SchedulerName,
HostIPC: cluster.Spec.Pod.HostIPC,
HostNetwork: cluster.Spec.Pod.HostNetwork,
},
},
},
Expand Down
12 changes: 12 additions & 0 deletions examples/dist/flux-operator-arm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,18 @@ spec:
This is not recommended in favor of providing the secret
name as curveCertSecret, below
type: string
hostlist:
description: Provide a custom hostlist - useful if hostNetwork
is set to true
type: string
logLevel:
default: 6
description: Log level to use for flux logging (only in non TestMode)
format: int32
type: integer
mainHost:
description: If a different primary host is indicated
type: string
minimalService:
description: Only expose the broker service (to reduce load on
DNS)
Expand Down Expand Up @@ -543,6 +550,11 @@ spec:
automountServiceAccountToken:
description: Automatically mount the service account name
type: boolean
hostIPC:
description: Security
type: boolean
hostNetwork:
type: boolean
labels:
additionalProperties:
type: string
Expand Down
12 changes: 12 additions & 0 deletions examples/dist/flux-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,18 @@ spec:
This is not recommended in favor of providing the secret
name as curveCertSecret, below
type: string
hostlist:
description: Provide a custom hostlist - useful if hostNetwork
is set to true
type: string
logLevel:
default: 6
description: Log level to use for flux logging (only in non TestMode)
format: int32
type: integer
mainHost:
description: If a different primary host is indicated
type: string
minimalService:
description: Only expose the broker service (to reduce load on
DNS)
Expand Down Expand Up @@ -543,6 +550,11 @@ spec:
automountServiceAccountToken:
description: Automatically mount the service account name
type: boolean
hostIPC:
description: Security
type: boolean
hostNetwork:
type: boolean
labels:
additionalProperties:
type: string
Expand Down
6 changes: 6 additions & 0 deletions pkg/flux/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ func getRandomToken(requested string) string {
func generateHostlist(cluster *api.MiniCluster, size int32) string {

var hosts string

// If we are given a hostlist, just return it
if cluster.Spec.Flux.Hostlist != "" {
return cluster.Spec.Flux.Hostlist
}

if cluster.Spec.Flux.Bursting.Hostlist != "" {

// In case 1, we are given a custom hostlist
Expand Down
3 changes: 1 addition & 2 deletions pkg/flux/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func generateEntrypointScript(
) (string, error) {

container := cluster.Spec.Containers[containerIndex]
mainHost := fmt.Sprintf("%s-0", cluster.Name)

// Ensure if we have a batch command, it gets split up
batchCommand := strings.Split(container.Command, "\n")
Expand All @@ -102,7 +101,7 @@ func generateEntrypointScript(
RequiredRanks: requiredRanks,
ViewBase: cluster.Spec.Flux.Container.MountPath,
Container: container,
MainHost: mainHost,
MainHost: cluster.MainHost(),
Spec: cluster.Spec,
Batch: batchCommand,
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/flux/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func generateHostBlock(hosts string, cluster *api.MiniCluster) string {
// Unless we have a bursting broker address
if cluster.Spec.Flux.Bursting.LeadBroker.Address != "" {

hostTemplate = `hosts = [{host="%s", bind="tcp://eth0:%s", connect="tcp://%s:%s"},
hostTemplate = `hosts = [{host="%s", bind="tcp://eth0:%d", connect="tcp://%s:%d"},
{host="%s"}]`

hostBlock = fmt.Sprintf(
Expand All @@ -38,6 +38,7 @@ func generateHostBlock(hosts string, cluster *api.MiniCluster) string {
cluster.Spec.Flux.Bursting.LeadBroker.Port,
cluster.Spec.Flux.Bursting.LeadBroker.Address,
cluster.Spec.Flux.Bursting.LeadBroker.Port,
hosts,
)
}
return hostBlock
Expand Down Expand Up @@ -103,7 +104,8 @@ func GenerateFluxEntrypoint(cluster *api.MiniCluster) (string, error) {
// github.com:converged-computing/flux-views.git
fluxRoot := "/opt/view"

mainHost := fmt.Sprintf("%s-0", cluster.Name)
// Get the main host, either cluster name or custom
mainHost := cluster.MainHost()

// Generate hostlists, this is the lead broker
hosts := generateHostlist(cluster, cluster.Spec.MaxSize)
Expand Down
38 changes: 18 additions & 20 deletions sdk/python/v1alpha2/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
# NOTE: This file is auto generated by OpenAPI Generator.
# URL: https://openapi-generator.tech
#
# ref: https://docs.gitlab.com/ee/ci/README.html
# ref: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml

stages:
- test

.nosetest:
.pytest:
stage: test
script:
- pip install -r requirements.txt
- pip install -r test-requirements.txt
- pytest --cov=fluxoperator

nosetest-2.7:
extends: .nosetest
image: python:2.7-alpine
nosetest-3.3:
extends: .nosetest
image: python:3.3-alpine
nosetest-3.4:
extends: .nosetest
image: python:3.4-alpine
nosetest-3.5:
extends: .nosetest
image: python:3.5-alpine
nosetest-3.6:
extends: .nosetest
image: python:3.6-alpine
nosetest-3.7:
extends: .nosetest
pytest-3.7:
extends: .pytest
image: python:3.7-alpine
nosetest-3.8:
extends: .nosetest
pytest-3.8:
extends: .pytest
image: python:3.8-alpine
pytest-3.9:
extends: .pytest
image: python:3.9-alpine
pytest-3.10:
extends: .pytest
image: python:3.10-alpine
pytest-3.11:
extends: .pytest
image: python:3.11-alpine
Loading

0 comments on commit 11c9d68

Please sign in to comment.