Skip to content

Commit 988abd6

Browse files
Merge pull request #473 from openshift-bot/synchronize-upstream
NO-ISSUE: Synchronize From Upstream Repositories
2 parents 8f440ec + 1122522 commit 988abd6

File tree

27 files changed

+514
-152
lines changed

27 files changed

+514
-152
lines changed

commitchecker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
expectedMergeBase: e0a2e17332717dab9a16c1ff6d6ff80fd769ffe5
1+
expectedMergeBase: 4867f92ba1bda49f4861627fb078177d2553f438
22
upstreamBranch: main
33
upstreamOrg: operator-framework
44
upstreamRepo: operator-controller

go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ require (
99
github.com/cert-manager/cert-manager v1.18.2
1010
github.com/containerd/containerd v1.7.28
1111
github.com/containers/image/v5 v5.36.2
12-
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
1312
github.com/fsnotify/fsnotify v1.9.0
1413
github.com/go-logr/logr v1.4.3
1514
github.com/golang-jwt/jwt/v5 v5.3.0
@@ -22,7 +21,7 @@ require (
2221
github.com/opencontainers/image-spec v1.1.1
2322
github.com/operator-framework/api v0.34.0
2423
github.com/operator-framework/helm-operator-plugins v0.8.0
25-
github.com/operator-framework/operator-registry v1.57.0
24+
github.com/operator-framework/operator-registry v1.58.0
2625
github.com/prometheus/client_golang v1.23.2
2726
github.com/prometheus/common v0.66.1
2827
github.com/spf13/cobra v1.10.1
@@ -83,14 +82,15 @@ require (
8382
github.com/containerd/stargz-snapshotter/estargz v0.16.3 // indirect
8483
github.com/containerd/ttrpc v1.2.7 // indirect
8584
github.com/containerd/typeurl/v2 v2.2.3 // indirect
86-
github.com/containers/common v0.64.1 // indirect
85+
github.com/containers/common v0.64.2 // indirect
8786
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect
8887
github.com/containers/ocicrypt v1.2.1 // indirect
8988
github.com/containers/storage v1.59.1 // indirect
9089
github.com/cyberphone/json-canonicalization v0.0.0-20241213102144-19d51d7fe467 // indirect
9190
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
91+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
9292
github.com/distribution/reference v0.6.0 // indirect
93-
github.com/docker/cli v28.3.3+incompatible // indirect
93+
github.com/docker/cli v28.4.0+incompatible // indirect
9494
github.com/docker/distribution v2.8.3+incompatible // indirect
9595
github.com/docker/docker v28.3.3+incompatible // indirect
9696
github.com/docker/docker-credential-helpers v0.9.3 // indirect
@@ -207,7 +207,7 @@ require (
207207
github.com/stoewer/go-strcase v1.3.1 // indirect
208208
github.com/stretchr/objx v0.5.2 // indirect
209209
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect
210-
github.com/ulikunitz/xz v0.5.14 // indirect
210+
github.com/ulikunitz/xz v0.5.15 // indirect
211211
github.com/vbatts/tar-split v0.12.1 // indirect
212212
github.com/vbauerster/mpb/v8 v8.10.2 // indirect
213213
github.com/x448/float16 v0.8.4 // indirect
@@ -237,7 +237,7 @@ require (
237237
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 // indirect
238238
google.golang.org/genproto/googleapis/api v0.0.0-20250707201910-8d1bb00bc6a7 // indirect
239239
google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 // indirect
240-
google.golang.org/grpc v1.75.0 // indirect
240+
google.golang.org/grpc v1.75.1 // indirect
241241
google.golang.org/protobuf v1.36.9 // indirect
242242
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
243243
gopkg.in/inf.v0 v0.9.1 // indirect

go.sum

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ github.com/containerd/ttrpc v1.2.7 h1:qIrroQvuOL9HQ1X6KHe2ohc7p+HP/0VE6XPU7elJRq
7777
github.com/containerd/ttrpc v1.2.7/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o=
7878
github.com/containerd/typeurl/v2 v2.2.3 h1:yNA/94zxWdvYACdYO8zofhrTVuQY73fFU1y++dYSw40=
7979
github.com/containerd/typeurl/v2 v2.2.3/go.mod h1:95ljDnPfD3bAbDJRugOiShd/DlAAsxGtUBhJxIn7SCk=
80-
github.com/containers/common v0.64.1 h1:E8vSiL+B84/UCsyVSb70GoxY9cu+0bseLujm4EKF6GE=
81-
github.com/containers/common v0.64.1/go.mod h1:CtfQNHoCAZqWeXMwdShcsxmMJSeGRgKKMqAwRKmWrHE=
80+
github.com/containers/common v0.64.2 h1:1xepE7QwQggUXxmyQ1Dbh6Cn0yd7ktk14sN3McSWf5I=
81+
github.com/containers/common v0.64.2/go.mod h1:o29GfYy4tefUuShm8mOn2AiL5Mpzdio+viHI7n24KJ4=
8282
github.com/containers/image/v5 v5.36.2 h1:GcxYQyAHRF/pLqR4p4RpvKllnNL8mOBn0eZnqJbfTwk=
8383
github.com/containers/image/v5 v5.36.2/go.mod h1:b4GMKH2z/5t6/09utbse2ZiLK/c72GuGLFdp7K69eA4=
8484
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 h1:Qzk5C6cYglewc+UyGf6lc8Mj2UaPTHy/iF2De0/77CA=
@@ -110,8 +110,8 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr
110110
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
111111
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
112112
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
113-
github.com/docker/cli v28.3.3+incompatible h1:fp9ZHAr1WWPGdIWBM1b3zLtgCF+83gRdVMTJsUeiyAo=
114-
github.com/docker/cli v28.3.3+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
113+
github.com/docker/cli v28.4.0+incompatible h1:RBcf3Kjw2pMtwui5V0DIMdyeab8glEw5QY0UUU4C9kY=
114+
github.com/docker/cli v28.4.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
115115
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
116116
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
117117
github.com/docker/docker v28.3.3+incompatible h1:Dypm25kh4rmk49v1eiVbsAtpAsYURjYkaKubwuBdxEI=
@@ -212,8 +212,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
212212
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
213213
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
214214
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
215-
github.com/golang-migrate/migrate/v4 v4.18.3 h1:EYGkoOsvgHHfm5U/naS1RP/6PL/Xv3S4B/swMiAmDLs=
216-
github.com/golang-migrate/migrate/v4 v4.18.3/go.mod h1:99BKpIi6ruaaXRM1A77eqZ+FWPQ3cfRa+ZVy5bmWMaY=
215+
github.com/golang-migrate/migrate/v4 v4.19.0 h1:RcjOnCGz3Or6HQYEJ/EEVLfWnmw9KnoigPSjzhCuaSE=
216+
github.com/golang-migrate/migrate/v4 v4.19.0/go.mod h1:9dyEcu+hO+G9hPSw8AIg50yg622pXJsoHItQnDGZkI0=
217217
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
218218
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
219219
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
@@ -386,8 +386,8 @@ github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY=
386386
github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc=
387387
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
388388
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
389-
github.com/onsi/ginkgo/v2 v2.25.2 h1:hepmgwx1D+llZleKQDMEvy8vIlCxMGt7W5ZxDjIEhsw=
390-
github.com/onsi/ginkgo/v2 v2.25.2/go.mod h1:43uiyQC4Ed2tkOzLsEYm7hnrb7UJTWHYNsuy3bG/snE=
389+
github.com/onsi/ginkgo/v2 v2.25.3 h1:Ty8+Yi/ayDAGtk4XxmmfUy4GabvM+MegeB4cDLRi6nw=
390+
github.com/onsi/ginkgo/v2 v2.25.3/go.mod h1:43uiyQC4Ed2tkOzLsEYm7hnrb7UJTWHYNsuy3bG/snE=
391391
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
392392
github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k=
393393
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
@@ -402,8 +402,8 @@ github.com/operator-framework/helm-operator-plugins v0.8.0 h1:0f6HOQC5likkf0b/Ov
402402
github.com/operator-framework/helm-operator-plugins v0.8.0/go.mod h1:Sc+8bE38xTCgCChBUvtq/PxatEg9fAypr7S5iAw8nlA=
403403
github.com/operator-framework/operator-lib v0.17.0 h1:cbz51wZ9+GpWR1ZYP4CSKSSBxDlWxmmnseaHVZZjZt4=
404404
github.com/operator-framework/operator-lib v0.17.0/go.mod h1:TGopBxIE8L6E/Cojzo26R3NFp1eNlqhQNmzqhOblaLw=
405-
github.com/operator-framework/operator-registry v1.57.0 h1:mQ4c8A8VUxZPJ0QCFRNio+7JEsLX6eKxlDSl6ORCRdk=
406-
github.com/operator-framework/operator-registry v1.57.0/go.mod h1:9rAZH/LZ/ttEuTvL1D4KApGqOtRDE6fJzzOrJNcBu7g=
405+
github.com/operator-framework/operator-registry v1.58.0 h1:CvfwYy19fBmsGBHEPQLwVvsYrQ3HQnqP9xQorBtz8nM=
406+
github.com/operator-framework/operator-registry v1.58.0/go.mod h1:0MhOHp+BPGs9HBgbwtLSTKwmRKYIeD0aMnJesEXhIAw=
407407
github.com/otiai10/copy v1.14.1 h1:5/7E6qsUMBaH5AnQ0sSLzzTg1oTECmcCmT6lvF45Na8=
408408
github.com/otiai10/copy v1.14.1/go.mod h1:oQwrEDDOci3IM8dJF0d8+jnbfPDllW6vUjNc3DoZm9I=
409409
github.com/otiai10/mint v1.6.3 h1:87qsV/aw1F5as1eH1zS/yqHY85ANKVMgkDrf9rcxbQs=
@@ -490,8 +490,8 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
490490
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
491491
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 h1:e/5i7d4oYZ+C1wj2THlRK+oAhjeS/TRQwMfkIuet3w0=
492492
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399/go.mod h1:LdwHTNJT99C5fTAzDz0ud328OgXz+gierycbcIx2fRs=
493-
github.com/ulikunitz/xz v0.5.14 h1:uv/0Bq533iFdnMHZdRBTOlaNMdb1+ZxXIlHDZHIHcvg=
494-
github.com/ulikunitz/xz v0.5.14/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
493+
github.com/ulikunitz/xz v0.5.15 h1:9DNdB5s+SgV3bQ2ApL10xRc35ck0DuIX/isZvIk+ubY=
494+
github.com/ulikunitz/xz v0.5.15/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
495495
github.com/vbatts/tar-split v0.12.1 h1:CqKoORW7BUWBe7UL/iqTVvkTBOF8UvOMKOIZykxnnbo=
496496
github.com/vbatts/tar-split v0.12.1/go.mod h1:eF6B6i6ftWQcDqEn3/iGFRFRo8cBIMSJVOpnNdfTMFA=
497497
github.com/vbauerster/mpb/v8 v8.10.2 h1:2uBykSHAYHekE11YvJhKxYmLATKHAGorZwFlyNw4hHM=
@@ -718,8 +718,8 @@ google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac
718718
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
719719
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
720720
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
721-
google.golang.org/grpc v1.75.0 h1:+TW+dqTd2Biwe6KKfhE5JpiYIBWq865PhKGSXiivqt4=
722-
google.golang.org/grpc v1.75.0/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
721+
google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI=
722+
google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
723723
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
724724
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
725725
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=

internal/operator-controller/applier/boxcutter.go

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@ package applier
33
import (
44
"cmp"
55
"context"
6-
"crypto/sha256"
7-
"encoding/hex"
86
"errors"
97
"fmt"
10-
"hash"
118
"io/fs"
129
"maps"
1310
"slices"
1411
"strings"
1512

16-
"github.com/davecgh/go-spew/spew"
1713
"helm.sh/helm/v3/pkg/release"
1814
"helm.sh/helm/v3/pkg/storage/driver"
1915
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -33,6 +29,7 @@ import (
3329
"github.com/operator-framework/operator-controller/internal/operator-controller/labels"
3430
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/bundle/source"
3531
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/render"
32+
hashutil "github.com/operator-framework/operator-controller/internal/shared/util/hash"
3633
)
3734

3835
const (
@@ -233,7 +230,7 @@ func (bc *Boxcutter) apply(ctx context.Context, contentFS fs.FS, ext *ocv1.Clust
233230
if err != nil {
234231
return false, "", err
235232
}
236-
desiredHash := computeSHA256Hash(desiredRevision.Spec.Phases)
233+
desiredHash := hashutil.DeepHashObject(desiredRevision.Spec.Phases)
237234

238235
// Sort into current and previous revisions.
239236
var (
@@ -355,33 +352,6 @@ func (bc *Boxcutter) getExistingRevisions(ctx context.Context, extName string) (
355352
return existingRevisionList.Items, nil
356353
}
357354

358-
// computeSHA256Hash returns a sha236 hash value calculated from object.
359-
func computeSHA256Hash(obj any) string {
360-
hasher := sha256.New()
361-
deepHashObject(hasher, obj)
362-
return hex.EncodeToString(hasher.Sum(nil))
363-
}
364-
365-
// deepHashObject writes specified object to hash using the spew library
366-
// which follows pointers and prints actual values of the nested objects
367-
// ensuring the hash does not change when a pointer changes.
368-
func deepHashObject(hasher hash.Hash, objectToWrite any) {
369-
hasher.Reset()
370-
371-
// TODO: change this out to `json.Marshal`. Pretty sure we found issues in the past where
372-
// spew would produce different output when internal structures changed without the
373-
// external public API changing.
374-
printer := spew.ConfigState{
375-
Indent: " ",
376-
SortKeys: true,
377-
DisableMethods: true,
378-
SpewKeys: true,
379-
}
380-
if _, err := printer.Fprintf(hasher, "%#v", objectToWrite); err != nil {
381-
panic(err)
382-
}
383-
}
384-
385355
func latestRevisionNumber(prevRevisions []ocv1.ClusterExtensionRevision) int64 {
386356
if len(prevRevisions) == 0 {
387357
return 0

internal/operator-controller/applier/boxcutter_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ func TestBoxcutter_Apply(t *testing.T) {
354354
UID: "test-uid",
355355
},
356356
}
357-
defaultDesiredHash := "705ada5296ab26f74d94bfa497295a0cbccdb140623bbe704a3506cd1dfba4eb"
357+
defaultDesiredHash := "gvvp8nzq5sbila80hkiv69am8hdr7o68qkk8n084gdn"
358358
defaultDesiredRevision := &ocv1.ClusterExtensionRevision{
359359
ObjectMeta: metav1.ObjectMeta{
360360
Name: "test-ext-1",
@@ -546,7 +546,7 @@ func TestBoxcutter_Apply(t *testing.T) {
546546

547547
assert.Equal(t, "test-ext-2", newRev.Name)
548548
assert.Equal(t, int64(2), newRev.Spec.Revision)
549-
assert.Equal(t, "9d0e48f6830fce1be5f510eb996f2876719fdb8bcffcfe1dfd3fd60e56316424", newRev.Annotations[applier.RevisionHashAnnotation])
549+
assert.Equal(t, "1fqrim12vefkogp3pwxwhcs7c0pi1z1t2fw4roxu81sv", newRev.Annotations[applier.RevisionHashAnnotation])
550550
require.Len(t, newRev.Spec.Previous, 1)
551551
assert.Equal(t, "test-ext-1", newRev.Spec.Previous[0].Name)
552552
assert.Equal(t, types.UID("rev-uid-1"), newRev.Spec.Previous[0].UID)

internal/operator-controller/controllers/clusterextensionrevision_controller.go

Lines changed: 66 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ import (
1212

1313
appsv1 "k8s.io/api/apps/v1"
1414
corev1 "k8s.io/api/core/v1"
15+
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
1516
"k8s.io/apimachinery/pkg/api/equality"
1617
"k8s.io/apimachinery/pkg/api/meta"
1718
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1819
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
19-
"k8s.io/apimachinery/pkg/runtime"
2020
"k8s.io/apimachinery/pkg/runtime/schema"
2121
"k8s.io/apimachinery/pkg/types"
2222
"k8s.io/apimachinery/pkg/util/sets"
2323
"pkg.package-operator.run/boxcutter"
2424
"pkg.package-operator.run/boxcutter/machinery"
2525
machinerytypes "pkg.package-operator.run/boxcutter/machinery/types"
26+
"pkg.package-operator.run/boxcutter/probing"
2627
ctrl "sigs.k8s.io/controller-runtime"
2728
"sigs.k8s.io/controller-runtime/pkg/builder"
2829
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -430,31 +431,9 @@ func toBoxcutterRevision(rev *ocv1.ClusterExtensionRevision) (*boxcutter.Revisio
430431

431432
opts := []boxcutter.RevisionReconcileOption{
432433
boxcutter.WithPreviousOwners(previous),
433-
boxcutter.WithProbe(boxcutter.ProgressProbeType, boxcutter.ProbeFunc(func(obj client.Object) (bool, []string) {
434-
deployGK := schema.GroupKind{
435-
Group: "apps", Kind: "Deployment",
436-
}
437-
if obj.GetObjectKind().GroupVersionKind().GroupKind() != deployGK {
438-
return true, nil
439-
}
440-
ustrObj := obj.(*unstructured.Unstructured)
441-
depl := &appsv1.Deployment{}
442-
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(ustrObj.Object, depl); err != nil {
443-
return false, []string{err.Error()}
444-
}
445-
446-
if depl.Status.ObservedGeneration != depl.Generation {
447-
return false, []string{".status.observedGeneration outdated"}
448-
}
449-
for _, cond := range depl.Status.Conditions {
450-
if cond.Type == ocv1.ClusterExtensionRevisionTypeAvailable &&
451-
cond.Status == corev1.ConditionTrue &&
452-
depl.Status.UpdatedReplicas == *depl.Spec.Replicas {
453-
return true, nil
454-
}
455-
}
456-
return false, []string{"not available or not fully updated"}
457-
})),
434+
boxcutter.WithProbe(boxcutter.ProgressProbeType, probing.And{
435+
deploymentProbe, statefulSetProbe, crdProbe, issuerProbe, certProbe,
436+
}),
458437
}
459438

460439
r := &boxcutter.Revision{
@@ -490,3 +469,64 @@ func toBoxcutterRevision(rev *ocv1.ClusterExtensionRevision) (*boxcutter.Revisio
490469
}
491470
return r, opts, previous
492471
}
472+
473+
var (
474+
deploymentProbe = &probing.GroupKindSelector{
475+
GroupKind: schema.GroupKind{Group: appsv1.GroupName, Kind: "Deployment"},
476+
Prober: deplStatefulSetProbe,
477+
}
478+
statefulSetProbe = &probing.GroupKindSelector{
479+
GroupKind: schema.GroupKind{Group: appsv1.GroupName, Kind: "StatefulSet"},
480+
Prober: deplStatefulSetProbe,
481+
}
482+
crdProbe = &probing.GroupKindSelector{
483+
GroupKind: schema.GroupKind{Group: "apiextensions.k8s.io", Kind: "CustomResourceDefinition"},
484+
Prober: &probing.ObservedGenerationProbe{
485+
Prober: &probing.ConditionProbe{ // "Available" == "True"
486+
Type: string(apiextensions.Established),
487+
Status: string(corev1.ConditionTrue),
488+
},
489+
},
490+
}
491+
certProbe = &probing.GroupKindSelector{
492+
GroupKind: schema.GroupKind{Group: "acme.cert-manager.io", Kind: "Certificate"},
493+
Prober: &probing.ObservedGenerationProbe{
494+
Prober: readyConditionProbe,
495+
},
496+
}
497+
issuerProbe = &probing.GroupKindSelector{
498+
GroupKind: schema.GroupKind{Group: "acme.cert-manager.io", Kind: "Issuer"},
499+
Prober: &probing.ObservedGenerationProbe{
500+
Prober: readyConditionProbe,
501+
},
502+
}
503+
504+
// deplStaefulSetProbe probes Deployment, StatefulSet objects.
505+
deplStatefulSetProbe = &probing.ObservedGenerationProbe{
506+
Prober: probing.And{
507+
availableConditionProbe,
508+
replicasUpdatedProbe,
509+
},
510+
}
511+
512+
// Checks if the Type: "Available" Condition is "True".
513+
availableConditionProbe = &probing.ConditionProbe{ // "Available" == "True"
514+
Type: string(appsv1.DeploymentAvailable),
515+
Status: string(corev1.ConditionTrue),
516+
}
517+
518+
// Checks if the Type: "Ready" Condition is "True"
519+
readyConditionProbe = &probing.ObservedGenerationProbe{
520+
Prober: &probing.ConditionProbe{
521+
Type: "Ready",
522+
Status: "True",
523+
},
524+
}
525+
526+
// Checks if .status.updatedReplicas == .status.replicas.
527+
// Works for StatefulSts, Deployments and ReplicaSets.
528+
replicasUpdatedProbe = &probing.FieldsEqualProbe{
529+
FieldA: ".status.updatedReplicas",
530+
FieldB: ".status.replicas",
531+
}
532+
)

internal/operator-controller/rukpak/render/registryv1/generators/generators.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,7 @@ func BundleCSVPermissionsGenerator(rv1 *bundle.RegistryV1, opts render.Options)
122122
for _, ns := range opts.TargetNamespaces {
123123
for _, permission := range permissions {
124124
saName := saNameOrDefault(permission.ServiceAccountName)
125-
name, err := opts.UniqueNameGenerator(fmt.Sprintf("%s-%s", rv1.CSV.Name, saName), permission)
126-
if err != nil {
127-
return nil, err
128-
}
125+
name := opts.UniqueNameGenerator(fmt.Sprintf("%s-%s", rv1.CSV.Name, saName), permission)
129126

130127
objs = append(objs,
131128
CreateRoleResource(name, ns, WithRules(permission.Rules...)),
@@ -167,10 +164,7 @@ func BundleCSVClusterPermissionsGenerator(rv1 *bundle.RegistryV1, opts render.Op
167164
objs := make([]client.Object, 0, 2*len(clusterPermissions))
168165
for _, permission := range clusterPermissions {
169166
saName := saNameOrDefault(permission.ServiceAccountName)
170-
name, err := opts.UniqueNameGenerator(fmt.Sprintf("%s-%s", rv1.CSV.Name, saName), permission)
171-
if err != nil {
172-
return nil, err
173-
}
167+
name := opts.UniqueNameGenerator(fmt.Sprintf("%s-%s", rv1.CSV.Name, saName), permission)
174168
objs = append(objs,
175169
CreateClusterRoleResource(name, WithRules(permission.Rules...)),
176170
CreateClusterRoleBindingResource(

internal/operator-controller/rukpak/render/registryv1/generators/generators_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ func Test_BundleCSVDeploymentGenerator_FailsOnNil(t *testing.T) {
352352
}
353353

354354
func Test_BundleCSVPermissionsGenerator_Succeeds(t *testing.T) {
355-
fakeUniqueNameGenerator := func(base string, _ interface{}) (string, error) {
356-
return base, nil
355+
fakeUniqueNameGenerator := func(base string, _ interface{}) string {
356+
return base
357357
}
358358

359359
for _, tc := range []struct {
@@ -786,8 +786,8 @@ func Test_BundleCSVPermissionGenerator_FailsOnNil(t *testing.T) {
786786
}
787787

788788
func Test_BundleCSVClusterPermissionsGenerator_Succeeds(t *testing.T) {
789-
fakeUniqueNameGenerator := func(base string, _ interface{}) (string, error) {
790-
return base, nil
789+
fakeUniqueNameGenerator := func(base string, _ interface{}) string {
790+
return base
791791
}
792792

793793
for _, tc := range []struct {

0 commit comments

Comments
 (0)