Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add machineconfiguration API group #620

Closed
wants to merge 2 commits into from

Conversation

LorbusChris
Copy link
Member

@LorbusChris LorbusChris commented Apr 6, 2020

This moves over the machineconfiguration API from the
github.com/openshift/machine-config-operator repo,
and adds swagger doc generation for it.

TODO:

  • Re-add ControllerConfig
  • Exclude RawExtension from OpenAPI Validation generation
  • Address review here

/cc @runcom

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LorbusChris
To complete the pull request process, please assign sjenning
You can assign the PR to them by writing /assign @sjenning in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@runcom
Copy link
Member

runcom commented Apr 6, 2020

/cc @yuqi-zhang

@LorbusChris
Copy link
Member Author

LorbusChris commented Apr 6, 2020

// +k8s:openapi-gen=true is set in doc.go but and make update yields no further changes in the crd yaml files.
I would've expected it to overwrite the customized validation for machineconfig.spec.config, which is a RawExtension type.
Could somebody clarify why this isn't happening?

kind: CustomResourceDefinition
metadata:
# name must match the spec fields below, and be in the form: <plural>.<group>
name: controllerconfigs.machineconfiguration.openshift.io
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure this should be part of the openshift/api since this looks like an machine-config-operator internal API..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are in the same group at the moment (machineconfiguration.openshift.io). Should we move them out of that group into an MCO-internal group? Are there conventions around this?

)

// NewMachineConfigPoolCondition creates a new MachineConfigPool condition.
func NewMachineConfigPoolCondition(condType MachineConfigPoolConditionType, status corev1.ConditionStatus, reason, message string) *MachineConfigPoolCondition {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm.. the helper functions usually end up in library-go instead of the API..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like they're not used anywhere else and they could stay in the MCO repo for now.

@LorbusChris
Copy link
Member Author

Just to verify, the controllerconfigs.machineconfiguration.openshift.io API that is only used by the MachineConfig controller internally should stay in the MCO repo?
If so, should it be moved out of the machineconfiguration API group?

This moves over all external API from the
github.com/openshift/machine-config-operator repo,
and adds swagger doc generation for it.
@LorbusChris LorbusChris changed the title Add machineconfiguration API Add machineconfiguration API group Apr 6, 2020
@LorbusChris
Copy link
Member Author

LorbusChris commented Apr 6, 2020

I've removed the controllerconfig CRD and API from this PR.

Please let me know if I should add it back.
The open questions above remain.

@yuqi-zhang
Copy link
Contributor

I'm not very familiar with how we structure CRDs. It'd obviously be nicer from a maintenance perspective if everything in the *.machineconfiguration.openshift.io lived in the same repo but I defer to the experts.

)

