Skip to content

Commit

Permalink
http write timeout for the rest api frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
benpresnell authored Nov 17, 2021
1 parent 800db19 commit 556bfc6
Show file tree
Hide file tree
Showing 14 changed files with 360 additions and 100 deletions.
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@Library(['tools@master', 'tools-override@main']) _

node {
execute_pipeline(repository: 'trident')
}
46 changes: 38 additions & 8 deletions cli/cmd/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,46 @@ func getInstallYaml(semVersion *utils.Version) (string, error) {
snapshotCRDVersion = client.GetSnapshotterCRDVersion()
}

labels := make(map[string]string)

deploymentArgs := &k8sclient.DeploymentYAMLArguments{
DeploymentName: getDeploymentName(true),
TridentImage: tridentconfig.BuildImage,
AutosupportImage: tridentconfig.DefaultAutosupportImage,
AutosupportProxy: "",
AutosupportCustomURL: "",
AutosupportSerialNumber: "",
AutosupportHostname: "",
ImageRegistry: "",
LogFormat: "",
SnapshotCRDVersion: snapshotCRDVersion,
ImagePullSecrets: []string{},
Labels: map[string]string{},
ControllingCRDetails: map[string]string{},
Debug: false,
UseIPv6: false,
SilenceAutosupport: true,
Version: semVersion,
TopologyEnabled: false,
HTTPRequestTimeout: tridentconfig.HTTPTimeoutString,
}
// Get Deployment and Daemonset YAML and collect the names of the container images Trident needs to run.
yaml := k8sclient.GetCSIDeploymentYAML(getDeploymentName(true),
tridentconfig.BuildImage, tridentconfig.DefaultAutosupportImage, "", "",
"", "", "", "", snapshotCRDVersion, []string{}, nil,
nil, false, false, true, semVersion, false)
yaml := k8sclient.GetCSIDeploymentYAML(deploymentArgs)
daemonSetArgs := &k8sclient.DaemonsetYAMLArguments{
DaemonsetName: "",
TridentImage: "",
ImageRegistry: "",
KubeletDir: "",
LogFormat: "",
ProbePort: "",
ImagePullSecrets: []string{},
Labels: map[string]string{},
ControllingCRDetails: map[string]string{},
Debug: false,
NodePrep: false,
Version: semVersion,
HTTPRequestTimeout: tridentconfig.HTTPTimeoutString,
}
// trident image here is an empty string because we are already going to get it from the deployment yaml
yaml += k8sclient.GetCSIDaemonSetYAML("", "", "", "",
"", "", []string{}, labels, nil, false, false, semVersion)
yaml += k8sclient.GetCSIDaemonSetYAML(daemonSetArgs)

