-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(service): Implements traffic splitting and tagging targets
- Add e2e tests - Use '=' for traffic and tag assignment instead of ':' - Use --tag and --untag flags for tagging traffic targets - Use --traffic flag for setting traffic portions - Allow --traffic portion to either take revisionName or tagName - Uses @latest identifier for referencing latest revision of service - Dont throw error if requested revision=tag pair is same - Support having multiple tags for a revision - creates a new target in traffic block if revision present in traffic block with new tag requested - creates N new targets in traffic block if revision absent in traffic block with Nxnew tags requested - Ensure updating tag of @latest requires --untag flag - streamline updating tag for latestReadyRevision - adds respective tests - adds tests for ensuring given traffic sum to 100 on CLI and fail fast - Add note about preference of order in case where tagOfOneRevision == revisionOfAnother, first tags are checked and assigned traffic if any, as tags are supposed to be unique in traffic block and should be referenced in such scenario. - Remove the examples from flag description, moves it to service update command example section - Pass only traffic block to compute trffic, makes it better to consume. - Cover more error cases for invalid value format for assignments, covers a=b=c, a=, =b, or variants of them - Separate and improves the error messages - Add unit tests for traffic computing - Add sanity checks in dedicated function verifyInputSanity - traffic perents should sum to 100 - individual percent should be in 0-100 - repetition of @latest or tagName or revisionRef is disallowed - Verify traffic percents sum to 100 on client side and fail fast - Add e2e tests for traffic splitting - create and update service, assign tags and set traffic to make an existing state - run the scenario on existing state of service - form the desired state traffic block - extract the traffic block and form the traffic block struct actual state - assert.DeepEqual actual and desired traffic blocks - Use logic to generate service name in the same way as namespace, use different service name per test case - Run e2e test for traffic splitting in parallel - Use timeout duration of 30m for e2e tests, use timeout parameter for go_test_e2e library function - Use tagName in flag description of --untag, avoiding conflict with --tag flag
- Loading branch information
1 parent
c4e8d5a
commit 38a9e2b
Showing
10 changed files
with
1,168 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright © 2019 The Knative Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package flags | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
type Traffic struct { | ||
RevisionsPercentages []string | ||
RevisionsTags []string | ||
UntagRevisions []string | ||
} | ||
|
||
func (t *Traffic) Add(cmd *cobra.Command) { | ||
cmd.Flags().StringSliceVar(&t.RevisionsPercentages, | ||
"traffic", | ||
nil, | ||
"Set traffic distribution (format: --traffic revisionRef=percent) where revisionRef can be a revision or a tag or '@latest' string "+ | ||
"representing latest ready revision. This flag can be given multiple times with percent summing up to 100%.") | ||
|
||
cmd.Flags().StringSliceVar(&t.RevisionsTags, | ||
"tag", | ||
nil, | ||
"Set tag (format: --tag revisionRef=tagName) where revisionRef can be a revision or '@latest' string representing latest ready revision. "+ | ||
"This flag can be specified multiple times.") | ||
|
||
cmd.Flags().StringSliceVar(&t.UntagRevisions, | ||
"untag", | ||
nil, | ||
"Untag revision (format: --untag tagName). This flag can be spcified multiple times.") | ||
} | ||
|
||
func (t *Traffic) PercentagesChanged(cmd *cobra.Command) bool { | ||
return cmd.Flags().Changed("traffic") | ||
} | ||
|
||
func (t *Traffic) TagsChanged(cmd *cobra.Command) bool { | ||
return cmd.Flags().Changed("tag") || cmd.Flags().Changed("untag") | ||
} | ||
|
||
func (t *Traffic) Changed(cmd *cobra.Command) bool { | ||
return t.PercentagesChanged(cmd) || t.TagsChanged(cmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.