This is an automated email from the ASF dual-hosted git repository. nferraro pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit fd02e812be5cade7bc5866f1b00be89f9cc37b73 Author: Nicola Ferraro <[email protected]> AuthorDate: Tue May 5 13:47:06 2020 +0200 Fix #1367: add more build events --- cmd/util/doc-gen/generators/traitdocgen.go | 3 - deploy/camel-catalog-1.3.0-SNAPSHOT-main.yaml | 131 ++++++++++----------- deploy/camel-catalog-1.3.0-SNAPSHOT-quarkus.yaml | 33 ++++-- deploy/resources.go | 12 +- pkg/controller/build/action.go | 12 +- pkg/controller/build/build_controller.go | 5 +- pkg/controller/build/schedule_routine.go | 11 +- .../integration/integration_controller.go | 4 +- .../integrationkit/integrationkit_controller.go | 4 +- pkg/event/injectable.go | 7 ++ pkg/event/manager.go | 20 ++-- pkg/metadata/metadata_dependencies_test.go | 2 + pkg/util/watch/watch.go | 53 ++++++++- 13 files changed, 190 insertions(+), 107 deletions(-) diff --git a/cmd/util/doc-gen/generators/traitdocgen.go b/cmd/util/doc-gen/generators/traitdocgen.go index 2d0bd7e..ec3ef23 100644 --- a/cmd/util/doc-gen/generators/traitdocgen.go +++ b/cmd/util/doc-gen/generators/traitdocgen.go @@ -50,9 +50,6 @@ const ( adocNavMarkerStart = adocCommonMarkerStart + " (trait-nav)" adocNavMarkerEnd = adocCommonMarkerEnd + " (trait-nav)" - - adocListMarkerStart = adocCommonMarkerStart + " (trait-list)" - adocListMarkerEnd = adocCommonMarkerEnd + " (trait-list)" ) var ( diff --git a/deploy/camel-catalog-1.3.0-SNAPSHOT-main.yaml b/deploy/camel-catalog-1.3.0-SNAPSHOT-main.yaml index 6e10f19..fcd877b 100644 --- a/deploy/camel-catalog-1.3.0-SNAPSHOT-main.yaml +++ b/deploy/camel-catalog-1.3.0-SNAPSHOT-main.yaml @@ -21,8 +21,8 @@ metadata: name: camel-catalog-1.3.0-snapshot-main labels: app: camel-k - camel.apache.org/catalog.version: 3.1.0 - camel.apache.org/catalog.loader.version: 3.1.0 + camel.apache.org/catalog.version: 3.2.0 + camel.apache.org/catalog.loader.version: 3.2.0 camel.apache.org/runtime.version: 1.3.0-SNAPSHOT camel.apache.org/runtime.provider: main spec: @@ -31,9 +31,9 @@ spec: provider: main applicationClass: org.apache.camel.k.main.Application metadata: - camel.version: 3.1.0 - quarkus.version: 1.3.2.Final - camel-quarkus.version: 1.0.0-M6 + camel.version: 3.2.0 + quarkus.version: 1.4.1.Final + camel-quarkus.version: 1.0.0-M7 dependencies: - groupId: org.apache.camel.k artifactId: camel-k-runtime-main @@ -1099,6 +1099,19 @@ spec: passive: false javaTypes: - org.apache.camel.component.aws2.sqs.Sqs2Component + camel-aws2-kinesis: + groupId: org.apache.camel + artifactId: camel-aws2-kinesis + schemes: + - id: aws2-kinesis + http: false + passive: false + - id: aws2-kinesis-firehose + http: false + passive: false + javaTypes: + - org.apache.camel.component.aws2.kinesis.Kinesis2Component + - org.apache.camel.component.aws2.firehose.KinesisFirehose2Component camel-reactive-streams: groupId: org.apache.camel artifactId: camel-reactive-streams @@ -1148,15 +1161,6 @@ spec: javaTypes: - org.apache.camel.component.dataset.DataSetComponent - org.apache.camel.component.dataset.DataSetTestComponent - camel-elytron: - groupId: org.apache.camel - artifactId: camel-elytron - schemes: - - id: elytron - http: false - passive: false - javaTypes: - - org.apache.camel.component.elytron.ElytronComponent camel-jsonapi: groupId: org.apache.camel artifactId: camel-jsonapi @@ -1330,6 +1334,25 @@ spec: passive: false javaTypes: - org.apache.camel.component.timer.TimerComponent + camel-core-languages: + groupId: org.apache.camel + artifactId: camel-core-languages + languages: + - constant + - exchangeProperty + - file + - header + - ref + - simple + - tokenize + javaTypes: + - org.apache.camel.language.constant.ConstantLanguage + - org.apache.camel.language.property.ExchangePropertyLanguage + - org.apache.camel.language.simple.FileLanguage + - org.apache.camel.language.header.HeaderLanguage + - org.apache.camel.language.ref.RefLanguage + - org.apache.camel.language.simple.SimpleLanguage + - org.apache.camel.language.tokenizer.TokenizeLanguage camel-jcache: groupId: org.apache.camel artifactId: camel-jcache @@ -1399,15 +1422,6 @@ spec: - jsonpath javaTypes: - org.apache.camel.jsonpath.JsonPathLanguage - camel-spark-rest: - groupId: org.apache.camel - artifactId: camel-spark-rest - schemes: - - id: spark-rest - http: true - passive: false - javaTypes: - - org.apache.camel.component.sparkrest.SparkComponent camel-jt400: groupId: org.apache.camel artifactId: camel-jt400 @@ -1548,15 +1562,6 @@ spec: passive: false javaTypes: - org.apache.camel.component.master.MasterComponent - camel-eventadmin: - groupId: org.apache.camel - artifactId: camel-eventadmin - schemes: - - id: eventadmin - http: false - passive: false - javaTypes: - - org.apache.camel.component.eventadmin.EventAdminComponent camel-optaplanner: groupId: org.apache.camel artifactId: camel-optaplanner @@ -1711,14 +1716,9 @@ spec: camel-avro: groupId: org.apache.camel artifactId: camel-avro - schemes: - - id: avro - http: false - passive: false dataformats: - avro javaTypes: - - org.apache.camel.component.avro.AvroComponent - org.apache.camel.dataformat.avro.AvroDataFormat camel-mllp: groupId: org.apache.camel @@ -1747,6 +1747,15 @@ spec: passive: false javaTypes: - org.apache.camel.component.elsql.ElsqlComponent + camel-aws2-lambda: + groupId: org.apache.camel + artifactId: camel-aws2-lambda + schemes: + - id: aws2-lambda + http: false + passive: false + javaTypes: + - org.apache.camel.component.aws2.lambda.Lambda2Component camel-aws-msk: groupId: org.apache.camel artifactId: camel-aws-msk @@ -2365,25 +2374,6 @@ spec: passive: false javaTypes: - org.apache.camel.component.aws2.msk.MSK2Component - camel-base: - groupId: org.apache.camel - artifactId: camel-base - languages: - - constant - - exchangeProperty - - file - - header - - ref - - simple - - tokenize - javaTypes: - - org.apache.camel.language.constant.ConstantLanguage - - org.apache.camel.language.property.ExchangePropertyLanguage - - org.apache.camel.language.simple.FileLanguage - - org.apache.camel.language.header.HeaderLanguage - - org.apache.camel.language.ref.RefLanguage - - org.apache.camel.language.simple.SimpleLanguage - - org.apache.camel.language.tokenizer.TokenizeLanguage camel-jpa: groupId: org.apache.camel artifactId: camel-jpa @@ -2393,6 +2383,15 @@ spec: passive: false javaTypes: - org.apache.camel.component.jpa.JpaComponent + camel-avro-rpc: + groupId: org.apache.camel + artifactId: camel-avro-rpc + schemes: + - id: avro + http: false + passive: false + javaTypes: + - org.apache.camel.component.avro.AvroComponent camel-cassandraql: groupId: org.apache.camel artifactId: camel-cassandraql @@ -2431,6 +2430,15 @@ spec: - syslog javaTypes: - org.apache.camel.component.syslog.SyslogDataFormat + camel-aws2-s3: + groupId: org.apache.camel + artifactId: camel-aws2-s3 + schemes: + - id: aws2-s3 + http: false + passive: false + javaTypes: + - org.apache.camel.component.aws2.s3.AWS2S3Component camel-pubnub: groupId: org.apache.camel artifactId: camel-pubnub @@ -2490,7 +2498,7 @@ spec: dataformats: - secureXML javaTypes: - - org.apache.camel.component.xmlsecurity.XmlSignatureComponent + - org.apache.camel.component.xmlsecurity.XmlSignerComponent - org.apache.camel.component.xmlsecurity.XmlVerifierComponent - org.apache.camel.dataformat.xmlsecurity.XMLSecurityDataFormat camel-bonita: @@ -2583,15 +2591,6 @@ spec: passive: false javaTypes: - org.apache.camel.component.xchange.XChangeComponent - camel-paxlogging: - groupId: org.apache.camel - artifactId: camel-paxlogging - schemes: - - id: paxlogging - http: false - passive: false - javaTypes: - - org.apache.camel.component.paxlogging.PaxLoggingComponent camel-tarfile: groupId: org.apache.camel artifactId: camel-tarfile diff --git a/deploy/camel-catalog-1.3.0-SNAPSHOT-quarkus.yaml b/deploy/camel-catalog-1.3.0-SNAPSHOT-quarkus.yaml index f0e3468..1c39eda 100644 --- a/deploy/camel-catalog-1.3.0-SNAPSHOT-quarkus.yaml +++ b/deploy/camel-catalog-1.3.0-SNAPSHOT-quarkus.yaml @@ -21,8 +21,8 @@ metadata: name: camel-catalog-1.3.0-snapshot-quarkus labels: app: camel-k - camel.apache.org/catalog.version: 3.1.0 - camel.apache.org/catalog.loader.version: 3.1.0 + camel.apache.org/catalog.version: 3.2.0 + camel.apache.org/catalog.loader.version: 3.2.0 camel.apache.org/runtime.version: 1.3.0-SNAPSHOT camel.apache.org/runtime.provider: quarkus spec: @@ -31,9 +31,9 @@ spec: provider: quarkus applicationClass: io.quarkus.runner.GeneratedMain metadata: - camel.version: 3.1.0 - quarkus.version: 1.3.2.Final - camel-quarkus.version: 1.0.0-M6 + camel.version: 3.2.0 + quarkus.version: 1.4.1.Final + camel-quarkus.version: 1.0.0-M7 dependencies: - groupId: org.apache.camel.k artifactId: camel-k-runtime-quarkus @@ -93,6 +93,15 @@ spec: passive: false javaTypes: - org.apache.camel.component.file.FileComponent + camel-quarkus-aws2-s3: + groupId: org.apache.camel.quarkus + artifactId: camel-quarkus-aws2-s3 + schemes: + - id: aws2-s3 + http: false + passive: false + javaTypes: + - org.apache.camel.component.aws2.s3.AWS2S3Component camel-quarkus-xpath: groupId: org.apache.camel.quarkus artifactId: camel-quarkus-xpath @@ -1131,14 +1140,9 @@ spec: camel-quarkus-avro: groupId: org.apache.camel.quarkus artifactId: camel-quarkus-avro - schemes: - - id: avro - http: false - passive: false dataformats: - avro javaTypes: - - org.apache.camel.component.avro.AvroComponent - org.apache.camel.dataformat.avro.AvroDataFormat camel-quarkus-couchbase: groupId: org.apache.camel.quarkus @@ -1303,6 +1307,15 @@ spec: passive: false javaTypes: - org.apache.camel.component.infinispan.InfinispanComponent + camel-quarkus-avro-rpc: + groupId: org.apache.camel.quarkus + artifactId: camel-quarkus-avro-rpc + schemes: + - id: avro + http: false + passive: false + javaTypes: + - org.apache.camel.component.avro.AvroComponent camel-quarkus-telegram: groupId: org.apache.camel.quarkus artifactId: camel-quarkus-telegram diff --git a/deploy/resources.go b/deploy/resources.go index 73ccf3e..c9efe1e 100644 --- a/deploy/resources.go +++ b/deploy/resources.go @@ -91,16 +91,16 @@ var assets = func() http.FileSystem { "/camel-catalog-1.3.0-SNAPSHOT-main.yaml": &vfsgen۰CompressedFileInfo{ name: "camel-catalog-1.3.0-SNAPSHOT-main.yaml", modTime: time.Time{}, - uncompressedSize: 87358, + uncompressedSize: 87389, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\xbd\x5b\x77\xdb\x38\xb2\x2f\xfe\x9e\x4f\xc1\x35\x79\xd9\x7b\xfd\x47\x98\x6e\x67\xf6\xf4\x7f\xf7\x79\xb2\xe5\x38\xb1\x63\x3b\xee\xd0\x93\x64\xfa\xa5\x17\x44\x42\x12\x2c\x92\xa0\x01\x48\x96\xfd\xe9\xcf\xc2\x85\x57\x41\x90\xc8\x32\xbc\x8e\x1f\x4c\x8a\xa8\xfa\x15\x0b\x00\x71\x2d\x54\xbd\x8f\x26\xaf\xf7\xf7\xee\x7d\x74\x4d\x13\x52\x08\x92\x46\x92\x45\x72\x49\xa2\xd3\x12\x27\x4b\x12\xc5\x6c\x2e\x9f\x30\x27\xd1\x05\x5b\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\xbd\x5b\x77\xdb\x38\xb2\x2f\xfe\x9e\x4f\xc1\x35\x79\xd9\x7b\xfd\x47\x35\xdd\xce\xec\xe9\xff\xee\xf3\x64\xcb\x71\x62\xc7\x76\xdc\xa1\x27\xc9\xf4\x4b\x2f\x88\x84\x24\x58\x24\x41\x03\x90\x2c\xfb\xd3\x9f\x85\x0b\xaf\x82\x20\x91\x30\xbc\x8e\x1f\x4c\x8a\xa8\xfa\x15\x8a\x00\x71\x2d\x54\xbd\x8f\x26\xaf\xf7\xf7\xee\x7d\x74\x4d\x12\x5c\x70\x9c\x46\x82\x46\x62\x89\xa3\xd3\x12\x25\x4b\x1c\xc5\x74\x2e\x9e\x10\xc3\xd1\x05\x5d\x [...] }, "/camel-catalog-1.3.0-SNAPSHOT-quarkus.yaml": &vfsgen۰CompressedFileInfo{ name: "camel-catalog-1.3.0-SNAPSHOT-quarkus.yaml", modTime: time.Time{}, - uncompressedSize: 46798, + uncompressedSize: 47185, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x7d\x4d\x77\xdc\xa8\xf2\xf7\xde\x9f\x82\x13\x6f\xee\x3d\x67\xc4\xcc\x75\x9e\x3b\x8b\x3c\x2b\xdb\x89\x13\x3b\xb1\xe3\xa4\x7d\x27\x99\xd9\xe4\xd0\x12\xdd\x8d\x5b\x02\x19\x50\x77\xdb\x9f\xfe\x7f\x40\xe8\xad\x5b\x2e\xbd\x18\xd9\x0b\x4b\x2d\x8a\x5f\x41\x81\xa0\xa8\x2a\xd0\x31\x0a\xfc\xfd\x1d\x1d\xa3\x2f\x2c\xa4\x5c\xd1\x08\x69\x81\xf4\x8a\xa2\xd3\x94\x84\x2b\x8a\x66\x62\xa1\xb7\x44\x52\x74\x21\x32\x1e\x11\xcd\x04\x47\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x7d\x5d\x73\xdc\x2a\xf2\xf7\xbd\x3f\x05\x15\xdf\xec\x56\x1d\x71\xce\x3a\xbb\xfb\x54\xe5\xb9\xb2\x9d\x38\xb1\x13\x3b\x4e\xc6\x7b\x92\x73\x6e\x52\x8c\xc4\xcc\xe0\x91\x40\x06\x34\x33\xf6\xa7\xff\x17\x08\xbd\x8d\xe5\xd6\x8b\xd1\xf8\xc2\xd2\x88\xe6\xd7\xd0\x20\x68\x75\x37\x70\x8c\x02\x7f\x7f\x47\xc7\xe8\x0b\x0b\x29\x57\x34\x42\x5a\x20\xbd\xa2\xe8\x34\x25\xe1\x8a\xa2\x99\x58\xe8\x2d\x91\x14\x5d\x88\x8c\x47\x44\x33\xc1\x [...] }, "/cr-example.yaml": &vfsgen۰CompressedFileInfo{ name: "cr-example.yaml", @@ -340,9 +340,9 @@ var assets = func() http.FileSystem { "/traits.yaml": &vfsgen۰CompressedFileInfo{ name: "traits.yaml", modTime: time.Time{}, - uncompressedSize: 28816, + uncompressedSize: 29816, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd4\x7d\x6d\x6f\x1c\x37\x92\xf0\x77\xff\x0a\x42\xcf\x03\xe8\x05\x33\x2d\x39\x8b\xdd\x64\xf5\xc0\x08\xf4\x28\xce\xae\x9c\xd8\xd6\x59\x4e\xf6\x0e\xb9\x60\x87\xd3\x5d\x33\x4d\x8b\x4d\xf6\x92\xec\x91\x67\x0f\x07\xdc\xdf\xb8\xbf\x77\xbf\xe4\x50\xc5\x97\x66\xf7\x8c\xa4\x91\x1d\x05\x56\xf2\xc1\x9a\x51\x77\xb1\xaa\x58\xef\x55\xa4\x9c\xe1\xc2\xd9\xd3\x67\x53\xa6\x78\x03\xa7\x8c\x2f\x16\x42\x09\xb7\x7e\xc6\x58\x2b\xb9\x5b\x68\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd4\x7d\x6d\x6f\x1c\x37\x92\xf0\x77\xff\x0a\x42\xcf\x03\xe8\x05\x33\x2d\x39\x8b\xdd\x64\xf5\xc0\x08\xf4\x28\xce\xae\x9c\xd8\xd6\x59\x4e\xf6\x0e\xb9\x60\x87\xd3\x5d\x33\x4d\x8b\x4d\xf6\x92\xec\x91\x67\x0f\x07\xdc\xdf\xb8\xbf\x77\xbf\xe4\x50\xc5\x97\x66\xcf\x8c\xa4\x96\x1d\x05\x56\xf2\xc1\x1a\xa9\xbb\x58\x55\xac\xf7\x2a\x72\x9c\xe1\xc2\xd9\xd3\x67\x53\xa6\x78\x03\xa7\x8c\x2f\x16\x42\x09\xb7\x7e\xc6\x58\x2b\xb9\x5b\x68\x [...] }, "/user-cluster-role.yaml": &vfsgen۰CompressedFileInfo{ name: "user-cluster-role.yaml", diff --git a/pkg/controller/build/action.go b/pkg/controller/build/action.go index cd08667..ae3914d 100644 --- a/pkg/controller/build/action.go +++ b/pkg/controller/build/action.go @@ -22,13 +22,16 @@ import ( v1 "github.com/apache/camel-k/pkg/apis/camel/v1" "github.com/apache/camel-k/pkg/client" + camelevent "github.com/apache/camel-k/pkg/event" "github.com/apache/camel-k/pkg/util/log" + "k8s.io/client-go/tools/record" ) // Action -- type Action interface { client.Injectable log.Injectable + camelevent.Injectable // a user friendly name for the action Name() string @@ -41,8 +44,9 @@ type Action interface { } type baseAction struct { - client client.Client - L log.Logger + client client.Client + L log.Logger + recorder record.EventRecorder } func (action *baseAction) InjectClient(client client.Client) { @@ -52,3 +56,7 @@ func (action *baseAction) InjectClient(client client.Client) { func (action *baseAction) InjectLogger(log log.Logger) { action.L = log } + +func (action *baseAction) InjectRecorder(recorder record.EventRecorder) { + action.recorder = recorder +} diff --git a/pkg/controller/build/build_controller.go b/pkg/controller/build/build_controller.go index 092dc68..d9e771f 100644 --- a/pkg/controller/build/build_controller.go +++ b/pkg/controller/build/build_controller.go @@ -202,6 +202,7 @@ func (r *ReconcileBuild) Reconcile(request reconcile.Request) (reconcile.Result, for _, a := range actions { a.InjectClient(r.client) a.InjectLogger(targetLog) + a.InjectRecorder(r.recorder) if a.CanHandle(target) { targetLog.Infof("Invoking action %s", a.Name()) @@ -218,10 +219,10 @@ func (r *ReconcileBuild) Reconcile(request reconcile.Request) (reconcile.Result, return res, err } - if newTarget.Status.Phase != target.Status.Phase { + if newTarget.Status.Phase != instance.Status.Phase { targetLog.Info( "state transition", - "phase-from", target.Status.Phase, + "phase-from", instance.Status.Phase, "phase-to", newTarget.Status.Phase, ) } diff --git a/pkg/controller/build/schedule_routine.go b/pkg/controller/build/schedule_routine.go index 62e2db8..26fd0d3 100644 --- a/pkg/controller/build/schedule_routine.go +++ b/pkg/controller/build/schedule_routine.go @@ -22,14 +22,13 @@ import ( "fmt" "sync" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - - "sigs.k8s.io/controller-runtime/pkg/client" - v1 "github.com/apache/camel-k/pkg/apis/camel/v1" "github.com/apache/camel-k/pkg/builder" + camelevent "github.com/apache/camel-k/pkg/event" "github.com/apache/camel-k/pkg/util/patch" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" ) // NewScheduleRoutineAction creates a new schedule routine action @@ -91,6 +90,7 @@ func (action *scheduleRoutineAction) Handle(ctx context.Context, build *v1.Build if err != nil { return nil, err } + camelevent.NotifyBuildUpdated(ctx, action.client, action.recorder, build, target) // Start the build asynchronously to avoid blocking the reconcile loop action.routines.Store(build.Name, true) @@ -156,6 +156,7 @@ func (action *scheduleRoutineAction) updateBuildStatus(ctx context.Context, buil action.L.Errorf(err, "Cannot update build status: %s", build.Name) return err } + camelevent.NotifyBuildUpdated(ctx, action.client, action.recorder, build, target) build.Status = target.Status return nil } diff --git a/pkg/controller/integration/integration_controller.go b/pkg/controller/integration/integration_controller.go index b23c020..dbc9302 100644 --- a/pkg/controller/integration/integration_controller.go +++ b/pkg/controller/integration/integration_controller.go @@ -281,10 +281,10 @@ func (r *ReconcileIntegration) Reconcile(request reconcile.Request) (reconcile.R return res, err } - if newTarget.Status.Phase != target.Status.Phase { + if newTarget.Status.Phase != instance.Status.Phase { targetLog.Info( "state transition", - "phase-from", target.Status.Phase, + "phase-from", instance.Status.Phase, "phase-to", newTarget.Status.Phase, ) } diff --git a/pkg/controller/integrationkit/integrationkit_controller.go b/pkg/controller/integrationkit/integrationkit_controller.go index dd4b271..d16def6 100644 --- a/pkg/controller/integrationkit/integrationkit_controller.go +++ b/pkg/controller/integrationkit/integrationkit_controller.go @@ -237,10 +237,10 @@ func (r *ReconcileIntegrationKit) Reconcile(request reconcile.Request) (reconcil return res, err } - if newTarget.Status.Phase != target.Status.Phase { + if newTarget.Status.Phase != instance.Status.Phase { targetLog.Info( "state transition", - "phase-from", target.Status.Phase, + "phase-from", instance.Status.Phase, "phase-to", newTarget.Status.Phase, ) } diff --git a/pkg/event/injectable.go b/pkg/event/injectable.go new file mode 100644 index 0000000..6854054 --- /dev/null +++ b/pkg/event/injectable.go @@ -0,0 +1,7 @@ +package event + +import "k8s.io/client-go/tools/record" + +type Injectable interface { + InjectRecorder(recorder record.EventRecorder) +} diff --git a/pkg/event/manager.go b/pkg/event/manager.go index f446b9a..43d1051 100644 --- a/pkg/event/manager.go +++ b/pkg/event/manager.go @@ -90,7 +90,7 @@ func NotifyIntegrationUpdated(ctx context.Context, c client.Client, recorder rec if new.Status.Phase != v1.IntegrationPhaseNone { notifyIfConditionUpdated(recorder, new, oldConditions, new.Status.GetConditions(), "Integration", new.Name, ReasonIntegrationConditionChanged) } - notifyIfPhaseUpdated(ctx, c, recorder, new, oldPhase, string(new.Status.Phase), "Integration", new.Name, ReasonIntegrationPhaseUpdated) + notifyIfPhaseUpdated(ctx, c, recorder, new, oldPhase, string(new.Status.Phase), "Integration", new.Name, ReasonIntegrationPhaseUpdated, "") } // NotifyIntegrationKitUpdated automatically generates events when an integration kit changes @@ -107,7 +107,7 @@ func NotifyIntegrationKitUpdated(ctx context.Context, c client.Client, recorder if new.Status.Phase != v1.IntegrationKitPhaseNone { notifyIfConditionUpdated(recorder, new, oldConditions, new.Status.GetConditions(), "Integration Kit", new.Name, ReasonIntegrationKitConditionChanged) } - notifyIfPhaseUpdated(ctx, c, recorder, new, oldPhase, string(new.Status.Phase), "Integration Kit", new.Name, ReasonIntegrationKitPhaseUpdated) + notifyIfPhaseUpdated(ctx, c, recorder, new, oldPhase, string(new.Status.Phase), "Integration Kit", new.Name, ReasonIntegrationKitPhaseUpdated, "") } // NotifyIntegrationKitError automatically generates error events when the integration kit reconcile cycle phase has an error @@ -136,7 +136,7 @@ func NotifyIntegrationPlatformUpdated(ctx context.Context, c client.Client, reco if new.Status.Phase != v1.IntegrationPlatformPhaseNone { notifyIfConditionUpdated(recorder, new, oldConditions, new.Status.GetConditions(), "Integration Platform", new.Name, ReasonIntegrationPlatformConditionChanged) } - notifyIfPhaseUpdated(ctx, c, recorder, new, oldPhase, string(new.Status.Phase), "Integration Platform", new.Name, ReasonIntegrationPlatformPhaseUpdated) + notifyIfPhaseUpdated(ctx, c, recorder, new, oldPhase, string(new.Status.Phase), "Integration Platform", new.Name, ReasonIntegrationPlatformPhaseUpdated, "") } // NotifyIntegrationPlatformError automatically generates error events when the integration Platform reconcile cycle phase has an error @@ -165,7 +165,13 @@ func NotifyBuildUpdated(ctx context.Context, c client.Client, recorder record.Ev if new.Status.Phase != v1.BuildPhaseNone { notifyIfConditionUpdated(recorder, new, oldConditions, new.Status.GetConditions(), "Build", new.Name, ReasonBuildConditionChanged) } - notifyIfPhaseUpdated(ctx, c, recorder, new, oldPhase, string(new.Status.Phase), "Build", new.Name, ReasonBuildPhaseUpdated) + info := "" + if new.Status.Failure != nil { + attempt := new.Status.Failure.Recovery.Attempt + attemptMax := new.Status.Failure.Recovery.AttemptMax + info = fmt.Sprintf(" (recovery %d of %d)", attempt, attemptMax) + } + notifyIfPhaseUpdated(ctx, c, recorder, new, oldPhase, string(new.Status.Phase), "Build", new.Name, ReasonBuildPhaseUpdated, info) } // NotifyBuildError automatically generates error events when the build reconcile cycle phase has an error @@ -181,17 +187,17 @@ func NotifyBuildError(ctx context.Context, c client.Client, recorder record.Even } // nolint:lll -func notifyIfPhaseUpdated(ctx context.Context, c client.Client, recorder record.EventRecorder, new runtime.Object, oldPhase, newPhase string, resourceType, name, reason string) { +func notifyIfPhaseUpdated(ctx context.Context, c client.Client, recorder record.EventRecorder, new runtime.Object, oldPhase, newPhase string, resourceType, name, reason, info string) { // Update information about phase changes if oldPhase != newPhase { phase := newPhase if phase == "" { phase = "[none]" } - recorder.Eventf(new, corev1.EventTypeNormal, reason, "%s %s in phase %s", resourceType, name, phase) + recorder.Eventf(new, corev1.EventTypeNormal, reason, "%s %s in phase %q%s", resourceType, name, phase, info) if creatorRef, creator := getCreatorObject(ctx, c, new); creatorRef != nil && creator != nil { - recorder.Eventf(creator, corev1.EventTypeNormal, ReasonRelatedObjectChanged, "%s %s dependent resource %s (%s) changed phase to %s", creatorRef.Kind, creatorRef.Name, name, resourceType, phase) + recorder.Eventf(creator, corev1.EventTypeNormal, ReasonRelatedObjectChanged, "%s %s subresource %s (%s) changed phase to %q%s", creatorRef.Kind, creatorRef.Name, name, resourceType, phase, info) } } } diff --git a/pkg/metadata/metadata_dependencies_test.go b/pkg/metadata/metadata_dependencies_test.go index 3a8f528..0e1cdcd 100644 --- a/pkg/metadata/metadata_dependencies_test.go +++ b/pkg/metadata/metadata_dependencies_test.go @@ -616,6 +616,7 @@ func TestXMLLanguageDependencies(t *testing.T) { assert.ElementsMatch( t, []string{ + "camel:core-languages", "camel:direct", "camel:ognl", "camel:saxon", @@ -736,6 +737,7 @@ func TestYAMLLanguageDependencies(t *testing.T) { assert.ElementsMatch( t, []string{ + "camel:core-languages", "camel:direct", "camel:ognl", "camel:saxon", diff --git a/pkg/util/watch/watch.go b/pkg/util/watch/watch.go index 21b08ba..9886c60 100644 --- a/pkg/util/watch/watch.go +++ b/pkg/util/watch/watch.go @@ -139,6 +139,7 @@ func HandleIntegrationEvents(ctx context.Context, integration *v1.Integration, defer watcher.Stop() events := watcher.ResultChan() + var lastEvent *corev1.Event for { select { case <-ctx.Done(): @@ -161,7 +162,8 @@ func HandleIntegrationEvents(ctx context.Context, integration *v1.Integration, return nil } - if evt.CreationTimestamp.UnixNano() >= integration.CreationTimestamp.UnixNano() { + if isAllowed(lastEvent, &evt, integration.CreationTimestamp.UnixNano()) { + lastEvent = &evt if !handler(&evt) { return nil } @@ -277,6 +279,7 @@ func HandleIntegrationPlatformEvents(ctx context.Context, p *v1.IntegrationPlatf defer watcher.Stop() events := watcher.ResultChan() + var lastEvent *corev1.Event for { select { case <-ctx.Done(): @@ -299,7 +302,8 @@ func HandleIntegrationPlatformEvents(ctx context.Context, p *v1.IntegrationPlatf return nil } - if evt.CreationTimestamp.UnixNano() >= p.CreationTimestamp.UnixNano() { + if isAllowed(lastEvent, &evt, p.CreationTimestamp.UnixNano()) { + lastEvent = &evt if !handler(&evt) { return nil } @@ -309,3 +313,48 @@ func HandleIntegrationPlatformEvents(ctx context.Context, p *v1.IntegrationPlatf } } } + +func isAllowed(lastEvent, event *corev1.Event, baseTime int64) bool { + if lastEvent == nil { + return true + } + + curTime := event.CreationTimestamp.UnixNano() + if event.LastTimestamp.UnixNano() > curTime { + curTime = event.LastTimestamp.UnixNano() + } + if curTime < baseTime { + return false + } + + lastTime := lastEvent.CreationTimestamp.UnixNano() + if lastEvent.LastTimestamp.UnixNano() > lastTime { + lastTime = lastEvent.LastTimestamp.UnixNano() + } + if curTime < lastTime { + return false + } + + if lastEvent.Reason != event.Reason { + return true + } + if lastEvent.Message != event.Message { + return true + } + if lastEvent.Type != event.Type { + return true + } + if lastEvent.InvolvedObject.Kind != event.InvolvedObject.Kind { + return true + } + if lastEvent.InvolvedObject.APIVersion != event.InvolvedObject.APIVersion { + return true + } + if lastEvent.InvolvedObject.Namespace != event.InvolvedObject.Namespace { + return true + } + if lastEvent.InvolvedObject.Name != event.InvolvedObject.Name { + return true + } + return false +}
