-
Notifications
You must be signed in to change notification settings - Fork 89
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
Add migration.PlanGeneratorOption to configure a PlanGenerator #173
Conversation
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.
- Checked that with
migration.WithErrorOnInvalidPatchSchema(false)
the migrator under test is reporting errors without the blocking failure:
2023/04/12 22:50:33 Excluding the patch from the migration target because conformance checking has failed with: failed to check whether the patch conforms to the target schema: failed to assert patch schema for path: spec.forProvider.tags.uid: failed to assert source struct field kind at path: uid: type is not a struct:
2023/04/12 22:50:33 Excluding the patch from the migration target because conformance checking has failed with: failed to check whether the patch conforms to the target schema: failed to assert patch schema for path: spec.forProvider.tags.deployment_guid: failed to assert source struct field kind at path: deployment_guid: type is not a struct:
2023/04/12 22:50:33 Excluding the patch from the migration target because conformance checking has failed with: failed to check whether the patch conforms to the target schema: failed to assert patch schema for path: spec.forProvider.tags.app: failed to assert source struct field kind at path: app: type is not a struct:
echo $?
0
- Tried to skip specific GVK but unfortunately failed
Skip config:
+ pg := migration.NewPlanGenerator(converters.Registry, source, target, migration.WithErrorOnInvalidPatchSchema(false), migration.WithSkipGVKs(schema.GroupVersionKind{
+ Group: "ec2.aws.crossplane.io",
+ Kind: "SecurityGroup",
+ Version: "v1beta1",
The migrated Composition still has
- base:
apiVersion: ec2.aws.upbound.io/v1beta1
kind: SecurityGroup
I added verbosity to associated function
if pg.isGVKSkipped(gvkSource) {
+ fmt.Println("skipping", gvkSource)
return nil
}
and pretty sure that it was treated as skipped
go run cmd/migrator/main.go
skipping ec2.aws.crossplane.io/v1beta1, Kind=SecurityGroup
skipping ec2.aws.crossplane.io/v1beta1, Kind=SecurityGroup
skipping ec2.aws.crossplane.io/v1beta1, Kind=SecurityGroup
...
but the migrated SecurityGroup is still in the resulting Composition
Thank @ytsarev for giving it a spin. Regarding the I think what you are expecting as a result of that configuration is to skip any Do we also need the current behavior, where we would like to still keep a target |
My expectation is that the target Composition would have an intact source 'ec2.aws.crossplane.io' in this specific example. More aggressive example is when source Composition has some special resource base, e.g. from some private provider Consider this to be a part of the source Composition
The migration will fail with
even when we have current skip GVK config of
So full conversion skip but keeping the original source config in the target Composition would make sense here. |
I think why the skip configuration did not behave as expected is because the API group of the We can also employ regular expressions here so that the specification language we use can be more powerful. |
@ulucinar thanks for the clarification! The switch to exact group specification In other words, I would expect skipping migration to mean 'transfer the GVK base as it is to target Composition' instead of 'omit the GVK fully' |
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.
We synced up with @ulucinar and I just double checked the skipping mechanism on my side - it actually transfers the unchanged resource base to the target composition.
So everything behaves as expected, thanks for the amazing job, Alper!
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.
Thanks @ulucinar LGTM!
…hema checking errors Signed-off-by: Alper Rifat Ulucinar <[email protected]>
…ssing of specific GVKs Signed-off-by: Alper Rifat Ulucinar <[email protected]>
Description of your changes
Depends on: #153
This PR introduces the
migration.PlanGeneratorOption
to configure aPlanGenerator
in the migrators. Currently, the available configuration options are:migration.WithErrorOnInvalidPatchSchema
: The migrators will now, by default, not error if issues are encountered while doing a patch schema check against the migration sources & targets and will exclude the patches in the migration targetComposedTemplate
s after logging the issues. A migrator can revert back to the previous behavior by setting this option on thePlanGenerator
.migration.WithSkipGVKs
: Allows the migrators to configure a list of GVKs that will not be converted during a migration. Wildcard GVKs can be specified by either leaving the API group, version or kind empty. For example, if the kind of a GVK in the skip list is empty, then all kinds in the specified GV will be skipped. List of skipped GVKs override any converters registered with thePlanGenerator
's registry, i.e., even if there's a converter registered for a GVK and the GVK is also in the skip list, then the converter will not be run. Resources associated with skipped GVKs are included in the generated migration resources with no further checks or filtering.This PR also fixes an issue observed when a resource type containing a nested
runtime.RawExtension
field is being migrated. Migration now continues without any further checks onruntime.RawExtension
s. Currently, the framework just traverses the type hierarchy and being able to follow the structure specified by theRawExtension
would require us to take the actual values into consideration so initially we just stop checking and filtering at the level aRawExtension
is encountered.I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR if necessary.How has this code been tested
Manually validated against a migrator converting provider-kubernetes
Object
s.Object
s have aruntime.RawExtension
at pathspec.forProvider.manifest
.