Skip to content

OPECO-3066: Synchronize From Upstream Repositories #612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/openshift/api v3.9.0+incompatible
github.com/operator-framework/api v0.19.0
github.com/operator-framework/operator-lifecycle-manager v0.0.0-00010101000000-000000000000
github.com/operator-framework/operator-registry v1.30.1
github.com/operator-framework/operator-registry v1.32.0
github.com/sirupsen/logrus v1.9.2
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.3
Expand Down
3 changes: 1 addition & 2 deletions staging/api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.19

require (
github.com/blang/semver/v4 v4.0.0
github.com/ghodss/yaml v1.0.0
github.com/go-bindata/go-bindata/v3 v3.1.3
github.com/google/cel-go v0.15.3
github.com/sirupsen/logrus v1.9.2
Expand All @@ -16,6 +15,7 @@ require (
k8s.io/apimachinery v0.27.7
k8s.io/client-go v0.27.7
sigs.k8s.io/controller-runtime v0.15.0
sigs.k8s.io/yaml v1.3.0
)

require (
Expand Down Expand Up @@ -91,5 +91,4 @@ require (
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
1 change: 0 additions & 1 deletion staging/api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-bindata/go-bindata/v3 v3.1.3 h1:F0nVttLC3ws0ojc7p60veTurcOm//D4QBODNM7EGrCI=
github.com/go-bindata/go-bindata/v3 v3.1.3/go.mod h1:1/zrpXsLD8YDIbhZRqXzm1Ghc7NhEvIN9+Z6R5/xH4I=
Expand Down
2 changes: 1 addition & 1 deletion staging/api/pkg/validation/internal/crd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"

"github.com/ghodss/yaml"
"sigs.k8s.io/yaml"
)

func TestValidateCRD(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion staging/api/pkg/validation/internal/csv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (

operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"

"github.com/ghodss/yaml"
"github.com/operator-framework/api/pkg/validation/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/yaml"
)

func TestValidateCSV(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions staging/api/pkg/validation/internal/object_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package internal

import (
"github.com/ghodss/yaml"
"io/ioutil"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"testing"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"sigs.k8s.io/yaml"
)

func TestValidateObject(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion staging/api/pkg/validation/internal/operatorgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"path/filepath"
"testing"

"github.com/ghodss/yaml"
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
"github.com/operator-framework/api/pkg/validation/errors"
"sigs.k8s.io/yaml"
)

func TestValidateOperatorGroup(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ jobs:
uses: "golangci/golangci-lint-action@v3"
with:
version: "v1.51.1"

6 changes: 3 additions & 3 deletions staging/operator-lifecycle-manager/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.20
require (
github.com/blang/semver/v4 v4.0.0
github.com/coreos/go-semver v0.3.0
github.com/davecgh/go-spew v1.1.1
github.com/distribution/distribution v2.7.1+incompatible
github.com/evanphx/json-patch v5.6.0+incompatible
github.com/fsnotify/fsnotify v1.6.0
Expand All @@ -25,8 +24,8 @@ require (
github.com/onsi/gomega v1.27.7
github.com/openshift/api v3.9.0+incompatible
github.com/openshift/client-go v0.0.0-20220525160904-9e1acff93e4a
github.com/operator-framework/api v0.18.0
github.com/operator-framework/operator-registry v1.30.1
github.com/operator-framework/api v0.19.0
github.com/operator-framework/operator-registry v1.32.0
github.com/otiai10/copy v1.12.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.15.1
Expand Down Expand Up @@ -90,6 +89,7 @@ require (
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/cli v23.0.1+incompatible // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v23.0.3+incompatible // indirect
Expand Down
8 changes: 4 additions & 4 deletions staging/operator-lifecycle-manager/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,10 @@ github.com/openshift/api v0.0.0-20221021112143-4226c2167e40 h1:PxjGCA72RtsdHWToZ
github.com/openshift/api v0.0.0-20221021112143-4226c2167e40/go.mod h1:aQ6LDasvHMvHZXqLHnX2GRmnfTWCF/iIwz8EMTTIE9A=
github.com/openshift/client-go v0.0.0-20221019143426-16aed247da5c h1:CV76yFOTXmq9VciBR3Bve5ZWzSxdft7gaMVB3kS0rwg=
github.com/openshift/client-go v0.0.0-20221019143426-16aed247da5c/go.mod h1:lFMO8mLHXWFzSdYvGNo8ivF9SfF6zInA8ZGw4phRnUE=
github.com/operator-framework/api v0.18.0 h1:6EdSNeAjin4LRu2YQnQWMJMc6HXS0AQDG+CfaEvFrAo=
github.com/operator-framework/api v0.18.0/go.mod h1:SCCslqke6AVOJ5JM+NqNE1CHuAgJLScsL66pnPaSMXs=
github.com/operator-framework/operator-registry v1.30.1 h1:7XvISZrwi+j9z4MIiApRRU+K7v3qMXIcgBs88eQ724Q=
github.com/operator-framework/operator-registry v1.30.1/go.mod h1:iKVnZsuGjPm6h/jPn4WyQ7JFguRCZMUN+YmsEMu6byA=
github.com/operator-framework/api v0.19.0 h1:QU1CTJU+CufoeneA5rsNlP/uP96s8vDHWUYDFZTauzA=
github.com/operator-framework/api v0.19.0/go.mod h1:SCCslqke6AVOJ5JM+NqNE1CHuAgJLScsL66pnPaSMXs=
github.com/operator-framework/operator-registry v1.32.0 h1:RNazXYt3vBf5FZ+JrNNjq4bNh3tDwlkwZJnC+kmCeKk=
github.com/operator-framework/operator-registry v1.32.0/go.mod h1:89VshAf6+n0V12vdh43+WOi8i1+XpY+kg6Ao4JO0y6k=
github.com/otiai10/copy v1.12.0 h1:cLMgSQnXBs1eehF0Wy/FAGsgDTDmAqFR7rQylBb1nDY=
github.com/otiai10/copy v1.12.0/go.mod h1:rSaLseMUsZFFbsFGc7wCJnnkTAvdc5L6VWxPE4308Ww=
github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ package install

import (
"fmt"
"hash/fnv"
"time"

log "github.com/sirupsen/logrus"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
k8slabels "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/utils/pointer"

"github.com/operator-framework/api/pkg/operators/v1alpha1"
Expand Down Expand Up @@ -181,7 +179,10 @@ func (i *StrategyDeploymentInstaller) deploymentForSpec(name string, spec appsv1
// to 2 ReplicaSets per deployment it manages, saving memory.
dep.Spec.RevisionHistoryLimit = pointer.Int32(1)

hash = HashDeploymentSpec(dep.Spec)
hash, err = hashutil.DeepHashObject(&dep.Spec)
if err != nil {
return nil, "", err
}
dep.Labels[DeploymentSpecHashLabelKey] = hash

deployment = dep
Expand Down Expand Up @@ -327,11 +328,3 @@ func (i *StrategyDeploymentInstaller) cleanupOrphanedDeployments(deploymentSpecs

return nil
}

// HashDeploymentSpec calculates a hash given a copy of the deployment spec from a CSV, stripping any
// operatorgroup annotations.
func HashDeploymentSpec(spec appsv1.DeploymentSpec) string {
hasher := fnv.New32a()
hashutil.DeepHashObject(hasher, &spec)
return rand.SafeEncodeString(fmt.Sprint(hasher.Sum32()))
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"testing"

hashutil "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/kubernetes/pkg/util/hash"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -352,7 +353,11 @@ func TestInstallStrategyDeploymentCheckInstallErrors(t *testing.T) {
dep := testDeployment("olm-dep-1", namespace, &mockOwner)
dep.Spec.Template.SetAnnotations(map[string]string{"test": "annotation"})
dep.Spec.RevisionHistoryLimit = &revisionHistoryLimit
dep.SetLabels(labels.CloneAndAddLabel(dep.ObjectMeta.GetLabels(), DeploymentSpecHashLabelKey, HashDeploymentSpec(dep.Spec)))
hash, err := hashutil.DeepHashObject(&dep.Spec)
if err != nil {
t.Fatal(err)
}
dep.SetLabels(labels.CloneAndAddLabel(dep.ObjectMeta.GetLabels(), DeploymentSpecHashLabelKey, hash))
dep.Labels[OLMManagedLabelKey] = OLMManagedLabelValue
dep.Status.Conditions = append(dep.Status.Conditions, appsv1.DeploymentCondition{
Type: appsv1.DeploymentAvailable,
Expand All @@ -374,7 +379,11 @@ func TestInstallStrategyDeploymentCheckInstallErrors(t *testing.T) {
deployment := testDeployment("olm-dep-1", namespace, &mockOwner)
deployment.Spec.Template.SetAnnotations(map[string]string{"test": "annotation"})
deployment.Spec.RevisionHistoryLimit = &revisionHistoryLimit
deployment.SetLabels(labels.CloneAndAddLabel(dep.ObjectMeta.GetLabels(), DeploymentSpecHashLabelKey, HashDeploymentSpec(deployment.Spec)))
hash, err = hashutil.DeepHashObject(&deployment.Spec)
if err != nil {
t.Fatal(err)
}
deployment.SetLabels(labels.CloneAndAddLabel(dep.ObjectMeta.GetLabels(), DeploymentSpecHashLabelKey, hash))
fakeClient.CreateOrUpdateDeploymentReturns(&deployment, tt.createDeploymentErr)
defer func() {
require.Equal(t, &deployment, fakeClient.CreateOrUpdateDeploymentArgsForCall(0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ package install
import (
"context"
"fmt"
"hash/fnv"

log "github.com/sirupsen/logrus"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/client-go/util/retry"

"github.com/operator-framework/api/pkg/operators/v1alpha1"
Expand Down Expand Up @@ -285,17 +283,14 @@ func addWebhookLabels(object metav1.Object, webhookDesc v1alpha1.WebhookDescript
if labels == nil {
labels = map[string]string{}
}
hash, err := hashutil.DeepHashObject(&webhookDesc)
if err != nil {
return err
}
labels[WebhookDescKey] = webhookDesc.GenerateName
labels[WebhookHashKey] = HashWebhookDesc(webhookDesc)
labels[WebhookHashKey] = hash
labels[OLMManagedLabelKey] = OLMManagedLabelValue
object.SetLabels(labels)

return nil
}

// HashWebhookDesc calculates a hash given a webhookDescription
func HashWebhookDesc(webhookDesc v1alpha1.WebhookDescription) string {
hasher := fnv.New32a()
hashutil.DeepHashObject(hasher, &webhookDesc)
return rand.SafeEncodeString(fmt.Sprint(hasher.Sum32()))
}
Original file line number Diff line number Diff line change
Expand Up @@ -999,15 +999,15 @@ func TestSyncCatalogSources(t *testing.T) {
},
expectedError: nil,
expectedObjs: []runtime.Object{
pod(*grpcCatalog),
pod(t, *grpcCatalog),
},
},
{
testName: "CatalogSourceWithGrpcImage/EnsuresCorrectImage",
namespace: "cool-namespace",
catalogSource: grpcCatalog,
k8sObjs: []runtime.Object{
pod(v1alpha1.CatalogSource{
pod(t, v1alpha1.CatalogSource{
ObjectMeta: metav1.ObjectMeta{
Name: "cool-catalog",
Namespace: "cool-namespace",
Expand All @@ -1031,7 +1031,7 @@ func TestSyncCatalogSources(t *testing.T) {
},
expectedError: nil,
expectedObjs: []runtime.Object{
pod(*grpcCatalog),
pod(t, *grpcCatalog),
},
},
{
Expand Down Expand Up @@ -1110,7 +1110,7 @@ func TestSyncCatalogSources(t *testing.T) {
},
}),
k8sObjs: []runtime.Object{
pod(*grpcCatalog),
pod(t, *grpcCatalog),
service(grpcCatalog.GetName(), grpcCatalog.GetNamespace()),
serviceAccount(grpcCatalog.GetName(), grpcCatalog.GetNamespace(), "", objectReference("init secret")),
},
Expand Down Expand Up @@ -2119,14 +2119,17 @@ func toManifest(t *testing.T, obj runtime.Object) string {
return string(raw)
}

func pod(s v1alpha1.CatalogSource) *corev1.Pod {
func pod(t *testing.T, s v1alpha1.CatalogSource) *corev1.Pod {
serviceAccount := &corev1.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Namespace: s.GetNamespace(),
Name: s.GetName(),
},
}
pod := reconciler.Pod(&s, "registry-server", "central-opm", "central-util", s.Spec.Image, serviceAccount, s.GetLabels(), s.GetAnnotations(), 5, 10, 1001)
pod, err := reconciler.Pod(&s, "registry-server", "central-opm", "central-util", s.Spec.Image, serviceAccount, s.GetLabels(), s.GetAnnotations(), 5, 10, 1001)
if err != nil {
t.Fatal(err)
}
ownerutil.AddOwner(pod, &s, false, true)
return pod
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

hashutil "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/kubernetes/pkg/util/hash"
log "github.com/sirupsen/logrus"
appsv1 "k8s.io/api/apps/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -414,7 +415,11 @@ func (a *Operator) areWebhooksAvailable(csv *v1alpha1.ClusterServiceVersion) (bo
// Create Webhook Label Selector
webhookLabels := ownerutil.OwnerLabel(csv, v1alpha1.ClusterServiceVersionKind)
webhookLabels[install.WebhookDescKey] = desc.GenerateName
webhookLabels[install.WebhookHashKey] = install.HashWebhookDesc(desc)
hash, err := hashutil.DeepHashObject(&desc)
if err != nil {
return false, err
}
webhookLabels[install.WebhookHashKey] = hash
webhookSelector := labels.SelectorFromSet(webhookLabels).String()

webhookCount := 0
Expand Down
Loading