return yaml, nil
}
Expand Down
93 changes: 78 additions & 15 deletions cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ var (
logFormat string
probePort int64
k8sTimeout time.Duration
httpRequestTimeout string

// CLI-based K8S client
client k8sclient.Interface
Expand Down Expand Up @@ -154,6 +155,7 @@ func init() {
installCmd.Flags().StringVar(&autosupportHostname, "autosupport-hostname", "", "The value to set for the hostname field in Autosupport payloads")

installCmd.Flags().DurationVar(&k8sTimeout, "k8s-timeout", 180*time.Second, "The timeout for all Kubernetes operations.")
installCmd.Flags().StringVar(&httpRequestTimeout, "http-request-timeout", tridentconfig.HTTPTimeoutString, "The HTTP request timeout (e.g. '90s'.")

if err := installCmd.Flags().MarkHidden("skip-k8s-version-check"); err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
Expand Down Expand Up @@ -437,17 +439,48 @@ func prepareYAMLFiles() error {
return fmt.Errorf("could not write service YAML file; %v", err)
}

deploymentYAML := k8sclient.GetCSIDeploymentYAML(getDeploymentName(true),
tridentImage, autosupportImage, autosupportProxy, autosupportCustomURL, autosupportSerialNumber,
autosupportHostname, imageRegistry, logFormat, snapshotCRDVersion, []string{}, labels,
nil, Debug, useIPv6, silenceAutosupport, client.ServerVersion(), topologyEnabled)
deploymentArgs := &k8sclient.DeploymentYAMLArguments{
DeploymentName: getDeploymentName(true),
TridentImage: tridentImage,
AutosupportImage: autosupportImage,
AutosupportProxy: autosupportProxy,
AutosupportCustomURL: autosupportCustomURL,
AutosupportSerialNumber: autosupportSerialNumber,
AutosupportHostname: autosupportHostname,
ImageRegistry: imageRegistry,
LogFormat: logFormat,
SnapshotCRDVersion: snapshotCRDVersion,
ImagePullSecrets: []string{},
Labels: labels,
ControllingCRDetails: nil,
Debug: Debug,
UseIPv6: useIPv6,
SilenceAutosupport: silenceAutosupport,
Version: client.ServerVersion(),
TopologyEnabled: topologyEnabled,
HTTPRequestTimeout: httpRequestTimeout,
}
deploymentYAML := k8sclient.GetCSIDeploymentYAML(deploymentArgs)
if err = writeFile(deploymentPath, deploymentYAML); err != nil {
return fmt.Errorf("could not write deployment YAML file; %v", err)
}

daemonSetYAML := k8sclient.GetCSIDaemonSetYAML(getDaemonSetName(),
tridentImage, imageRegistry, kubeletDir, logFormat, strconv.FormatInt(probePort, 10), []string{},
daemonSetlabels, nil, Debug, enableNodePrep, client.ServerVersion())
daemonArgs := &k8sclient.DaemonsetYAMLArguments{
DaemonsetName: getDaemonSetName(),
TridentImage: tridentImage,
ImageRegistry: imageRegistry,
KubeletDir: kubeletDir,
LogFormat: logFormat,
ProbePort: strconv.FormatInt(probePort, 10),
ImagePullSecrets: []string{},
Labels: daemonSetlabels,
ControllingCRDetails: nil,
Debug: Debug,
NodePrep: enableNodePrep,
Version: client.ServerVersion(),
HTTPRequestTimeout: httpRequestTimeout,
}
daemonSetYAML := k8sclient.GetCSIDaemonSetYAML(daemonArgs)
if err = writeFile(daemonsetPath, daemonSetYAML); err != nil {
return fmt.Errorf("could not write daemonset YAML file; %v", err)
}
Expand Down Expand Up @@ -770,11 +803,29 @@ func installTrident() (returnError error) {
returnError = client.CreateObjectByFile(deploymentPath)
logFields = log.Fields{"path": deploymentPath}
} else {
deploymentArgs := &k8sclient.DeploymentYAMLArguments{
DeploymentName: getDeploymentName(true),
TridentImage: tridentImage,
AutosupportImage: autosupportImage,
AutosupportProxy: autosupportProxy,
AutosupportCustomURL: autosupportCustomURL,
AutosupportSerialNumber: autosupportSerialNumber,
AutosupportHostname: autosupportHostname,
ImageRegistry: imageRegistry,
LogFormat: logFormat,
SnapshotCRDVersion: snapshotCRDVersion,
ImagePullSecrets: []string{},
Labels: labels,
ControllingCRDetails: nil,
Debug: Debug,
UseIPv6: useIPv6,
SilenceAutosupport: silenceAutosupport,
Version: client.ServerVersion(),
TopologyEnabled: topologyEnabled,
HTTPRequestTimeout: httpRequestTimeout,
}
returnError = client.CreateObjectByYAML(
k8sclient.GetCSIDeploymentYAML(getDeploymentName(true),
tridentImage, autosupportImage, autosupportProxy, autosupportCustomURL, autosupportSerialNumber,
autosupportHostname, imageRegistry, logFormat, snapshotCRDVersion, []string{}, labels, nil,
Debug, useIPv6, silenceAutosupport, client.ServerVersion(), topologyEnabled))
k8sclient.GetCSIDeploymentYAML(deploymentArgs))
logFields = log.Fields{}
}
if returnError != nil {
Expand All @@ -795,11 +846,23 @@ func installTrident() (returnError error) {
} else {
daemonSetlabels := make(map[string]string)
daemonSetlabels[appLabelKey] = TridentNodeLabelValue

daemonSetArgs := &k8sclient.DaemonsetYAMLArguments{
DaemonsetName: getDaemonSetName(),
TridentImage: tridentImage,
ImageRegistry: imageRegistry,
KubeletDir: kubeletDir,
LogFormat: logFormat,
ProbePort: strconv.FormatInt(probePort, 10),
ImagePullSecrets: []string{},
Labels: daemonSetlabels,
ControllingCRDetails: nil,
Debug: Debug,
NodePrep: enableNodePrep,
Version: client.ServerVersion(),
HTTPRequestTimeout: httpRequestTimeout,
}
returnError = client.CreateObjectByYAML(
k8sclient.GetCSIDaemonSetYAML(getDaemonSetName(),
tridentImage, imageRegistry, kubeletDir, logFormat, strconv.FormatInt(probePort, 10), []string{},
daemonSetlabels, nil, Debug, enableNodePrep, client.ServerVersion()))
k8sclient.GetCSIDaemonSetYAML(daemonSetArgs))
logFields = log.Fields{}
}
if returnError != nil {
Expand Down
43 changes: 43 additions & 0 deletions cli/k8s_client/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package k8sclient

import (
"github.com/netapp/trident/utils"
)

type DeploymentYAMLArguments struct {
DeploymentName string `json:"deploymentName"`
TridentImage string `json:"tridentImage"`
AutosupportImage string `json:"autosupportImage"`
AutosupportProxy string `json:"autosupportProxy"`
AutosupportCustomURL string `json:"autosupportCustomURL"`
AutosupportSerialNumber string `json:"autosupportSerialNumber"`
AutosupportHostname string `json:"autosupportHostname"`
ImageRegistry string `json:"imageRegistry"`
LogFormat string `json:"logFormat"`
SnapshotCRDVersion string `json:"snapshotCRDVersion"`
ImagePullSecrets []string `json:"imagePullSecrets"`
Labels map[string]string `json:"labels"`
ControllingCRDetails map[string]string `json:"controllingCRDetails"`
Debug bool `json:"debug"`
UseIPv6 bool `json:"useIPv6"`
SilenceAutosupport bool `json:"silenceAutosupport"`
Version *utils.Version `json:"version"`
TopologyEnabled bool `json:"topologyEnabled"`
HTTPRequestTimeout string `json:"httpRequestTimeout"`
}

type DaemonsetYAMLArguments struct {
DaemonsetName string `json:"daemonsetName"`
TridentImage string `json:"tridentImage"`
ImageRegistry string `json:"imageRegistry"`
KubeletDir string `json:"kubeletDir"`
LogFormat string `json:"logFormat"`
ProbePort string `json:"probePort"`
ImagePullSecrets []string `json:"imagePullSecrets"`
Labels map[string]string `json:"labels"`
ControllingCRDetails map[string]string `json:"controllingCRDetails"`
Debug bool `json:"debug"`
NodePrep bool `json:"nodePrep"`
Version *utils.Version `json:"version"`
HTTPRequestTimeout string `json:"httpRequestTimeout"`
}
Loading

0 comments on commit 556bfc6

Please sign in to comment.