Skip to content

Commit

Permalink
updates to manifest to remove broker
Browse files Browse the repository at this point in the history
the broker is entirely internally generated (for the time being)
so we do not need to expose anything in the custom resource for
the admin user to modify

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Aug 31, 2022
1 parent 618af25 commit 503347e
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 32 deletions.
4 changes: 0 additions & 4 deletions api/v1alpha1/fluxsetup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ type FluxSetupSpec struct {

// THe hostfile ConfigMap etc-hosts
EtcHosts FluxHostConfig `json:"etc-hosts"`

// Broker with a hostfile for flux-config
Broker FluxHostConfig `json:"broker"`
}

// FluxSetupStatus defines the observed state of a FluxSetup
Expand All @@ -50,7 +47,6 @@ func (s *FluxSetup) SetDefaults() {
s.Spec.Size = 1
}
fmt.Printf("🤓 FluxSetup.Size %d\n", (*s).Spec.Size)
fmt.Printf("🤓 FluxSetup.Broker.Hostfile %s\n", (*s).Spec.Broker.Hostfile)
fmt.Printf("🤓 FluxSetup.EtcHosts.Hostfile \n%s\n", (*s).Spec.EtcHosts.Hostfile)
fmt.Println()
}
Expand Down
1 change: 0 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

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

9 changes: 0 additions & 9 deletions config/crd/bases/flux-framework.org_fluxsetups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ spec:
spec:
description: FluxSetupSpec defines the desired state of Flux
properties:
broker:
description: Broker with a hostfile for flux-config
properties:
hostfile:
type: string
required:
- hostfile
type: object
etc-hosts:
description: THe hostfile ConfigMap etc-hosts
properties:
Expand All @@ -56,7 +48,6 @@ spec:
format: int32
type: integer
required:
- broker
- etc-hosts
type: object
status:
Expand Down
12 changes: 0 additions & 12 deletions config/samples/flux-framework.org_v1alpha1_fluxsetup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,3 @@ spec:
hostfile: |
flux-workers-0.flux-workers 10.0.0.1
flux-workers-1.flux-workers 10.0.0.2
broker:
hostfile: |
[bootstrap]
curve_cert = "/mnt/curve/curve.cert"
default_port = 8050
default_bind = "tcp://eth0:%p"
default_connect = "tcp://%h:%p"
hosts = [
{ host="flux-workers-0.flux-workers"},
{ host="flux-workers-1.flux-workers"},
]
8 changes: 5 additions & 3 deletions controllers/flux/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (
api "flux-framework/flux-operator/api/v1alpha1"
)

var BrokerConfigTemplate = `
var (
brokerConfigTemplate = `
[bootstrap]
curve_cert = "/mnt/curve/curve.cert"
default_port = 8050
Expand All @@ -35,6 +36,7 @@ hosts = [
{ host="%s-%s"},
]
`
)

// getHostfileConfig gets an existing configmap, if it's done
func (r *FluxSetupReconciler) getHostfileConfig(ctx context.Context, instance *api.FluxSetup, configName string, hostfile string) (*corev1.ConfigMap, ctrl.Result, error) {
Expand All @@ -46,7 +48,7 @@ func (r *FluxSetupReconciler) getHostfileConfig(ctx context.Context, instance *a

// Case 1: not found yet, and hostfile is ready (recreate)
if errors.IsNotFound(err) {
// check if its broker.toml TODO : Convert all configMaps to use template stirngs
// check if its broker.toml TODO : Convert all configMaps to use template strings
if configName == "flux-config" {
hostfile = generateFluxConfig(instance.Name, instance.Spec.Size)
}
Expand Down Expand Up @@ -78,7 +80,7 @@ func generateFluxConfig(name string, size int32) string {
} else {
hosts = fmt.Sprintf("[0-%d]", size-1)
}
fluxConfig := fmt.Sprintf(BrokerConfigTemplate, name, hosts)
fluxConfig := fmt.Sprintf(brokerConfigTemplate, name, hosts)

return fluxConfig
}
Expand Down
6 changes: 3 additions & 3 deletions controllers/flux/fluxsetup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ func (r *FluxSetupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
flux.SetDefaults()
instance.SetDefaults()

log.Info("🥑️ Found instance 🥑️", "Flux Image: ", flux.Spec.Image)
fmt.Printf("\n🪵 Broker Hostfile %s\n", instance.Spec.Broker.Hostfile)
log.Info("🥑️ Found instance 🥑️", "Flux Image: ", flux.Spec.Image, "Size: ", fmt.Sprint(instance.Spec.Size))
fmt.Printf("\n🪵 EtcHosts Hostfile \n%s\n", instance.Spec.EtcHosts.Hostfile)

// Ensure the configs are created (for volume sources)
_, result, err := r.getHostfileConfig(ctx, &instance, "flux-config", instance.Spec.Broker.Hostfile)
// The hostfile here is empty because we generate it entirely
_, result, err := r.getHostfileConfig(ctx, &instance, "flux-config", "")
if err != nil {
return result, err
}
Expand Down

0 comments on commit 503347e

Please sign in to comment.