mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 04:52:08 +00:00
cleanup: Update deprecated FromInt to FromInt32 (#119858)
* redo commit * apply suggestions from liggitt * update Parse function based on suggestions
This commit is contained in:
parent
c5a675808b
commit
a5b3a4b738
@ -63,9 +63,9 @@ func GetStaticPodSpecs(cfg *kubeadmapi.ClusterConfiguration, endpoint *kubeadmap
|
||||
ImagePullPolicy: v1.PullIfNotPresent,
|
||||
Command: getAPIServerCommand(cfg, endpoint),
|
||||
VolumeMounts: staticpodutil.VolumeMountMapToSlice(mounts.GetVolumeMounts(kubeadmconstants.KubeAPIServer)),
|
||||
LivenessProbe: staticpodutil.LivenessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/livez", int(endpoint.BindPort), v1.URISchemeHTTPS),
|
||||
ReadinessProbe: staticpodutil.ReadinessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/readyz", int(endpoint.BindPort), v1.URISchemeHTTPS),
|
||||
StartupProbe: staticpodutil.StartupProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/livez", int(endpoint.BindPort), v1.URISchemeHTTPS, cfg.APIServer.TimeoutForControlPlane),
|
||||
LivenessProbe: staticpodutil.LivenessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/livez", endpoint.BindPort, v1.URISchemeHTTPS),
|
||||
ReadinessProbe: staticpodutil.ReadinessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/readyz", endpoint.BindPort, v1.URISchemeHTTPS),
|
||||
StartupProbe: staticpodutil.StartupProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/livez", endpoint.BindPort, v1.URISchemeHTTPS, cfg.APIServer.TimeoutForControlPlane),
|
||||
Resources: staticpodutil.ComponentResources("250m"),
|
||||
Env: kubeadmutil.MergeEnv(proxyEnvs, cfg.APIServer.ExtraEnvs),
|
||||
}, mounts.GetVolumes(kubeadmconstants.KubeAPIServer),
|
||||
|
@ -242,20 +242,20 @@ func ReadStaticPodFromDisk(manifestPath string) (*v1.Pod, error) {
|
||||
}
|
||||
|
||||
// LivenessProbe creates a Probe object with a HTTPGet handler
|
||||
func LivenessProbe(host, path string, port int, scheme v1.URIScheme) *v1.Probe {
|
||||
func LivenessProbe(host, path string, port int32, scheme v1.URIScheme) *v1.Probe {
|
||||
// sets initialDelaySeconds same as periodSeconds to skip one period before running a check
|
||||
return createHTTPProbe(host, path, port, scheme, 10, 15, 8, 10)
|
||||
}
|
||||
|
||||
// ReadinessProbe creates a Probe object with a HTTPGet handler
|
||||
func ReadinessProbe(host, path string, port int, scheme v1.URIScheme) *v1.Probe {
|
||||
func ReadinessProbe(host, path string, port int32, scheme v1.URIScheme) *v1.Probe {
|
||||
// sets initialDelaySeconds as '0' because we don't want to delay user infrastructure checks
|
||||
// looking for "ready" status on kubeadm static Pods
|
||||
return createHTTPProbe(host, path, port, scheme, 0, 15, 3, 1)
|
||||
}
|
||||
|
||||
// StartupProbe creates a Probe object with a HTTPGet handler
|
||||
func StartupProbe(host, path string, port int, scheme v1.URIScheme, timeoutForControlPlane *metav1.Duration) *v1.Probe {
|
||||
func StartupProbe(host, path string, port int32, scheme v1.URIScheme, timeoutForControlPlane *metav1.Duration) *v1.Probe {
|
||||
periodSeconds, timeoutForControlPlaneSeconds := int32(10), kubeadmconstants.DefaultControlPlaneTimeout.Seconds()
|
||||
if timeoutForControlPlane != nil {
|
||||
timeoutForControlPlaneSeconds = timeoutForControlPlane.Seconds()
|
||||
@ -267,13 +267,13 @@ func StartupProbe(host, path string, port int, scheme v1.URIScheme, timeoutForCo
|
||||
return createHTTPProbe(host, path, port, scheme, periodSeconds, 15, failureThreshold, periodSeconds)
|
||||
}
|
||||
|
||||
func createHTTPProbe(host, path string, port int, scheme v1.URIScheme, initialDelaySeconds, timeoutSeconds, failureThreshold, periodSeconds int32) *v1.Probe {
|
||||
func createHTTPProbe(host, path string, port int32, scheme v1.URIScheme, initialDelaySeconds, timeoutSeconds, failureThreshold, periodSeconds int32) *v1.Probe {
|
||||
return &v1.Probe{
|
||||
ProbeHandler: v1.ProbeHandler{
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Host: host,
|
||||
Path: path,
|
||||
Port: intstr.FromInt(port),
|
||||
Port: intstr.FromInt32(port),
|
||||
Scheme: scheme,
|
||||
},
|
||||
},
|
||||
@ -312,7 +312,7 @@ func GetSchedulerProbeAddress(cfg *kubeadmapi.ClusterConfiguration) string {
|
||||
// GetEtcdProbeEndpoint takes a kubeadm Etcd configuration object and attempts to parse
|
||||
// the first URL in the listen-metrics-urls argument, returning an etcd probe hostname,
|
||||
// port and scheme
|
||||
func GetEtcdProbeEndpoint(cfg *kubeadmapi.Etcd, isIPv6 bool) (string, int, v1.URIScheme) {
|
||||
func GetEtcdProbeEndpoint(cfg *kubeadmapi.Etcd, isIPv6 bool) (string, int32, v1.URIScheme) {
|
||||
localhost := "127.0.0.1"
|
||||
if isIPv6 {
|
||||
localhost = "::1"
|
||||
@ -346,7 +346,7 @@ func GetEtcdProbeEndpoint(cfg *kubeadmapi.Etcd, isIPv6 bool) (string, int, v1.UR
|
||||
port = p
|
||||
}
|
||||
}
|
||||
return hostname, port, scheme
|
||||
return hostname, int32(port), scheme
|
||||
}
|
||||
return localhost, kubeadmconstants.EtcdMetricsPort, v1.URISchemeHTTP
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ func TestGetEtcdProbeEndpoint(t *testing.T) {
|
||||
cfg *kubeadmapi.Etcd
|
||||
isIPv6 bool
|
||||
expectedHostname string
|
||||
expectedPort int
|
||||
expectedPort int32
|
||||
expectedScheme v1.URIScheme
|
||||
}{
|
||||
{
|
||||
|
@ -176,7 +176,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
}
|
||||
|
||||
func getMaxUnavailable(maxUnavailable int) *intstr.IntOrString {
|
||||
maxUnavailableIntOrStr := intstr.FromInt(maxUnavailable)
|
||||
maxUnavailableIntOrStr := intstr.FromInt32(int32(maxUnavailable))
|
||||
return &maxUnavailableIntOrStr
|
||||
}
|
||||
|
||||
|
@ -532,6 +532,6 @@ func getPartition(partition int32) *int32 {
|
||||
}
|
||||
|
||||
func getMaxUnavailable(maxUnavailable int) *intstr.IntOrString {
|
||||
maxUnavailableIntOrStr := intstr.FromInt(maxUnavailable)
|
||||
maxUnavailableIntOrStr := intstr.FromInt32(int32(maxUnavailable))
|
||||
return &maxUnavailableIntOrStr
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
}
|
||||
|
||||
func getMaxUnavailable(maxUnavailable int) *intstr.IntOrString {
|
||||
maxUnavailableIntOrStr := intstr.FromInt(maxUnavailable)
|
||||
maxUnavailableIntOrStr := intstr.FromInt32(int32(maxUnavailable))
|
||||
return &maxUnavailableIntOrStr
|
||||
}
|
||||
|
||||
|
@ -8197,7 +8197,7 @@ func TestValidateInitContainers(t *testing.T) {
|
||||
StartupProbe: &core.Probe{
|
||||
ProbeHandler: core.ProbeHandler{
|
||||
TCPSocket: &core.TCPSocketAction{
|
||||
Port: intstr.FromInt(80),
|
||||
Port: intstr.FromInt32(80),
|
||||
},
|
||||
},
|
||||
SuccessThreshold: 1,
|
||||
@ -8413,7 +8413,7 @@ func TestValidateInitContainers(t *testing.T) {
|
||||
RestartPolicy: &containerRestartPolicyAlways,
|
||||
StartupProbe: &core.Probe{
|
||||
ProbeHandler: core.ProbeHandler{
|
||||
TCPSocket: &core.TCPSocketAction{Port: intstr.FromInt(80)},
|
||||
TCPSocket: &core.TCPSocketAction{Port: intstr.FromInt32(80)},
|
||||
},
|
||||
SuccessThreshold: 2,
|
||||
},
|
||||
|
@ -48,7 +48,7 @@ func TestDaemonSetUpdatesPods(t *testing.T) {
|
||||
|
||||
ds.Spec.Template.Spec.Containers[0].Image = "foo2/bar2"
|
||||
ds.Spec.UpdateStrategy.Type = apps.RollingUpdateDaemonSetStrategyType
|
||||
intStr := intstr.FromInt(maxUnavailable)
|
||||
intStr := intstr.FromInt32(int32(maxUnavailable))
|
||||
ds.Spec.UpdateStrategy.RollingUpdate = &apps.RollingUpdateDaemonSet{MaxUnavailable: &intStr}
|
||||
manager.dsStore.Update(ds)
|
||||
|
||||
@ -90,7 +90,7 @@ func TestDaemonSetUpdatesPodsWithMaxSurge(t *testing.T) {
|
||||
// surge is thhe controlling amount
|
||||
maxSurge := 2
|
||||
ds.Spec.Template.Spec.Containers[0].Image = "foo2/bar2"
|
||||
ds.Spec.UpdateStrategy = newUpdateSurge(intstr.FromInt(maxSurge))
|
||||
ds.Spec.UpdateStrategy = newUpdateSurge(intstr.FromInt32(int32(maxSurge)))
|
||||
manager.dsStore.Update(ds)
|
||||
|
||||
clearExpectations(t, manager, ds, podControl)
|
||||
@ -135,7 +135,7 @@ func TestDaemonSetUpdatesWhenNewPosIsNotReady(t *testing.T) {
|
||||
|
||||
ds.Spec.Template.Spec.Containers[0].Image = "foo2/bar2"
|
||||
ds.Spec.UpdateStrategy.Type = apps.RollingUpdateDaemonSetStrategyType
|
||||
intStr := intstr.FromInt(maxUnavailable)
|
||||
intStr := intstr.FromInt32(int32(maxUnavailable))
|
||||
ds.Spec.UpdateStrategy.RollingUpdate = &apps.RollingUpdateDaemonSet{MaxUnavailable: &intStr}
|
||||
err = manager.dsStore.Update(ds)
|
||||
if err != nil {
|
||||
@ -171,7 +171,7 @@ func TestDaemonSetUpdatesAllOldPodsNotReady(t *testing.T) {
|
||||
|
||||
ds.Spec.Template.Spec.Containers[0].Image = "foo2/bar2"
|
||||
ds.Spec.UpdateStrategy.Type = apps.RollingUpdateDaemonSetStrategyType
|
||||
intStr := intstr.FromInt(maxUnavailable)
|
||||
intStr := intstr.FromInt32(int32(maxUnavailable))
|
||||
ds.Spec.UpdateStrategy.RollingUpdate = &apps.RollingUpdateDaemonSet{MaxUnavailable: &intStr}
|
||||
err = manager.dsStore.Update(ds)
|
||||
if err != nil {
|
||||
@ -203,7 +203,7 @@ func TestDaemonSetUpdatesAllOldPodsNotReadyMaxSurge(t *testing.T) {
|
||||
|
||||
maxSurge := 3
|
||||
ds.Spec.Template.Spec.Containers[0].Image = "foo2/bar2"
|
||||
ds.Spec.UpdateStrategy = newUpdateSurge(intstr.FromInt(maxSurge))
|
||||
ds.Spec.UpdateStrategy = newUpdateSurge(intstr.FromInt32(int32(maxSurge)))
|
||||
manager.dsStore.Update(ds)
|
||||
|
||||
// all old pods are unavailable so should be surged
|
||||
@ -347,7 +347,7 @@ func TestDaemonSetUpdatesNoTemplateChanged(t *testing.T) {
|
||||
expectSyncDaemonSets(t, manager, ds, podControl, 5, 0, 0)
|
||||
|
||||
ds.Spec.UpdateStrategy.Type = apps.RollingUpdateDaemonSetStrategyType
|
||||
intStr := intstr.FromInt(maxUnavailable)
|
||||
intStr := intstr.FromInt32(int32(maxUnavailable))
|
||||
ds.Spec.UpdateStrategy.RollingUpdate = &apps.RollingUpdateDaemonSet{MaxUnavailable: &intStr}
|
||||
manager.dsStore.Update(ds)
|
||||
|
||||
|
@ -35,7 +35,7 @@ import (
|
||||
)
|
||||
|
||||
func intOrStrP(val int) *intstr.IntOrString {
|
||||
intOrStr := intstr.FromInt(val)
|
||||
intOrStr := intstr.FromInt32(int32(val))
|
||||
return &intOrStr
|
||||
}
|
||||
|
||||
|
@ -516,11 +516,11 @@ func TestNewRSNewReplicas(t *testing.T) {
|
||||
newDeployment.Spec.Strategy = apps.DeploymentStrategy{Type: test.strategyType}
|
||||
newDeployment.Spec.Strategy.RollingUpdate = &apps.RollingUpdateDeployment{
|
||||
MaxUnavailable: func(i int) *intstr.IntOrString {
|
||||
x := intstr.FromInt(i)
|
||||
x := intstr.FromInt32(int32(i))
|
||||
return &x
|
||||
}(1),
|
||||
MaxSurge: func(i int) *intstr.IntOrString {
|
||||
x := intstr.FromInt(i)
|
||||
x := intstr.FromInt32(int32(i))
|
||||
return &x
|
||||
}(test.maxSurge),
|
||||
}
|
||||
@ -705,8 +705,8 @@ func TestDeploymentComplete(t *testing.T) {
|
||||
Replicas: &desired,
|
||||
Strategy: apps.DeploymentStrategy{
|
||||
RollingUpdate: &apps.RollingUpdateDeployment{
|
||||
MaxUnavailable: func(i int) *intstr.IntOrString { x := intstr.FromInt(i); return &x }(int(maxUnavailable)),
|
||||
MaxSurge: func(i int) *intstr.IntOrString { x := intstr.FromInt(i); return &x }(int(maxSurge)),
|
||||
MaxUnavailable: func(i int) *intstr.IntOrString { x := intstr.FromInt32(int32(i)); return &x }(int(maxUnavailable)),
|
||||
MaxSurge: func(i int) *intstr.IntOrString { x := intstr.FromInt32(int32(i)); return &x }(int(maxSurge)),
|
||||
},
|
||||
Type: apps.RollingUpdateDeploymentStrategyType,
|
||||
},
|
||||
@ -960,7 +960,7 @@ func TestMaxUnavailable(t *testing.T) {
|
||||
Replicas: func(i int32) *int32 { return &i }(replicas),
|
||||
Strategy: apps.DeploymentStrategy{
|
||||
RollingUpdate: &apps.RollingUpdateDeployment{
|
||||
MaxSurge: func(i int) *intstr.IntOrString { x := intstr.FromInt(i); return &x }(int(1)),
|
||||
MaxSurge: func(i int) *intstr.IntOrString { x := intstr.FromInt32(int32(i)); return &x }(int(1)),
|
||||
MaxUnavailable: &maxUnavailable,
|
||||
},
|
||||
Type: apps.RollingUpdateDeploymentStrategyType,
|
||||
@ -1255,7 +1255,7 @@ func TestGetDeploymentsForReplicaSet(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMinAvailable(t *testing.T) {
|
||||
maxSurge := func(i int) *intstr.IntOrString { x := intstr.FromInt(i); return &x }(int(1))
|
||||
maxSurge := func(i int) *intstr.IntOrString { x := intstr.FromInt32(int32(i)); return &x }(int(1))
|
||||
deployment := func(replicas int32, maxUnavailable intstr.IntOrString) *apps.Deployment {
|
||||
return &apps.Deployment{
|
||||
Spec: apps.DeploymentSpec{
|
||||
|
@ -184,7 +184,7 @@ func createPortAndServiceSpec(servicePort int, targetServicePort int, nodePort i
|
||||
Protocol: corev1.ProtocolTCP,
|
||||
Port: int32(servicePort),
|
||||
Name: servicePortName,
|
||||
TargetPort: intstr.FromInt(targetServicePort),
|
||||
TargetPort: intstr.FromInt32(int32(targetServicePort)),
|
||||
}}
|
||||
serviceType := corev1.ServiceTypeClusterIP
|
||||
if nodePort > 0 {
|
||||
|
@ -45,7 +45,7 @@ import (
|
||||
|
||||
func TestResolvePortInt(t *testing.T) {
|
||||
expected := 80
|
||||
port, err := resolvePort(intstr.FromInt(expected), &v1.Container{})
|
||||
port, err := resolvePort(intstr.FromInt32(int32(expected)), &v1.Container{})
|
||||
if port != expected {
|
||||
t.Errorf("expected: %d, saw: %d", expected, port)
|
||||
}
|
||||
|
@ -257,14 +257,14 @@ func (f *fakePod) probeHandler() v1.ProbeHandler {
|
||||
handler = v1.ProbeHandler{
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Host: "127.0.0.1",
|
||||
Port: intstr.FromInt(port),
|
||||
Port: intstr.FromInt32(int32(port)),
|
||||
},
|
||||
}
|
||||
} else {
|
||||
handler = v1.ProbeHandler{
|
||||
TCPSocket: &v1.TCPSocketAction{
|
||||
Host: "127.0.0.1",
|
||||
Port: intstr.FromInt(port),
|
||||
Port: intstr.FromInt32(int32(port)),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ func generateServiceEndpoints(nServices, nEndpoints int, epsFunc func(eps *disco
|
||||
Name: fmt.Sprintf("%d", epPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
Port: int32(basePort + i),
|
||||
TargetPort: intstr.FromInt(epPort),
|
||||
TargetPort: intstr.FromInt32(int32(epPort)),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -2623,7 +2623,7 @@ func TestExternalIPsReject(t *testing.T) {
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
TargetPort: intstr.FromInt(svcPort),
|
||||
TargetPort: intstr.FromInt32(int32(svcPort)),
|
||||
}}
|
||||
}),
|
||||
)
|
||||
@ -2698,7 +2698,7 @@ func TestOnlyLocalExternalIPs(t *testing.T) {
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
TargetPort: intstr.FromInt(svcPort),
|
||||
TargetPort: intstr.FromInt32(int32(svcPort)),
|
||||
}}
|
||||
}),
|
||||
)
|
||||
@ -2810,7 +2810,7 @@ func TestNonLocalExternalIPs(t *testing.T) {
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
TargetPort: intstr.FromInt(svcPort),
|
||||
TargetPort: intstr.FromInt32(int32(svcPort)),
|
||||
}}
|
||||
}),
|
||||
)
|
||||
@ -3932,7 +3932,7 @@ func addTestPort(array []v1.ServicePort, name string, protocol v1.Protocol, port
|
||||
Protocol: protocol,
|
||||
Port: port,
|
||||
NodePort: nodeport,
|
||||
TargetPort: intstr.FromInt(targetPort),
|
||||
TargetPort: intstr.FromInt32(int32(targetPort)),
|
||||
}
|
||||
return append(array, svcPort)
|
||||
}
|
||||
|
@ -1743,7 +1743,7 @@ func TestExternalIPsNoEndpoint(t *testing.T) {
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
TargetPort: intstr.FromInt(svcPort),
|
||||
TargetPort: intstr.FromInt32(int32(svcPort)),
|
||||
}}
|
||||
}),
|
||||
)
|
||||
@ -1795,7 +1795,7 @@ func TestExternalIPs(t *testing.T) {
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
TargetPort: intstr.FromInt(svcPort),
|
||||
TargetPort: intstr.FromInt32(int32(svcPort)),
|
||||
}}
|
||||
}),
|
||||
)
|
||||
@ -1866,7 +1866,7 @@ func TestOnlyLocalExternalIPs(t *testing.T) {
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
TargetPort: intstr.FromInt(svcPort),
|
||||
TargetPort: intstr.FromInt32(int32(svcPort)),
|
||||
}}
|
||||
svc.Spec.ExternalTrafficPolicy = v1.ServiceExternalTrafficPolicyLocal
|
||||
}),
|
||||
@ -2476,7 +2476,7 @@ func addTestPort(array []v1.ServicePort, name string, protocol v1.Protocol, port
|
||||
Protocol: protocol,
|
||||
Port: port,
|
||||
NodePort: nodeport,
|
||||
TargetPort: intstr.FromInt(targetPort),
|
||||
TargetPort: intstr.FromInt32(int32(targetPort)),
|
||||
}
|
||||
return append(array, svcPort)
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ func addTestPort(array []v1.ServicePort, name string, protocol v1.Protocol, port
|
||||
Protocol: protocol,
|
||||
Port: port,
|
||||
NodePort: nodeport,
|
||||
TargetPort: intstr.FromInt(targetPort),
|
||||
TargetPort: intstr.FromInt32(int32(targetPort)),
|
||||
}
|
||||
return append(array, svcPort)
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ func generateStatefulSetWithMinReadySeconds(minReadySeconds int32) *apps.Statefu
|
||||
func makeStatefulSetWithMaxUnavailable(maxUnavailable *int) *apps.StatefulSet {
|
||||
rollingUpdate := apps.RollingUpdateStatefulSetStrategy{}
|
||||
if maxUnavailable != nil {
|
||||
maxUnavailableIntStr := intstr.FromInt(*maxUnavailable)
|
||||
maxUnavailableIntStr := intstr.FromInt32(int32(*maxUnavailable))
|
||||
rollingUpdate = apps.RollingUpdateStatefulSetStrategy{
|
||||
MaxUnavailable: &maxUnavailableIntStr,
|
||||
}
|
||||
|
@ -72,14 +72,14 @@ func FromString(val string) IntOrString {
|
||||
return IntOrString{Type: String, StrVal: val}
|
||||
}
|
||||
|
||||
// Parse the given string and try to convert it to an integer before
|
||||
// Parse the given string and try to convert it to an int32 integer before
|
||||
// setting it as a string value.
|
||||
func Parse(val string) IntOrString {
|
||||
i, err := strconv.Atoi(val)
|
||||
i, err := strconv.ParseInt(val, 10, 32)
|
||||
if err != nil {
|
||||
return FromString(val)
|
||||
}
|
||||
return FromInt(i)
|
||||
return FromInt32(int32(i))
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface.
|
||||
|
@ -100,7 +100,7 @@ func tweakAddLBIngress(ip string) serviceTweak {
|
||||
func makeServicePort(protocol v1.Protocol, targetPort int) []v1.ServicePort {
|
||||
sp := v1.ServicePort{Port: 80, Protocol: protocol}
|
||||
if targetPort > 0 {
|
||||
sp.TargetPort = intstr.FromInt(targetPort)
|
||||
sp.TargetPort = intstr.FromInt32(int32(targetPort))
|
||||
}
|
||||
return []v1.ServicePort{sp}
|
||||
}
|
||||
|
@ -1709,13 +1709,13 @@ func TestGenerateService(t *testing.T) {
|
||||
Name: "port-1-tcp",
|
||||
Port: 53,
|
||||
Protocol: corev1.ProtocolTCP,
|
||||
TargetPort: intstr.FromInt(53),
|
||||
TargetPort: intstr.FromInt32(53),
|
||||
},
|
||||
{
|
||||
Name: "port-1-udp",
|
||||
Port: 53,
|
||||
Protocol: corev1.ProtocolUDP,
|
||||
TargetPort: intstr.FromInt(53),
|
||||
TargetPort: intstr.FromInt32(53),
|
||||
},
|
||||
},
|
||||
ClusterIP: corev1.ClusterIPNone,
|
||||
|
@ -196,7 +196,7 @@ func generateService(genericParams map[string]interface{}) (runtime.Object, erro
|
||||
if portNum, err := strconv.Atoi(targetPortString); err != nil {
|
||||
targetPort = intstr.FromString(targetPortString)
|
||||
} else {
|
||||
targetPort = intstr.FromInt(portNum)
|
||||
targetPort = intstr.FromInt32(int32(portNum))
|
||||
}
|
||||
// Use the same target-port for every port
|
||||
for i := range service.Spec.Ports {
|
||||
|
@ -934,13 +934,13 @@ func TestFirewallNeedsUpdate(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
svc := fakeLoadbalancerService("")
|
||||
svc.Spec.Ports = []v1.ServicePort{
|
||||
{Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt(80)},
|
||||
{Name: "port2", Protocol: v1.ProtocolTCP, Port: int32(81), TargetPort: intstr.FromInt(81)},
|
||||
{Name: "port3", Protocol: v1.ProtocolTCP, Port: int32(82), TargetPort: intstr.FromInt(82)},
|
||||
{Name: "port4", Protocol: v1.ProtocolTCP, Port: int32(84), TargetPort: intstr.FromInt(84)},
|
||||
{Name: "port5", Protocol: v1.ProtocolTCP, Port: int32(85), TargetPort: intstr.FromInt(85)},
|
||||
{Name: "port6", Protocol: v1.ProtocolTCP, Port: int32(86), TargetPort: intstr.FromInt(86)},
|
||||
{Name: "port7", Protocol: v1.ProtocolTCP, Port: int32(88), TargetPort: intstr.FromInt(87)},
|
||||
{Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt32(80)},
|
||||
{Name: "port2", Protocol: v1.ProtocolTCP, Port: int32(81), TargetPort: intstr.FromInt32(81)},
|
||||
{Name: "port3", Protocol: v1.ProtocolTCP, Port: int32(82), TargetPort: intstr.FromInt32(82)},
|
||||
{Name: "port4", Protocol: v1.ProtocolTCP, Port: int32(84), TargetPort: intstr.FromInt32(84)},
|
||||
{Name: "port5", Protocol: v1.ProtocolTCP, Port: int32(85), TargetPort: intstr.FromInt32(85)},
|
||||
{Name: "port6", Protocol: v1.ProtocolTCP, Port: int32(86), TargetPort: intstr.FromInt32(86)},
|
||||
{Name: "port7", Protocol: v1.ProtocolTCP, Port: int32(88), TargetPort: intstr.FromInt32(87)},
|
||||
}
|
||||
|
||||
status, err := createExternalLoadBalancer(gce, svc, []string{"test-node-1"}, vals.ClusterName, vals.ClusterID, vals.ZoneName)
|
||||
@ -1643,7 +1643,7 @@ func TestFirewallObject(t *testing.T) {
|
||||
desc: "empty source ranges",
|
||||
sourceRanges: utilnet.IPNetSet{},
|
||||
svcPorts: []v1.ServicePort{
|
||||
{Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt(80)},
|
||||
{Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt32(80)},
|
||||
},
|
||||
expectedFirewall: func(fw compute.Firewall) compute.Firewall {
|
||||
return fw
|
||||
@ -1653,7 +1653,7 @@ func TestFirewallObject(t *testing.T) {
|
||||
desc: "has source ranges",
|
||||
sourceRanges: sourceRanges,
|
||||
svcPorts: []v1.ServicePort{
|
||||
{Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt(80)},
|
||||
{Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt32(80)},
|
||||
},
|
||||
expectedFirewall: func(fw compute.Firewall) compute.Firewall {
|
||||
fw.SourceRanges = srcRanges
|
||||
@ -1665,7 +1665,7 @@ func TestFirewallObject(t *testing.T) {
|
||||
sourceRanges: utilnet.IPNetSet{},
|
||||
destinationIP: dstIP,
|
||||
svcPorts: []v1.ServicePort{
|
||||
{Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt(80)},
|
||||
{Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt32(80)},
|
||||
},
|
||||
expectedFirewall: func(fw compute.Firewall) compute.Firewall {
|
||||
fw.DestinationRanges = []string{dstIP}
|
||||
@ -1676,9 +1676,9 @@ func TestFirewallObject(t *testing.T) {
|
||||
desc: "has multiple ports",
|
||||
sourceRanges: sourceRanges,
|
||||
svcPorts: []v1.ServicePort{
|
||||
{Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt(80)},
|
||||
{Name: "port2", Protocol: v1.ProtocolTCP, Port: int32(82), TargetPort: intstr.FromInt(82)},
|
||||
{Name: "port3", Protocol: v1.ProtocolTCP, Port: int32(84), TargetPort: intstr.FromInt(84)},
|
||||
{Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt32(80)},
|
||||
{Name: "port2", Protocol: v1.ProtocolTCP, Port: int32(82), TargetPort: intstr.FromInt32(82)},
|
||||
{Name: "port3", Protocol: v1.ProtocolTCP, Port: int32(84), TargetPort: intstr.FromInt32(84)},
|
||||
},
|
||||
expectedFirewall: func(fw compute.Firewall) compute.Firewall {
|
||||
fw.Allowed = []*compute.FirewallAllowed{
|
||||
@ -1695,13 +1695,13 @@ func TestFirewallObject(t *testing.T) {
|
||||
desc: "has multiple ports",
|
||||
sourceRanges: sourceRanges,
|
||||
svcPorts: []v1.ServicePort{
|
||||
{Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt(80)},
|
||||
{Name: "port2", Protocol: v1.ProtocolTCP, Port: int32(81), TargetPort: intstr.FromInt(81)},
|
||||
{Name: "port3", Protocol: v1.ProtocolTCP, Port: int32(82), TargetPort: intstr.FromInt(82)},
|
||||
{Name: "port4", Protocol: v1.ProtocolTCP, Port: int32(84), TargetPort: intstr.FromInt(84)},
|
||||
{Name: "port5", Protocol: v1.ProtocolTCP, Port: int32(85), TargetPort: intstr.FromInt(85)},
|
||||
{Name: "port6", Protocol: v1.ProtocolTCP, Port: int32(86), TargetPort: intstr.FromInt(86)},
|
||||
{Name: "port7", Protocol: v1.ProtocolTCP, Port: int32(88), TargetPort: intstr.FromInt(87)},
|
||||
{Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt32(80)},
|
||||
{Name: "port2", Protocol: v1.ProtocolTCP, Port: int32(81), TargetPort: intstr.FromInt32(81)},
|
||||
{Name: "port3", Protocol: v1.ProtocolTCP, Port: int32(82), TargetPort: intstr.FromInt32(82)},
|
||||
{Name: "port4", Protocol: v1.ProtocolTCP, Port: int32(84), TargetPort: intstr.FromInt32(84)},
|
||||
{Name: "port5", Protocol: v1.ProtocolTCP, Port: int32(85), TargetPort: intstr.FromInt32(85)},
|
||||
{Name: "port6", Protocol: v1.ProtocolTCP, Port: int32(86), TargetPort: intstr.FromInt32(86)},
|
||||
{Name: "port7", Protocol: v1.ProtocolTCP, Port: int32(88), TargetPort: intstr.FromInt32(87)},
|
||||
},
|
||||
expectedFirewall: func(fw compute.Firewall) compute.Firewall {
|
||||
fw.Allowed = []*compute.FirewallAllowed{
|
||||
|
@ -671,7 +671,7 @@ func failureTrap(ctx context.Context, c clientset.Interface, ns string) {
|
||||
}
|
||||
|
||||
func intOrStrP(num int) *intstr.IntOrString {
|
||||
intstr := intstr.FromInt(num)
|
||||
intstr := intstr.FromInt32(int32(num))
|
||||
return &intstr
|
||||
}
|
||||
|
||||
|
@ -1035,7 +1035,7 @@ func runDrainTest(ctx context.Context, f *framework.Framework, migSizes map[stri
|
||||
ginkgo.DeferCleanup(e2erc.DeleteRCAndWaitForGC, f.ClientSet, namespace, "reschedulable-pods")
|
||||
|
||||
ginkgo.By("Create a PodDisruptionBudget")
|
||||
minAvailable := intstr.FromInt(numPods - pdbSize)
|
||||
minAvailable := intstr.FromInt32(int32(numPods - pdbSize))
|
||||
pdb := &policyv1.PodDisruptionBudget{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test_pdb",
|
||||
@ -1915,7 +1915,7 @@ func addKubeSystemPdbs(ctx context.Context, f *framework.Framework) error {
|
||||
ginkgo.By(fmt.Sprintf("Create PodDisruptionBudget for %v", pdbData.label))
|
||||
labelMap := map[string]string{"k8s-app": pdbData.label}
|
||||
pdbName := fmt.Sprintf("test-pdb-for-%v", pdbData.label)
|
||||
minAvailable := intstr.FromInt(pdbData.minAvailable)
|
||||
minAvailable := intstr.FromInt32(int32(pdbData.minAvailable))
|
||||
pdb := &policyv1.PodDisruptionBudget{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: pdbName,
|
||||
|
@ -1196,7 +1196,7 @@ var _ = SIGDescribe("[NodeAlphaFeature:SidecarContainers][Feature:SidecarContain
|
||||
ProbeHandler: v1.ProbeHandler{
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Path: "/healthz",
|
||||
Port: intstr.FromInt(8080),
|
||||
Port: intstr.FromInt32(8080),
|
||||
},
|
||||
},
|
||||
InitialDelaySeconds: 10,
|
||||
@ -1660,7 +1660,7 @@ func httpGetHandler(path string, port int) v1.ProbeHandler {
|
||||
return v1.ProbeHandler{
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Path: path,
|
||||
Port: intstr.FromInt(port),
|
||||
Port: intstr.FromInt32(int32(port)),
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -1668,7 +1668,7 @@ func httpGetHandler(path string, port int) v1.ProbeHandler {
|
||||
func tcpSocketHandler(port int) v1.ProbeHandler {
|
||||
return v1.ProbeHandler{
|
||||
TCPSocket: &v1.TCPSocketAction{
|
||||
Port: intstr.FromInt(port),
|
||||
Port: intstr.FromInt32(int32(port)),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ var _ = SIGDescribe("[NodeAlphaFeature:SidecarContainers][Feature:SidecarContain
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Path: "/echo?msg=poststart",
|
||||
Host: targetIP,
|
||||
Port: intstr.FromInt(8080),
|
||||
Port: intstr.FromInt32(8080),
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -432,7 +432,7 @@ var _ = SIGDescribe("[NodeAlphaFeature:SidecarContainers][Feature:SidecarContain
|
||||
Scheme: v1.URISchemeHTTPS,
|
||||
Path: "/echo?msg=poststart",
|
||||
Host: targetIP,
|
||||
Port: intstr.FromInt(9090),
|
||||
Port: intstr.FromInt32(9090),
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -459,7 +459,7 @@ var _ = SIGDescribe("[NodeAlphaFeature:SidecarContainers][Feature:SidecarContain
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Path: "/echo?msg=prestop",
|
||||
Host: targetIP,
|
||||
Port: intstr.FromInt(8080),
|
||||
Port: intstr.FromInt32(8080),
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -487,7 +487,7 @@ var _ = SIGDescribe("[NodeAlphaFeature:SidecarContainers][Feature:SidecarContain
|
||||
Scheme: v1.URISchemeHTTPS,
|
||||
Path: "/echo?msg=prestop",
|
||||
Host: targetIP,
|
||||
Port: intstr.FromInt(9090),
|
||||
Port: intstr.FromInt32(9090),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ func svcByName(name string, port int) *v1.Service {
|
||||
},
|
||||
Ports: []v1.ServicePort{{
|
||||
Port: int32(port),
|
||||
TargetPort: intstr.FromInt(port),
|
||||
TargetPort: intstr.FromInt32(int32(port)),
|
||||
}},
|
||||
},
|
||||
}
|
||||
|
@ -585,7 +585,7 @@ func createService(ctx context.Context, c clientset.Interface, name, ns string,
|
||||
Spec: v1.ServiceSpec{
|
||||
Ports: []v1.ServicePort{{
|
||||
Port: port,
|
||||
TargetPort: intstr.FromInt(targetPort),
|
||||
TargetPort: intstr.FromInt32(int32(targetPort)),
|
||||
}},
|
||||
Selector: selectors,
|
||||
},
|
||||
|
@ -688,8 +688,8 @@ func (config *NetworkingTestConfig) createNodePortServiceSpec(svcName string, se
|
||||
Spec: v1.ServiceSpec{
|
||||
Type: v1.ServiceTypeNodePort,
|
||||
Ports: []v1.ServicePort{
|
||||
{Port: ClusterHTTPPort, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(EndpointHTTPPort)},
|
||||
{Port: ClusterUDPPort, Name: "udp", Protocol: v1.ProtocolUDP, TargetPort: intstr.FromInt(EndpointUDPPort)},
|
||||
{Port: ClusterHTTPPort, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(EndpointHTTPPort)},
|
||||
{Port: ClusterUDPPort, Name: "udp", Protocol: v1.ProtocolUDP, TargetPort: intstr.FromInt32(EndpointUDPPort)},
|
||||
},
|
||||
Selector: selector,
|
||||
SessionAffinity: sessionAffinity,
|
||||
@ -697,7 +697,7 @@ func (config *NetworkingTestConfig) createNodePortServiceSpec(svcName string, se
|
||||
}
|
||||
|
||||
if config.SCTPEnabled {
|
||||
res.Spec.Ports = append(res.Spec.Ports, v1.ServicePort{Port: ClusterSCTPPort, Name: "sctp", Protocol: v1.ProtocolSCTP, TargetPort: intstr.FromInt(EndpointSCTPPort)})
|
||||
res.Spec.Ports = append(res.Spec.Ports, v1.ServicePort{Port: ClusterSCTPPort, Name: "sctp", Protocol: v1.ProtocolSCTP, TargetPort: intstr.FromInt32(EndpointSCTPPort)})
|
||||
}
|
||||
if config.DualStackEnabled {
|
||||
requireDual := v1.IPFamilyPolicyRequireDualStack
|
||||
|
@ -148,7 +148,7 @@ func CreateServiceForSimpleApp(ctx context.Context, c clientset.Interface, contP
|
||||
return []v1.ServicePort{{
|
||||
Protocol: v1.ProtocolTCP,
|
||||
Port: int32(svcPort),
|
||||
TargetPort: intstr.FromInt(contPort),
|
||||
TargetPort: intstr.FromInt32(int32(contPort)),
|
||||
}}
|
||||
}
|
||||
framework.Logf("Creating a service-for-%v for selecting app=%v-pod", appName, appName)
|
||||
|
@ -222,7 +222,7 @@ func (t *dnsTestCommon) createUtilPodLabel(ctx context.Context, baseName string)
|
||||
{
|
||||
Protocol: v1.ProtocolTCP,
|
||||
Port: servicePort,
|
||||
TargetPort: intstr.FromInt(servicePort),
|
||||
TargetPort: intstr.FromInt32(servicePort),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -194,7 +194,7 @@ func createSecondNodePortService(ctx context.Context, f *framework.Framework, co
|
||||
Port: e2enetwork.ClusterHTTPPort,
|
||||
Name: "http",
|
||||
Protocol: v1.ProtocolTCP,
|
||||
TargetPort: intstr.FromInt(e2enetwork.EndpointHTTPPort),
|
||||
TargetPort: intstr.FromInt32(e2enetwork.EndpointHTTPPort),
|
||||
},
|
||||
},
|
||||
Selector: config.NodePortService.Spec.Selector,
|
||||
|
@ -187,7 +187,7 @@ func markPodReady(c clientset.Interface, ns string, pod *v1.Pod) error {
|
||||
}
|
||||
|
||||
func intOrStrP(num int) *intstr.IntOrString {
|
||||
intstr := intstr.FromInt(num)
|
||||
intstr := intstr.FromInt32(int32(num))
|
||||
return &intstr
|
||||
}
|
||||
|
||||
|
@ -1231,7 +1231,7 @@ func TestNominatedNodeCleanUp(t *testing.T) {
|
||||
}
|
||||
|
||||
func mkMinAvailablePDB(name, namespace string, uid types.UID, minAvailable int, matchLabels map[string]string) *policy.PodDisruptionBudget {
|
||||
intMinAvailable := intstr.FromInt(minAvailable)
|
||||
intMinAvailable := intstr.FromInt32(int32(minAvailable))
|
||||
return &policy.PodDisruptionBudget{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
|
Loading…
Reference in New Issue
Block a user