Skip to content
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 Snapshot selector support #17

Merged
merged 1 commit into from
Mar 14, 2024
Merged

Conversation

RichardChen820
Copy link
Contributor

Add Snapshot selector support

LabelFilter *string `json:"labelFilter,omitempty"`
KeyFilter *string `json:"keyFilter,omitempty"`
LabelFilter *string `json:"labelFilter,omitempty"`
SnapshotName *string `json:"snapshotName,omitempty"`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this not named xxxFilter? sounds inconsistent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is discussed in the design, snapshotFilter sounds not reasonable.

@@ -71,21 +71,21 @@ func verifyObject(spec acpv1.AzureAppConfigurationProviderSpec) error {

// Check if feature flag label filters are valid
for i := range spec.FeatureFlag.Selectors {
if spec.FeatureFlag.Selectors[i].LabelFilter != nil && hasNonEscapedValueInLabel(*spec.FeatureFlag.Selectors[i].LabelFilter) {
return loader.NewArgumentError("spec.featureFlag.selectors", fmt.Errorf("non-escaped reserved wildcard character '*' and multiple labels separator ',' are not supported in label filters"))
err = verifySelectorObject(spec.FeatureFlag.Selectors[i])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FeatureFlag is verifying input the same way asa Configuration.Selectors. Does this mean FeatureFlag supports Snapshot filter now?

Copy link
Contributor Author

@RichardChen820 RichardChen820 Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will filter out all the feature flag type key-values in the specified snapshot


if *snapshot.CompositionType != azappconfig.CompositionTypeKey {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only accept 'key' type and not allowing key+lable?

Copy link
Contributor Author

@RichardChen820 RichardChen820 Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is by design, it's consistent with other providers. support key+label type would cause ambiguity problem, which label would be populated is not definitive

},
}

Expect(verifyObject(configProviderSpec).Error()).Should(Equal("spec.configuration.selectors: set both keyFilter and snapshotName in one selector causes ambiguity, only one of them should be set"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'set both keyFilter...' -> 'setting both keyFilter...'

@@ -396,6 +396,7 @@ var _ = Describe("AppConfiguationProvider controller", func() {
ctx := context.Background()
providerName := "test-appconfigurationprovider-8"
configMapName := "file-style-configmap-to-be-created-2"
wildcard := "*"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can user set wildcard in SnapshotName filed?

Copy link
Contributor Author

@RichardChen820 RichardChen820 Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We allow it , but we don't treat it as wildcard, it's just a normal character

err := json.Unmarshal([]byte(*setting.Value), &out)
if err != nil {
return nil, fmt.Errorf("Failed to unmarshal feature flag settings: %s", err.Error())
if setting.ContentType != nil &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If user set snapshot in feature flag section,what's the value of setting.ContentType when feature flags from snapshot?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with what we filtered out by key/lable filters

}
}
} else {
snapshot, err := client.GetSnapshot(ctx, *filter.SnapshotName, nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add snapshot status check since it can be archived? And what's expected behavior if the snapshot expire after some interval?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Archived snapshots are still available to be used.

@@ -693,7 +718,10 @@ func getFeatureFlagFilters(acpSpec acpv1.AzureAppConfigurationProviderSpec) []ac
if acpSpec.FeatureFlag != nil {
featureFlagFilters = deduplicateFilters(acpSpec.FeatureFlag.Selectors)
for i := 0; i < len(featureFlagFilters); i++ {
featureFlagFilters[i].KeyFilter = FeatureFlagKeyPrefix + featureFlagFilters[i].KeyFilter
if featureFlagFilters[i].KeyFilter != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If user set snapshot in feature flag section, what is expected behavior? Ignoring all featureFlag.selector.snapshot ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we go ahead to use it, get the snapshot, and retrieve the feature flags settings from it.

@RichardChen820 RichardChen820 merged commit aa7bd68 into release/v1 Mar 14, 2024
2 checks passed
@RichardChen820 RichardChen820 deleted the user/junbchen/snapshot branch March 14, 2024 03:04
RichardChen820 added a commit that referenced this pull request Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants