feat(auth): integrate authentication with installation lifecycle
This commit is contained in:
@@ -43,6 +43,15 @@ var requiredVolumes = []string{
|
||||
"embedding-models",
|
||||
}
|
||||
|
||||
var requiredServerVolumes = []string{"qdrant-data", "embedding-models"}
|
||||
|
||||
func requiredBackupVolumes(installation config.Installation) []string {
|
||||
if installation.Profile == "server" {
|
||||
return requiredServerVolumes
|
||||
}
|
||||
return requiredVolumes
|
||||
}
|
||||
|
||||
const (
|
||||
helperImage = "busybox:1.36.1"
|
||||
drainPollInterval = time.Second
|
||||
@@ -165,7 +174,7 @@ func createWithDependencies(ctx context.Context, installation config.Installatio
|
||||
if err != nil {
|
||||
return Result{}, err
|
||||
}
|
||||
volumes, err := inspectRequiredVolumes(ctx, dependencies.runner, rendered)
|
||||
volumes, err := inspectRequiredVolumes(ctx, installation, dependencies.runner, rendered)
|
||||
if err != nil {
|
||||
return Result{}, err
|
||||
}
|
||||
@@ -408,7 +417,7 @@ func renderedConfiguration(ctx context.Context, installation config.Installation
|
||||
if json.Unmarshal([]byte(result.Stdout), &rendered) != nil {
|
||||
return renderedCompose{}, errors.New("Docker Compose returned invalid backup configuration")
|
||||
}
|
||||
for _, logical := range requiredVolumes {
|
||||
for _, logical := range requiredBackupVolumes(installation) {
|
||||
if rendered.Volumes[logical].Name == "" {
|
||||
return renderedCompose{}, fmt.Errorf("required backup volume %q is not configured", logical)
|
||||
}
|
||||
@@ -416,9 +425,10 @@ func renderedConfiguration(ctx context.Context, installation config.Installation
|
||||
return rendered, nil
|
||||
}
|
||||
|
||||
func inspectRequiredVolumes(ctx context.Context, runner archiveRunner, rendered renderedCompose) ([]VolumeMetadata, error) {
|
||||
names := make([]string, 0, len(requiredVolumes))
|
||||
for _, logical := range requiredVolumes {
|
||||
func inspectRequiredVolumes(ctx context.Context, installation config.Installation, runner archiveRunner, rendered renderedCompose) ([]VolumeMetadata, error) {
|
||||
required := requiredBackupVolumes(installation)
|
||||
names := make([]string, 0, len(required))
|
||||
for _, logical := range required {
|
||||
names = append(names, rendered.Volumes[logical].Name)
|
||||
}
|
||||
result, err := runner.Run(ctx, append([]string{"volume", "inspect"}, names...), nil)
|
||||
@@ -445,8 +455,8 @@ func inspectRequiredVolumes(ctx context.Context, runner archiveRunner, rendered
|
||||
Labels map[string]string
|
||||
}{item.Name, item.Driver, item.Labels}
|
||||
}
|
||||
volumes := make([]VolumeMetadata, 0, len(requiredVolumes))
|
||||
for _, logical := range requiredVolumes {
|
||||
volumes := make([]VolumeMetadata, 0, len(required))
|
||||
for _, logical := range required {
|
||||
name := rendered.Volumes[logical].Name
|
||||
item, ok := byName[name]
|
||||
if !ok || item.Driver == "" {
|
||||
@@ -614,13 +624,12 @@ func normalizeBackupServiceStates(states []backupServiceState) ([]backupServiceS
|
||||
}
|
||||
|
||||
func maintenance(ctx context.Context, installation config.Installation, runner archiveRunner, activate bool) error {
|
||||
action := "deactivate"
|
||||
action := "maintenance-deactivate"
|
||||
if activate {
|
||||
action = "activate"
|
||||
action = "maintenance-activate"
|
||||
}
|
||||
result, err := runner.Run(ctx, installation.ComposeArgs(
|
||||
"exec", "-T", "core", "curl", "-fsS", "--max-time", "5", "-X", "POST",
|
||||
"http://127.0.0.1:8787/internal/maintenance/"+action,
|
||||
"exec", "-T", "core", "node", "/app/backend/dist/operator-command.js", action,
|
||||
), nil)
|
||||
if err != nil {
|
||||
return dockerError("change maintenance admissions", result, err)
|
||||
@@ -631,8 +640,8 @@ func maintenance(ctx context.Context, installation config.Installation, runner a
|
||||
func waitForNoActiveSessions(ctx context.Context, installation config.Installation, runner archiveRunner, drain bool, sleep func(time.Duration)) error {
|
||||
for attempt := 0; attempt < maxDrainPolls; attempt++ {
|
||||
result, err := runner.Run(ctx, installation.ComposeArgs(
|
||||
"exec", "-T", "core", "curl", "-fsS", "--max-time", "5",
|
||||
"http://127.0.0.1:8787/sessions?scope="+runner.SessionInventoryScope(),
|
||||
"exec", "-T", "core", "node", "/app/backend/dist/operator-command.js",
|
||||
"session-inventory", runner.SessionInventoryScope(),
|
||||
), nil)
|
||||
if err != nil {
|
||||
return dockerError("inspect active sessions", result, err)
|
||||
|
||||
Reference in New Issue
Block a user