Skip to content

Commit

Permalink
bump: adjusting code to updated deps (PROJQUAY-2046)
Browse files Browse the repository at this point in the history
After bumping k8s.io dependencies some adjusts were necessary:

- use the right import URL for prometheus types
- pod "Probe" became "ProbeHandler"
- signingengine.SigningEngineFieldGroup{} does not exist anymore
- variables need to be removed (logic passed to middleware instead)
- krusty.MakeKustomizer() invocation has changed
  • Loading branch information
ricardomaraschini committed Jan 7, 2022
1 parent 5ca6250 commit 1827f4c
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion controllers/quay/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"strings"
"time"

prometheusv1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
objectbucket "github.com/kube-object-storage/lib-bucket-provisioner/pkg/apis/objectbucket.io/v1alpha1"
routev1 "github.com/openshift/api/route/v1"
prometheusv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"gopkg.in/yaml.v2"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand Down
2 changes: 1 addition & 1 deletion controllers/quay/quayregistry_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (
"sync"
"time"

prometheusv1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
"github.com/go-logr/logr"
objectbucket "github.com/kube-object-storage/lib-bucket-provisioner/pkg/apis/objectbucket.io/v1alpha1"
routev1 "github.com/openshift/api/route/v1"
prometheusv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"github.com/tidwall/sjson"
"gopkg.in/yaml.v2"
batchv1 "k8s.io/api/batch/v1"
Expand Down
19 changes: 12 additions & 7 deletions controllers/redhatcop/quayecosystem_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"os"
"time"

"github.com/quay/config-tool/pkg/lib/fieldgroups/signingengine"

"github.com/go-logr/logr"
"github.com/quay/config-tool/pkg/lib/fieldgroups/database"
"github.com/quay/config-tool/pkg/lib/fieldgroups/hostsettings"
Expand Down Expand Up @@ -330,7 +328,7 @@ func (r *QuayEcosystemReconciler) Reconcile(ctx context.Context, req ctrl.Reques
},
},
ReadinessProbe: &corev1.Probe{
Handler: corev1.Handler{
ProbeHandler: corev1.ProbeHandler{
Exec: &corev1.ExecAction{
Command: []string{"/usr/libexec/check-container"},
},
Expand All @@ -348,7 +346,7 @@ func (r *QuayEcosystemReconciler) Reconcile(ctx context.Context, req ctrl.Reques
Image: pgImage,
Command: []string{"/bin/bash", "-c", cleanupCommand},
ReadinessProbe: &corev1.Probe{
Handler: corev1.Handler{
ProbeHandler: corev1.ProbeHandler{
Exec: &corev1.ExecAction{
Command: []string{"/bin/bash", "-c", "psql -h localhost -f /tmp/check-user.sql | grep -q 1"},
},
Expand Down Expand Up @@ -766,12 +764,19 @@ func canHandleClair(q redhatcop.QuayEcosystem) bool {
return q.Spec.Clair != nil && q.Spec.Clair.Enabled
}

// clean removes deprecated fields from provided config.
func clean(config map[string]interface{}) map[string]interface{} {
// NOTE: Signing engine code has been removed from Quay.
for _, field := range (&signingengine.SigningEngineFieldGroup{}).Fields() {
// NOTE: signing engine code has been removed from Quay. here we remove the fields
// related to it as they are not useful anymore.
for _, field := range []string{
"GPG2_PRIVATE_KEY_FILENAME",
"GPG2_PRIVATE_KEY_NAME",
"GPG2_PUBLIC_KEY_FILENAME",
"SIGNING_ENGINE",
"FEATURE_SIGNING",
} {
delete(config, field)
}

return config
}

Expand Down
4 changes: 2 additions & 2 deletions kustomize/components/route/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ vars:
apiVersion: v1
name: quay-app
fieldref:
fieldpath: metadata.annotations["quay-registry-hostname"]
fieldpath: metadata.annotations.quay-registry-hostname
- name: BUILDMAN_HOSTNAME
objref:
kind: Service
apiVersion: v1
name: quay-app
fieldref:
fieldpath: metadata.annotations["quay-buildmanager-hostname"]
fieldpath: metadata.annotations.quay-buildmanager-hostname
2 changes: 1 addition & 1 deletion pkg/cmpstatus/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client/fake"

monv1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
ocsv1a1 "github.com/kube-object-storage/lib-bucket-provisioner/pkg/apis/objectbucket.io/v1alpha1"
routev1 "github.com/openshift/api/route/v1"
monv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"

qv1 "github.com/quay/quay-operator/apis/quay/v1"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmpstatus/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"

monv1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
monv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
qv1 "github.com/quay/quay-operator/apis/quay/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmpstatus/monitoring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client/fake"

monv1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
monv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"

qv1 "github.com/quay/quay-operator/apis/quay/v1"
)
Expand Down
12 changes: 7 additions & 5 deletions pkg/kustomize/kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"sort"
"strings"

prometheusv1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
"github.com/go-logr/logr"
objectbucket "github.com/kube-object-storage/lib-bucket-provisioner/pkg/apis/objectbucket.io/v1alpha1"
route "github.com/openshift/api/route/v1"
prometheusv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
apps "k8s.io/api/apps/v1"
autoscaling "k8s.io/api/autoscaling/v2beta2"
batchv1 "k8s.io/api/batch/v1"
Expand All @@ -25,8 +25,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/api/krusty"
"sigs.k8s.io/kustomize/api/resid"
"sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/kustomize/kyaml/resid"
"sigs.k8s.io/yaml"

v1 "github.com/quay/quay-operator/apis/quay/v1"
Expand Down Expand Up @@ -222,9 +222,11 @@ func generate(kustomization *types.Kustomization, overlay string, quayConfigFile
check(err)
}

opts := &krusty.Options{}
k := krusty.MakeKustomizer(fSys, opts)
resMap, err := k.Run(overlay)
opts := &krusty.Options{
PluginConfig: &types.PluginConfig{},
}
k := krusty.MakeKustomizer(opts)
resMap, err := k.Run(fSys, overlay)
check(err)

output := []client.Object{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kustomize/kustomize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ var inflateTests = []struct {
func TestInflate(t *testing.T) {
assert := assert.New(t)

log := testlogr.TestLogger{}
log := testlogr.NewTestLogger(t)

for _, test := range inflateTests {
t.Run(test.name, func(t *testing.T) {
Expand Down
8 changes: 8 additions & 0 deletions pkg/kustomize/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ func FieldGroupFor(ctx *quaycontext.QuayRegistryContext, component v1.ComponentK

fieldGroup.DbUri = ctx.DbUri

// XXX after bumping database package (dependency) these fields stopped being
// set to true by default. These lines restores the old behavior so we don't
// expect to have unexpected side effects.
if fieldGroup.DbConnectionArgs != nil {
fieldGroup.DbConnectionArgs.Autorollback = true
fieldGroup.DbConnectionArgs.Threadlocals = true
}

return fieldGroup, nil
case v1.ComponentObjectStorage:
fieldGroup := &distributedstorage.DistributedStorageFieldGroup{
Expand Down

0 comments on commit 1827f4c

Please sign in to comment.