diff --git a/go.mod b/go.mod index 1542d20420..8b1f763bed 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/onsi/ginkgo v1.12.0 github.com/onsi/gomega v1.8.1 github.com/openshift/api v0.0.0-20200424083944-0422dc17083e - github.com/openshift/machine-api-operator v0.2.1-0.20200722104429-f4f9b84df9b7 + github.com/openshift/machine-api-operator v0.2.1-0.20200819233022-79ac5f8a0097 // kube 1.18 k8s.io/api v0.18.2 diff --git a/go.sum b/go.sum index 4e79a6664d..012d24c68d 100644 --- a/go.sum +++ b/go.sum @@ -342,12 +342,16 @@ github.com/openshift/cluster-api-provider-azure v0.1.0-alpha.3.0.20200618001858- github.com/openshift/cluster-api-provider-gcp v0.0.1-0.20200701112720-3a7d727c9a10/go.mod h1:wgkZrOlcIMWTzo8khB4Js2PoDJDlIUUdzCBm7BuDdqw= github.com/openshift/cluster-api-provider-gcp v0.0.1-0.20200713133651-5c8a640669ac h1:j4kWMuCD5Yvwa3LDXy0tN0ys24jDbQnQbCl0oRTBb6I= github.com/openshift/cluster-api-provider-gcp v0.0.1-0.20200713133651-5c8a640669ac/go.mod h1:XVYX9JE339nKbDDa/W481XD+1GTeqeaBm8bDPr7WE7I= +github.com/openshift/cluster-api-provider-gcp v0.0.1-0.20200813171611-46c5454e7175 h1:9wH82ayUDy9Y+loTm319cJVTol+cwbH6ZNYKezeWCQQ= +github.com/openshift/cluster-api-provider-gcp v0.0.1-0.20200813171611-46c5454e7175/go.mod h1:rcwAydGZX+z4l91wtOdbq+fqDwuo6iu0YuFik3UUc+8= github.com/openshift/library-go v0.0.0-20200512120242-21a1ff978534/go.mod h1:2kWwXTkpoQJUN3jZ3QW88EIY1hdRMqxgRs2hheEW/pg= github.com/openshift/machine-api-operator v0.2.1-0.20200527204437-14e5e0c7d862/go.mod h1:YKEQMHjXzrzm4fQGTyHBafFfQ/Yq/FrV+1YcGdPCp+0= github.com/openshift/machine-api-operator v0.2.1-0.20200611014855-9a69f85c32dd/go.mod h1:6vMi+R3xqznBdq5rgeal9N3ak3sOpy50t0fdRCcQXjE= github.com/openshift/machine-api-operator v0.2.1-0.20200701225707-950912b03628/go.mod h1:cxjy/RUzv5C2T5FNl1KKXUgtakWsezWQ642B/CD9VQA= github.com/openshift/machine-api-operator v0.2.1-0.20200722104429-f4f9b84df9b7 h1:jeLZ5Ng+Ri42dbZveN1ofrrRsUnYusauzeXPDTnXQfE= github.com/openshift/machine-api-operator v0.2.1-0.20200722104429-f4f9b84df9b7/go.mod h1:XDsNRAVEJtkI00e51SAZ/PnqNJl1zv0rHXSdl9L1oOY= +github.com/openshift/machine-api-operator v0.2.1-0.20200819233022-79ac5f8a0097 h1:vV7hlJyXrZfW/1GWjFmAgtxLhjgIW8ECurR3MNlsBio= +github.com/openshift/machine-api-operator v0.2.1-0.20200819233022-79ac5f8a0097/go.mod h1:flL4H7gYTcX6pSmalAYaZ60LC+tUGw80ocKq082ydzY= github.com/operator-framework/operator-sdk v0.5.1-0.20190301204940-c2efe6f74e7b/go.mod h1:iVyukRkam5JZa8AnjYf+/G3rk7JI1+M6GsU0sq0B9NA= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= diff --git a/vendor/github.com/openshift/cluster-api-provider-gcp/pkg/apis/gcpprovider/v1beta1/gcpmachineproviderconfig_types.go b/vendor/github.com/openshift/cluster-api-provider-gcp/pkg/apis/gcpprovider/v1beta1/gcpmachineproviderconfig_types.go index b1e9ec4c18..4271f0117e 100644 --- a/vendor/github.com/openshift/cluster-api-provider-gcp/pkg/apis/gcpprovider/v1beta1/gcpmachineproviderconfig_types.go +++ b/vendor/github.com/openshift/cluster-api-provider-gcp/pkg/apis/gcpprovider/v1beta1/gcpmachineproviderconfig_types.go @@ -66,6 +66,7 @@ type GCPMetadata struct { type GCPNetworkInterface struct { PublicIP bool `json:"publicIP,omitempty"` Network string `json:"network,omitempty"` + ProjectID string `json:"projectID,omitempty"` Subnetwork string `json:"subnetwork,omitempty"` } diff --git a/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/machine_webhook.go b/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/machine_webhook.go index 4dab8e2abe..6a6bc31a9a 100644 --- a/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/machine_webhook.go +++ b/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/machine_webhook.go @@ -67,9 +67,6 @@ var ( defaultGCPSubnetwork = func(clusterID string) string { return fmt.Sprintf("%s-worker-subnet", clusterID) } - defaultGCPDiskImage = func(clusterID string) string { - return fmt.Sprintf("%s-rhcos-image", clusterID) - } defaultGCPTags = func(clusterID string) []string { return []string{fmt.Sprintf("%s-worker", clusterID)} } @@ -95,7 +92,7 @@ const ( defaultWebhookServiceName = "machine-api-operator-webhook" defaultWebhookServiceNamespace = "openshift-machine-api" - defaultUserDataSecret = "worker-user-data" + defaultUserDataSecret = "worker-user-data-managed" defaultSecretNamespace = "openshift-machine-api" // AWS Defaults @@ -113,12 +110,18 @@ const ( defaultGCPCredentialsSecret = "gcp-cloud-credentials" defaultGCPDiskSizeGb = 128 defaultGCPDiskType = "pd-standard" + // https://releases-art-rhcos.svc.ci.openshift.org/art/storage/releases/rhcos-4.6/46.82.202007212240-0/x86_64/meta.json + // https://github.com/openshift/installer/pull/3808 + // https://github.com/openshift/installer/blob/d75bf7ad98124b901ae7e22b5595e0392ed6ea3c/data/data/rhcos.json + defaultGCPDiskImage = "projects/rhcos-cloud/global/images/rhcos-46-82-202007212240-0-gcp-x86-64" // vSphere Defaults defaultVSphereCredentialsSecret = "vsphere-cloud-credentials" // Minimum vSphere values taken from vSphere reconciler minVSphereCPU = 2 minVSphereMemoryMiB = 2048 + // https://docs.openshift.com/container-platform/4.1/installing/installing_vsphere/installing-vsphere.html#minimum-resource-requirements_installing-vsphere + minVSphereDiskGiB = 120 ) var ( @@ -445,14 +448,16 @@ func (h *machineDefaulterHandler) Handle(ctx context.Context, req admission.Requ klog.V(3).Infof("Mutate webhook called for Machine: %s", m.GetName()) - // Enforce that the same clusterID is set for machineSet Selector and machine labels. + // Only enforce the clusterID if it's not set. // Otherwise a discrepancy on the value would leave the machine orphan // and would trigger a new machine creation by the machineSet. // https://bugzilla.redhat.com/show_bug.cgi?id=1857175 if m.Labels == nil { m.Labels = make(map[string]string) } - m.Labels[MachineClusterIDLabel] = h.clusterID + if _, ok := m.Labels[MachineClusterIDLabel]; !ok { + m.Labels[MachineClusterIDLabel] = h.clusterID + } if ok, err := h.webhookOperations(m, h.clusterID); !ok { return admission.Denied(err.Error()) @@ -890,7 +895,7 @@ func defaultGCPDisks(disks []*gcp.GCPDisk, clusterID string) []*gcp.GCPDisk { Boot: true, SizeGb: defaultGCPDiskSizeGb, Type: defaultGCPDiskType, - Image: defaultGCPDiskImage(clusterID), + Image: defaultGCPDiskImage, }, } } @@ -901,7 +906,7 @@ func defaultGCPDisks(disks []*gcp.GCPDisk, clusterID string) []*gcp.GCPDisk { } if disk.Image == "" { - disk.Image = defaultGCPDiskImage(clusterID) + disk.Image = defaultGCPDiskImage } } @@ -1043,6 +1048,20 @@ func defaultVSphere(m *Machine, clusterID string) (bool, utilerrors.Aggregate) { providerSpec.CredentialsSecret = &corev1.LocalObjectReference{Name: defaultVSphereCredentialsSecret} } + // Default values for number of cpu, memory and disk size come from installer + // https://github.com/openshift/installer/blob/0ceffc5c737b49ab59441e2fd02f51f997d54a53/pkg/asset/machines/worker.go#L134 + if providerSpec.NumCPUs == 0 { + providerSpec.NumCPUs = minVSphereCPU + } + + if providerSpec.MemoryMiB == 0 { + providerSpec.MemoryMiB = minVSphereMemoryMiB + } + + if providerSpec.DiskGiB == 0 { + providerSpec.DiskGiB = minVSphereDiskGiB + } + rawBytes, err := json.Marshal(providerSpec) if err != nil { errs = append(errs, err) @@ -1079,6 +1098,9 @@ func validateVSphere(m *Machine, clusterID string) (bool, utilerrors.Aggregate) if providerSpec.MemoryMiB != 0 && providerSpec.MemoryMiB < minVSphereMemoryMiB { errs = append(errs, field.Invalid(field.NewPath("providerSpec", "memoryMiB"), providerSpec.MemoryMiB, fmt.Sprintf("memoryMiB is below minimum value (%d)", minVSphereMemoryMiB))) } + if providerSpec.DiskGiB != 0 && providerSpec.DiskGiB < minVSphereDiskGiB { + errs = append(errs, field.Invalid(field.NewPath("providerSpec", "diskGiB"), providerSpec.DiskGiB, fmt.Sprintf("diskGiB is below minimum value (%d)", minVSphereDiskGiB))) + } if providerSpec.UserDataSecret == nil { errs = append(errs, field.Required(field.NewPath("providerSpec", "userDataSecret"), "userDataSecret must be provided")) diff --git a/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/machinehealthcheck_types.go b/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/machinehealthcheck_types.go index 21ff73e42c..16cc7ad3e4 100644 --- a/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/machinehealthcheck_types.go +++ b/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/machinehealthcheck_types.go @@ -54,20 +54,25 @@ type MachineHealthCheckSpec struct { // Any farther remediation is only allowed if at most "MaxUnhealthy" machines selected by // "selector" are not healthy. - // +optional + // Expects either a postive integer value or a percentage value. + // Percentage values must be positive whole numbers and are capped at 100%. + // Both 0 and 0% are valid and will block all remediation. + // +kubebuilder:default:="100%" + // +kubebuilder:validation:Pattern="^((100|[0-9]{1,2})%|[0-9]+)$" + // +kubebuilder:validation:Type:=string + // +kubebuilder:validation:Minimum:=0 MaxUnhealthy *intstr.IntOrString `json:"maxUnhealthy,omitempty"` - // It would be preferable for nodeStartupTimeout to be a metav1.Duration, but - // there's no good way to validate the format here. Invalid input would cause - // problems with marshaling, so it's better to just make it a string and - // handle the conversion in the controller. - // - // Intentional blank line to keep this out of the OpenAPI description... - // Machines older than this duration without a node will be considered to have // failed and will be remediated. + // Expects an unsigned duration string of decimal numbers each with optional + // fraction and a unit suffix, eg "300ms", "1.5h" or "2h45m". + // Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". // +optional - NodeStartupTimeout string `json:"nodeStartupTimeout,omitempty"` + // +kubebuilder:default:="10m" + // +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$" + // +kubebuilder:validation:Type:=string + NodeStartupTimeout metav1.Duration `json:"nodeStartupTimeout,omitempty"` } // UnhealthyCondition represents a Node condition type and value with a timeout @@ -82,15 +87,12 @@ type UnhealthyCondition struct { // +kubebuilder:validation:MinLength=1 Status corev1.ConditionStatus `json:"status"` - // It would be preferable for timeout to be a metav1.Duration, but there's - // no good way to validate the format here. Invalid input would cause - // problems with marshaling, so it's better to just make it a string and - // handle the conversion in the controller. - // - // Intentional blank line to keep this out of the OpenAPI description... - - // +kubebuilder:validation:MinLength=1 - Timeout string `json:"timeout"` + // Expects an unsigned duration string of decimal numbers each with optional + // fraction and a unit suffix, eg "300ms", "1.5h" or "2h45m". + // Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". + // +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$" + // +kubebuilder:validation:Type:=string + Timeout metav1.Duration `json:"timeout"` } // MachineHealthCheckStatus defines the observed state of MachineHealthCheck diff --git a/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/machineset_webhook.go b/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/machineset_webhook.go index 6e3bd90cfd..6dd8998551 100644 --- a/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/machineset_webhook.go +++ b/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/machineset_webhook.go @@ -117,33 +117,13 @@ func (h *machineSetValidatorHandler) validateMachineSet(ms *MachineSet) (bool, u } func (h *machineSetDefaulterHandler) defaultMachineSet(ms *MachineSet) (bool, utilerrors.Aggregate) { - var errs []error - // Create a Machine from the MachineSet and default the Machine template m := &Machine{Spec: ms.Spec.Template.Spec} if ok, err := h.webhookOperations(m, h.clusterID); !ok { - errs = append(errs, err.Errors()...) - } else { - // Enforce that the same clusterID is set for machineSet Selector and machine labels. - // Otherwise a discrepancy on the value would leave the machine orphan - // and would trigger a new machine creation by the machineSet. - // https://bugzilla.redhat.com/show_bug.cgi?id=1857175 - if ms.Spec.Selector.MatchLabels == nil { - ms.Spec.Selector.MatchLabels = make(map[string]string) - } - ms.Spec.Selector.MatchLabels[MachineClusterIDLabel] = h.clusterID - - if ms.Spec.Template.Labels == nil { - ms.Spec.Template.Labels = make(map[string]string) - } - ms.Spec.Template.Labels[MachineClusterIDLabel] = h.clusterID - - // Restore the defaulted template - ms.Spec.Template.Spec = m.Spec + return false, utilerrors.NewAggregate(err.Errors()) } - if len(errs) > 0 { - return false, utilerrors.NewAggregate(errs) - } + // Restore the defaulted template + ms.Spec.Template.Spec = m.Spec return true, nil } diff --git a/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/zz_generated.deepcopy.go b/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/zz_generated.deepcopy.go index f13a4dbb27..f7a48e4b06 100644 --- a/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/zz_generated.deepcopy.go +++ b/vendor/github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1/zz_generated.deepcopy.go @@ -165,6 +165,7 @@ func (in *MachineHealthCheckSpec) DeepCopyInto(out *MachineHealthCheckSpec) { *out = new(intstr.IntOrString) **out = **in } + out.NodeStartupTimeout = in.NodeStartupTimeout return } @@ -511,6 +512,7 @@ func (in *ProviderSpec) DeepCopy() *ProviderSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *UnhealthyCondition) DeepCopyInto(out *UnhealthyCondition) { *out = *in + out.Timeout = in.Timeout return } diff --git a/vendor/github.com/openshift/machine-api-operator/pkg/metrics/metrics.go b/vendor/github.com/openshift/machine-api-operator/pkg/metrics/metrics.go index ce70b98665..0097a148b5 100644 --- a/vendor/github.com/openshift/machine-api-operator/pkg/metrics/metrics.go +++ b/vendor/github.com/openshift/machine-api-operator/pkg/metrics/metrics.go @@ -120,18 +120,22 @@ func (mc MachineCollector) collectMachineMetrics(ch chan<- prometheus.Metric) { if machine.Status.NodeRef != nil { nodeName = machine.Status.NodeRef.Name } - - ch <- prometheus.MustNewConstMetric( - MachineInfoDesc, - prometheus.GaugeValue, - float64(machine.ObjectMeta.GetCreationTimestamp().Time.Unix()), - machine.ObjectMeta.Name, - machine.ObjectMeta.Namespace, - stringPointerDeref(machine.Spec.ProviderID), - nodeName, - machine.TypeMeta.APIVersion, - stringPointerDeref(machine.Status.Phase), - ) + // Only gather metrics for machines with a phase. This indicates + // That the machine-controller is running on this cluster. + phase := stringPointerDeref(machine.Status.Phase) + if phase != "" { + ch <- prometheus.MustNewConstMetric( + MachineInfoDesc, + prometheus.GaugeValue, + float64(machine.ObjectMeta.GetCreationTimestamp().Time.Unix()), + machine.ObjectMeta.Name, + machine.ObjectMeta.Namespace, + stringPointerDeref(machine.Spec.ProviderID), + nodeName, + machine.TypeMeta.APIVersion, + phase, + ) + } } ch <- prometheus.MustNewConstMetric(MachineCountDesc, prometheus.GaugeValue, float64(len(machineList))) @@ -201,7 +205,7 @@ func RegisterFailedInstanceCreate(labels *MachineLabels) { } func RegisterFailedInstanceUpdate(labels *MachineLabels) { - failedInstanceCreateCount.With(prometheus.Labels{ + failedInstanceUpdateCount.With(prometheus.Labels{ "name": labels.Name, "namespace": labels.Namespace, "reason": labels.Reason, diff --git a/vendor/modules.txt b/vendor/modules.txt index 45db46b1e1..621a1981aa 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -192,9 +192,9 @@ github.com/openshift/api/config/v1 github.com/openshift/client-go/config/clientset/versioned github.com/openshift/client-go/config/clientset/versioned/scheme github.com/openshift/client-go/config/clientset/versioned/typed/config/v1 -# github.com/openshift/cluster-api-provider-gcp v0.0.1-0.20200713133651-5c8a640669ac +# github.com/openshift/cluster-api-provider-gcp v0.0.1-0.20200813171611-46c5454e7175 github.com/openshift/cluster-api-provider-gcp/pkg/apis/gcpprovider/v1beta1 -# github.com/openshift/machine-api-operator v0.2.1-0.20200722104429-f4f9b84df9b7 +# github.com/openshift/machine-api-operator v0.2.1-0.20200819233022-79ac5f8a0097 github.com/openshift/machine-api-operator/pkg/apis/machine github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1 github.com/openshift/machine-api-operator/pkg/apis/vsphereprovider/v1beta1