Skip to content

Commit

Permalink
mirror: Set mirror as managed when flag enabled in editor (PROJQUAY-2489
Browse files Browse the repository at this point in the history
) (#531)

- Enabled mirror component when repository mirroring flag is enabled through config editor
  • Loading branch information
jonathankingfc committed Sep 22, 2021
1 parent be0f36f commit c003063
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion controllers/quay/quayregistry_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (r *QuayRegistryReconciler) Reconcile(ctx context.Context, req ctrl.Request
}
}

if component.Managed && contains && component.Kind != v1.ComponentRoute {
if component.Managed && contains && component.Kind != v1.ComponentRoute && component.Kind != v1.ComponentMirror {
msg := fmt.Sprintf("%s component marked as managed, but `configBundleSecret` contains required fields", component.Kind)

return r.reconcileWithCondition(&quay, v1.ConditionTypeRolloutBlocked, metav1.ConditionTrue, v1.ConditionReasonConfigInvalid, msg)
Expand Down
11 changes: 10 additions & 1 deletion pkg/configure/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,29 @@ func ReconfigureHandler(k8sClient client.Client) func(w http.ResponseWriter, r *
newComponents := []v1.Component{}
for _, component := range quay.Spec.Components {

var contains bool
// HPA and Monitoring don't have fields associated with them so we skip. Route should not change based on config either since fields are optional when managed.
if component.Kind == v1.ComponentHPA || component.Kind == v1.ComponentMonitoring || component.Kind == v1.ComponentRoute {
newComponents = append(newComponents, component)
continue
}

// For the reset, infer from the presence of fields
contains, err := kustomize.ContainsComponentConfig(reconfigureRequest.Config, reconfigureRequest.Certs, component)

if err != nil {
log.Error(err, "failed to check `config.yaml` for component fieldgroup", "component", component.Kind)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}

// Mirror we infer based on the value of FEATURE_REPO_MIRROR
if component.Kind == v1.ComponentMirror {
enabled, ok := reconfigureRequest.Config["FEATURE_REPO_MIRROR"]
if ok && enabled.(bool) {
contains = false
}
}

if contains {
log.Info("marking component as unmanaged", "component", component.Kind)
newComponents = append(newComponents, v1.Component{Kind: component.Kind, Managed: false})
Expand Down

0 comments on commit c003063

Please sign in to comment.