-
Notifications
You must be signed in to change notification settings - Fork 176
ROX-13943: Hide "sourced" autogenerated image integrations behind a feature flag #4160
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
Changes from all commits
c461758
402359c
1d67722
53652ca
3f4fdd9
403135f
45ec03d
754801c
30c8e64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import ( | |
| "github.com/stackrox/rox/central/imageintegration/store/bolt" | ||
| "github.com/stackrox/rox/central/imageintegration/store/postgres" | ||
| "github.com/stackrox/rox/pkg/env" | ||
| "github.com/stackrox/rox/pkg/features" | ||
| "github.com/stackrox/rox/pkg/sac" | ||
| "github.com/stackrox/rox/pkg/sync" | ||
| "github.com/stackrox/rox/pkg/utils" | ||
|
|
@@ -22,16 +23,40 @@ var ( | |
| dataStore DataStore | ||
| ) | ||
|
|
||
| func initializeDefaultIntegrations(storage store.Store) { | ||
| func initializeIntegrations(storage store.Store) { | ||
| ctx := sac.WithGlobalAccessScopeChecker(context.Background(), sac.AllowAllAccessScopeChecker()) | ||
| iis, err := storage.GetAll(ctx) | ||
| utils.CrashOnError(err) | ||
| // If we are starting from scratch in online-mode, add the default image integrations. | ||
| if !env.OfflineModeEnv.BooleanSetting() && len(iis) == 0 { | ||
| // Add default integrations | ||
| for _, ii := range store.DefaultImageIntegrations { | ||
| utils.Must(storage.Upsert(ctx, ii)) | ||
| } | ||
| } | ||
|
|
||
|
RTann marked this conversation as resolved.
|
||
| // If the feature flag is disabled, remove all "sourced" autogenerated registries from the datastore. | ||
| if !features.SourcedAutogeneratedIntegrations.Enabled() { | ||
| if len(iis) > 0 { | ||
| log.Infof("[STARTUP] Starting deletion of 'sourced' image integrations") | ||
| } | ||
|
|
||
| var attempted, deleted int | ||
| for _, ii := range iis { | ||
| if ii.GetAutogenerated() && ii.GetSource() != nil { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When there's customer who migrate from 3.72.0 -> 3.73.0, they will have the mix of autogenerated integrations with In case of a "clean" installation of 3.73.0, all autogenerated image integrations will have So, we will delete all autogenerated image integrations then. In that case, how will the recovery look like for this? Will it be eventual consistent such that the autogenerated registries we expect to have (i.e. for internal OpenShift registry) will show up after some time, or does that require bumps of sensors to send the autogenerated registries once more? (I honestly don't think that the OpenShift internal ones are that important from an autogenerated image integration perspective, unless central can reach them, which won't be the case for most of them)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the case of a clean install, I'd expect us to eventually find all the autogenerated registries. When it comes to OpenShift internal registry, we do not use the stuff sent to Central for that |
||
| attempted++ | ||
| // Use Should so release versions do not panic. | ||
| if err := utils.ShouldErr(storage.Delete(ctx, ii.GetId())); err != nil { | ||
| deleted++ | ||
| } | ||
| } | ||
| } | ||
|
RTann marked this conversation as resolved.
|
||
| if attempted > 0 { | ||
| log.Infof("Successfully deleted %d out of %d image integration(s)", deleted, attempted) | ||
| } | ||
|
|
||
| log.Info("Completed deletion of 'sourced' image integrations") | ||
| } | ||
| } | ||
|
|
||
| func initialize() { | ||
|
|
@@ -46,7 +71,7 @@ func initialize() { | |
| storage = bolt.New(globaldb.GetGlobalDB()) | ||
| indexer = index.New(globalindex.GetGlobalTmpIndex()) | ||
| } | ||
| initializeDefaultIntegrations(storage) | ||
| initializeIntegrations(storage) | ||
| searcher := search.New(storage, indexer) | ||
| dataStore = New(storage, indexer, searcher) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ import ( | |
| "github.com/stackrox/rox/pkg/centralsensor" | ||
| "github.com/stackrox/rox/pkg/env" | ||
| "github.com/stackrox/rox/pkg/errox" | ||
| "github.com/stackrox/rox/pkg/features" | ||
| "github.com/stackrox/rox/pkg/logging" | ||
| "github.com/stackrox/rox/pkg/metrics" | ||
| "github.com/stackrox/rox/pkg/set" | ||
|
|
@@ -65,6 +66,10 @@ type pipelineImpl struct { | |
| } | ||
|
|
||
| func (s *pipelineImpl) Reconcile(ctx context.Context, clusterID string, storeMap *reconciliation.StoreMap) error { | ||
| if !features.SourcedAutogeneratedIntegrations.Enabled() { | ||
| return nil | ||
| } | ||
|
|
||
| existingIDs := set.NewStringSet() | ||
|
|
||
| conn := connection.FromContext(ctx) | ||
|
|
@@ -247,7 +252,8 @@ func (s *pipelineImpl) Run(ctx context.Context, clusterID string, msg *central.M | |
| } | ||
| defer countMetrics.IncrementResourceProcessedCounter(pipeline.ActionToOperation(msg.GetEvent().GetAction()), metrics.ImageIntegration) | ||
|
|
||
| if msg.GetEvent().GetAction() == central.ResourceAction_REMOVE_RESOURCE { | ||
| if features.SourcedAutogeneratedIntegrations.Enabled() && msg.GetEvent().GetAction() == central.ResourceAction_REMOVE_RESOURCE { | ||
| // Remove is only supported if the feature flag is enabled. | ||
| return s.runRemove(ctx, msg.GetEvent().GetImageIntegration().GetId()) | ||
| } | ||
|
|
||
|
|
@@ -269,7 +275,8 @@ func (s *pipelineImpl) Run(ctx context.Context, clusterID string, msg *central.M | |
| return errors.Wrapf(err, "setting up integration params for %q", imageIntegration.GetId()) | ||
| } | ||
| source := imageIntegration.GetSource() | ||
| if source == nil { | ||
| if !features.SourcedAutogeneratedIntegrations.Enabled() || source == nil { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we don't speak about autogenerated when the flag is disabled?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This flag is specifically for the new version of autogenerated registries introduced in 3.73.0: ones with this |
||
| imageIntegration.Name = fmt.Sprintf("Autogenerated %s for cluster %s", description, clusterName) | ||
| return s.legacyRun(ctx, imageIntegration, matches) | ||
| } | ||
| imageIntegration.Name = fmt.Sprintf("Autogenerated %s for cluster %s from %s/%s", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mental boolean compiler claims the code and the comment do not quite match. Applying De Morgan's rule:
This reads to me as "Upsert all if feature is enabled, otherwise skip autogenerated and those with non-nil source". The autogenerated with non-nil source indeed will be inserted only when feature is enabled but what about non-autogenerated with non-nil source?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Sourcefield was added into 73 and its addition has caused some issues. The goal is to ensure when the feature flag is turned off, we revert back to the old implementation, which inserted all autogenerated registries. TheSourcefield should not be populated when the flag is off, so this check is meant to ensure that, if it did somehow pass through, only registries withoutSourceare upserted