const (
GroupName = "machineconfiguration.openshift.io"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this group already exists and this is a straight move?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plural: containerruntimeconfigs
singular: containerruntimeconfig
shortNames:
- ctrcfg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this already present in your CRD manifest today? We discourage shortnames on resources that are infrequently used by cluster-admins.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, already present


// MachineConfigRoleLabelKey is metadata key in the MachineConfig. Specifies the node role that config should be applied to.
// For example: `master` or `worker`
const MachineConfigRoleLabelKey = "machineconfiguration.openshift.io/role"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

general API note. if you own the schema of the struct, why wasn't this just a top level field?

type MachineConfigPoolSpec struct {
// machineConfigSelector specifies a label selector for MachineConfigs.
// Refer https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ on how label and selectors work.
MachineConfigSelector *metav1.LabelSelector `json:"machineConfigSelector,omitempty" protobuf:"bytes,1,opt,name=machineConfigSelector"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to explain what nil means here. All, none, somethign else?

MachineConfigSelector *metav1.LabelSelector `json:"machineConfigSelector,omitempty" protobuf:"bytes,1,opt,name=machineConfigSelector"`

// nodeSelector specifies a label selector for Machines
NodeSelector *metav1.LabelSelector `json:"nodeSelector,omitempty" protobuf:"bytes,2,opt,name=nodeSelector"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe the meaning of nil

// +nullable
KernelArguments []string `json:"kernelArguments" protobuf:"bytes,3,rep,name=kernelArguments"`

FIPS bool `json:"fips" protobuf:"varint,4,opt,name=fips"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing doc

type MachineConfigSpec struct {
// OSImageURL specifies the remote location that will be used to
// fetch the OS.
OSImageURL string `json:"osImageURL" protobuf:"bytes,1,opt,name=osImageURL"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing required/optional if optional, what does empty string mean?

// fetch the OS.
OSImageURL string `json:"osImageURL" protobuf:"bytes,1,opt,name=osImageURL"`
// Config is a Ignition Config object.
Config runtime.RawExtension `json:"config" protobuf:"bytes,2,opt,name=config"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine. You're interpretting the value elsewhere but this eliminated the problematic compile time dep?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. This is parsed into Ignition.Config by the MCO

// OSImageURL specifies the remote location that will be used to
// fetch the OS.
OSImageURL string `json:"osImageURL" protobuf:"bytes,1,opt,name=osImageURL"`
// Config is a Ignition Config object.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

point to where the schema is please.

Config runtime.RawExtension `json:"config" protobuf:"bytes,2,opt,name=config"`

// +nullable
KernelArguments []string `json:"kernelArguments" protobuf:"bytes,3,rep,name=kernelArguments"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs doc.


// maxUnavailable specifies the percentage or constant number of machines that can be updating at any given time.
// default is 1.
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty" protobuf:"bytes,4,opt,name=maxUnavailable"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does zero mean here? based on comment, this would end poorly.

// MachineConfigPoolStatusConfiguration stores the current configuration for the pool, and
// optionally also stores the list of MachineConfig objects used to generate the configuration.
type MachineConfigPoolStatusConfiguration struct {
corev1.ObjectReference `json:",inline" protobuf:"bytes,1,opt,name=objectReference"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably don't honor all the fields of this struct. We encourage creating specific reference objects so you can provide precise docs. This will need revisiting.


// source is the list of MachineConfig objects that were used to generate the single MachineConfig object specified in `content`.
// +optional
Source []corev1.ObjectReference `json:"source,omitempty" protobuf:"bytes,2,rep,name=source"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably don't honor all the fields of this struct. We encourage creating specific reference objects so you can provide precise docs. This will need revisiting.


// KubeletConfigSpec defines the desired state of KubeletConfig
type KubeletConfigSpec struct {
MachineConfigPoolSelector *metav1.LabelSelector `json:"machineConfigPoolSelector,omitempty" protobuf:"bytes,1,opt,name=machineConfigPoolSelector"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to describe the meaning of nil

// KubeletConfigSpec defines the desired state of KubeletConfig
type KubeletConfigSpec struct {
MachineConfigPoolSelector *metav1.LabelSelector `json:"machineConfigPoolSelector,omitempty" protobuf:"bytes,1,opt,name=machineConfigPoolSelector"`
KubeletConfig *runtime.RawExtension `json:"kubeletConfig,omitempty" protobuf:"bytes,2,opt,name=kubeletConfig"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe the meaning of nil and point to what schema is accepted here.

KubeletConfigSuccess KubeletConfigStatusConditionType = "Success"

// KubeletConfigFailure designates a failure applying a KubeletConfig CR.
KubeletConfigFailure KubeletConfigStatusConditionType = "Failure"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these conditions are a bit odd, since Failure is usually Success == false.

@LorbusChris
Copy link
Member Author

deferring to @runcom to answer these questions. I'd prefer to have these issues fixed in the MCO repo before the move

This removes the hand-rafted API Validation for the RawExtension that contains Ignitition.Config

WIP
@LorbusChris LorbusChris changed the title Add machineconfiguration API group WIP: Add machineconfiguration API group Apr 7, 2020
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 7, 2020
@LorbusChris
Copy link
Member Author

This is stale. Someone from the MCO team should create a new PR once the API move task has been prioritized and scheduled for a sprint.
/close

@openshift-ci-robot
Copy link

@LorbusChris: Closed this PR.

In response to this:

This is stale. Someone from the MCO team should create a new PR once the API move task has been prioritized and scheduled for a sprint.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants