Skip to content

Commit

Permalink
Moved --timeout flag to shared flags
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasgun committed Apr 13, 2022
1 parent 184ce4e commit 3842507
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions docs/cmd/kn_service_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ kn service update NAME
--service-account string Service account name to set. An empty argument ("") clears the service account. The referenced service account must exist in the service's namespace.
--tag strings 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.
--target string Work on local directory instead of a remote cluster (experimental)
--timeout int Duration in seconds that the request routing layer will wait for a request delivered to a container to begin replying (default 300)
--traffic strings 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%.
--untag strings Untag revision (format: --untag tagName). This flag can be specified multiple times.
--user int The user ID to run the container (e.g., 1001).
Expand Down
16 changes: 10 additions & 6 deletions pkg/kn/commands/service/configuration_edit_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import (
"strings"

"github.com/spf13/cobra"
"knative.dev/serving/pkg/apis/config"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/serving/pkg/apis/config"

knflags "knative.dev/client/pkg/kn/flags"
servinglib "knative.dev/client/pkg/serving"
Expand Down Expand Up @@ -172,6 +171,11 @@ func (p *ConfigurationEditFlags) addSharedFlags(command *cobra.Command) {

command.Flags().IntVar(&p.ScaleInit, "scale-init", 0, "Initial number of replicas with which a service starts. Can be 0 or a positive integer.")
p.markFlagMakesRevision("scale-init")

command.Flags().Int64Var(&p.TimeoutSeconds, "timeout", config.DefaultRevisionTimeoutSeconds,
"Duration in seconds that the request routing layer will wait for a request delivered to a "+""+
"container to begin replying")
p.markFlagMakesRevision("timeout")
}

// AddUpdateFlags adds the flags specific to update.
Expand Down Expand Up @@ -219,10 +223,6 @@ func (p *ConfigurationEditFlags) AddCreateFlags(command *cobra.Command) {
"Labels to set for both Service and Revision. name=value; you may provide this flag "+
"any number of times to set multiple labels.")
p.markFlagMakesRevision("label")
command.Flags().Int64Var(&p.TimeoutSeconds, "timeout", config.DefaultRevisionTimeoutSeconds,
"Duration in seconds that the request routing layer will wait for a request delivered to a "+""+
"container to begin replying")
p.markFlagMakesRevision("timeout")
}

// Apply mutates the given service according to the flags in the command.
Expand Down Expand Up @@ -456,6 +456,10 @@ func (p *ConfigurationEditFlags) Apply(
}
}

if cmd.Flags().Changed("timeout") {
service.Spec.Template.Spec.TimeoutSeconds = &p.TimeoutSeconds
}

return nil
}

Expand Down
1 change: 0 additions & 1 deletion pkg/kn/commands/service/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ func constructService(cmd *cobra.Command, editFlags ConfigurationEditFlags, name
},
}
service.Spec.Template.Spec.Containers = []corev1.Container{{}}
service.Spec.Template.Spec.TimeoutSeconds = &editFlags.TimeoutSeconds

err := editFlags.Apply(&service, nil, cmd)
if err != nil {
Expand Down
3 changes: 0 additions & 3 deletions pkg/kn/commands/service/create_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"time"

"knative.dev/serving/pkg/apis/autoscaling"
"knative.dev/serving/pkg/apis/config"

"gotest.tools/v3/assert"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -480,8 +479,6 @@ func getService(name string) *servingv1.Service {
},
}}

var defaultTimeout int64 = config.DefaultRevisionTimeoutSeconds
service.Spec.Template.Spec.TimeoutSeconds = &defaultTimeout
return service
}

Expand Down

0 comments on commit 3842507

Please sign in to comment.