-
Notifications
You must be signed in to change notification settings - Fork 510
MCO-1713:[API 4/6] Update MCO to reflect API changes made for Status Reporting #5177
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
Changes from 8 commits
42c3d26
8c3f747
c5f30d0
ab8a94d
1fe21d2
e0ec96d
ae76087
8a455ca
4f9b635
7f52c15
74536f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1073,6 +1073,22 @@ func (dn *Daemon) update(oldConfig, newConfig *mcfgv1.MachineConfig, skipCertifi | |
| if err != nil { | ||
| klog.Errorf("Error making MCN spec for Update Compatible: %v", err) | ||
| } | ||
|
|
||
| _, newOCLImage := extractOCLImageFromMachineConfig(newConfig) | ||
| err = upgrademonitor.GenerateAndApplyMachineConfigNodes( | ||
| &upgrademonitor.Condition{State: mcfgv1.MachineConfigNodeUpdateExecuted, Reason: string(mcfgv1.MachineConfigNodeImagePulledFromRegistry), Message: fmt.Sprintf("Image %s pulled from registry.", newOCLImage)}, | ||
| &upgrademonitor.Condition{State: mcfgv1.MachineConfigNodeImagePulledFromRegistry, Reason: fmt.Sprintf("%s%s", string(mcfgv1.MachineConfigNodeUpdateExecuted), string(mcfgv1.MachineConfigNodeImagePulledFromRegistry)), Message: fmt.Sprintf("ask message")}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey, it looks like this message "ask message" might be a placeholder.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, do you have any suggestions on the message that should be produced?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. anything that signifies that the image was pulled! |
||
| metav1.ConditionUnknown, | ||
| metav1.ConditionTrue, | ||
| dn.node, | ||
| dn.mcfgClient, | ||
| dn.featureGatesAccessor, | ||
| pool, | ||
| ) | ||
| if err != nil { | ||
| klog.Errorf("Error making MCN for Pulling Image from Registry: %v", err) | ||
| } | ||
|
|
||
| if drain { | ||
| if err := dn.performDrain(); err != nil { | ||
| return err | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -807,6 +807,14 @@ func (optr *Operator) syncMachineConfigNodes(_ *renderConfig, _ *configv1.Cluste | |
| }, | ||
| }, | ||
| } | ||
|
|
||
| //Add: check if image mode status reporting fg is enables and if yes, use 821-826 as a guideline for configImage initialization | ||
| if fg.Enabled(features.FeatureGateImageModeStatusReporting) { | ||
| newMCS.Spec.ConfigImage = mcfgv1.MachineConfigNodeSpecConfigImage{ | ||
| DesiredImage: mcfgv1.ImageDigestFormat(node.Annotations[daemonconsts.DesiredImageAnnotationKey]), | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think how we handle this depends on the decision made this thread on the API review (openshift/api#2383) on whether the configImage value is required or not and what it means for whether OCL is enabled or not. If
|
||
|
|
||
| mcsBytes, err := json.Marshal(newMCS) | ||
| if err != nil { | ||
| klog.Errorf("error rendering asset for MachineConfigNode %v", err) | ||
|
|
@@ -817,6 +825,7 @@ func (optr *Operator) syncMachineConfigNodes(_ *renderConfig, _ *configv1.Cluste | |
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // if this is the first time we are applying the MCN and the node is ready, set the config version probably | ||
| if mcn.Spec.ConfigVersion.Desired == upgrademonitor.NotYetSet { | ||
| err = upgrademonitor.GenerateAndApplyMachineConfigNodeSpec(optr.fgAccessor, pool, node, optr.client) | ||
|
|
@@ -825,7 +834,17 @@ func (optr *Operator) syncMachineConfigNodes(_ *renderConfig, _ *configv1.Cluste | |
| } | ||
| } | ||
|
|
||
| if fg.Enabled(features.FeatureGateImageModeStatusReporting) { | ||
| if mcn.Spec.ConfigImage.DesiredImage == upgrademonitor.NotYetSet { | ||
| err = upgrademonitor.GenerateAndApplyMachineConfigNodeSpec(optr.fgAccessor, pool, node, optr.client) | ||
| if err != nil { | ||
| klog.Errorf("Error making MCN spec for Update Compatible: %v", err) | ||
| } | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this duplicative of lines 829-835? If I'm understanding this added conditional correctly,
|
||
|
|
||
| } | ||
|
|
||
| if mcns != nil { | ||
| for _, mcn := range mcns.Items { | ||
| if _, ok := nodeMap[mcn.Name]; !ok { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,12 +145,14 @@ func generateAndApplyMachineConfigNodes( | |
| mcfgv1.MachineConfigNodeUpdateComplete, | ||
| mcfgv1.MachineConfigNodeResumed, | ||
| mcfgv1.MachineConfigNodeUpdateDrained, | ||
| mcfgv1.MachineConfigNodeUpdateFilesAndOS, | ||
| mcfgv1.MachineConfigNodeUpdateFiles, | ||
| mcfgv1.MachineConfigNodeUpdateOS, | ||
| mcfgv1.MachineConfigNodeUpdateCordoned, | ||
| mcfgv1.MachineConfigNodeUpdateRebooted, | ||
| mcfgv1.MachineConfigNodeUpdated, | ||
| mcfgv1.MachineConfigNodeUpdateUncordoned, | ||
| mcfgv1.MachineConfigNodeNodeDegraded, | ||
| mcfgv1.MachineConfigNodeImagePulledFromRegistry, | ||
| } | ||
| allConditionTypes = append(allConditionTypes, singletonConditionTypes...) | ||
|
|
||
|
|
@@ -220,7 +222,11 @@ func generateAndApplyMachineConfigNodes( | |
|
|
||
| case condition.Status != metav1.ConditionFalse && reset: | ||
| condition.Status = metav1.ConditionFalse | ||
| // ASK: does this message change if OCL is used | ||
| condition.Message = fmt.Sprintf("Action during update to %s: %s", newMCNode.Spec.ConfigVersion.Desired, condition.Message) | ||
| if fg.Enabled(features.FeatureGateImageModeStatusReporting) { | ||
| condition.Message = fmt.Sprintf("") | ||
| } | ||
| condition.LastTransitionTime = metav1.Now() | ||
| } | ||
| condition.DeepCopyInto(&newMCNode.Status.Conditions[i]) | ||
|
|
@@ -247,7 +253,6 @@ func generateAndApplyMachineConfigNodes( | |
| } else { | ||
| newMCNode.Status.ConfigVersion.Desired = desiredAnnotation | ||
| } | ||
|
|
||
| // Set current version in MCN.Status.ConfigVersion if node annotation exists | ||
| if node.Annotations[daemonconsts.CurrentMachineConfigAnnotationKey] != "" { | ||
| newMCNode.Status.ConfigVersion.Current = node.Annotations[daemonconsts.CurrentMachineConfigAnnotationKey] | ||
|
|
@@ -290,6 +295,14 @@ func generateAndApplyMachineConfigNodes( | |
| } | ||
| } | ||
|
|
||
| if fg.Enabled(features.FeatureGateImageModeStatusReporting) { | ||
| statusConfigImageApplyImage := machineconfigurationv1.MachineConfigNodeStatusConfigImage().WithDesiredImage(newMCNode.Status.ConfigImage.DesiredImage) | ||
| if node.Annotations[daemonconsts.CurrentImageAnnotationKey] != "" { | ||
| statusConfigImageApplyImage = statusConfigImageApplyImage.WithCurrentImage(newMCNode.Status.ConfigImage.CurrentImage) | ||
| } | ||
|
Comment on lines
+325
to
+328
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: Why does current image have a nil check, but desired does not? |
||
|
|
||
| } | ||
|
|
||
| mcnodeApplyConfig := machineconfigurationv1.MachineConfigNode(newMCNode.Name).WithStatus(statusApplyConfig) | ||
| _, err := mcfgClient.MachineconfigurationV1().MachineConfigNodes().ApplyStatus(context.TODO(), mcnodeApplyConfig, metav1.ApplyOptions{FieldManager: "machine-config-operator", Force: true}) | ||
| if err != nil { | ||
|
|
@@ -304,6 +317,17 @@ func generateAndApplyMachineConfigNodes( | |
| if newMCNode.Spec.ConfigVersion.Desired == "" { | ||
| newMCNode.Spec.ConfigVersion.Desired = NotYetSet | ||
| } | ||
|
|
||
| if fg.Enabled(features.FeatureGateImageModeStatusReporting) { | ||
| newMCNode.Spec.ConfigImage = mcfgv1.MachineConfigNodeSpecConfigImage{ | ||
| DesiredImage: mcfgv1.ImageDigestFormat(node.Annotations[daemonconsts.DesiredImageAnnotationKey]), | ||
| } | ||
|
|
||
| if newMCNode.Spec.ConfigImage.DesiredImage == "" { | ||
| newMCNode.Spec.ConfigImage.DesiredImage = "" | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not seem like it would make any change. |
||
|
|
||
| } | ||
| newMCNode.Name = node.Name | ||
| newMCNode.Spec.Pool = mcfgv1.MCOObjectReference{Name: pool} | ||
| newMCNode.Spec.Node = mcfgv1.MCOObjectReference{Name: node.Name} | ||
|
|
@@ -379,11 +403,23 @@ func GenerateAndApplyMachineConfigNodeSpec(fgAccessor featuregates.FeatureGateAc | |
| newMCNode.Spec.Node = mcfgv1.MCOObjectReference{ | ||
| Name: node.Name, | ||
| } | ||
|
|
||
| if fg.Enabled(features.FeatureGateImageModeStatusReporting) { | ||
| newMCNode.Spec.ConfigImage = mcfgv1.MachineConfigNodeSpecConfigImage{ | ||
| DesiredImage: mcfgv1.ImageDigestFormat(node.Annotations[daemonconsts.DesiredImageAnnotationKey]), | ||
| } | ||
| // check if it should be empty | ||
| if newMCNode.Spec.ConfigImage.DesiredImage == "" { | ||
| newMCNode.Spec.ConfigVersion.Desired = NotYetSet | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like this may be a copy-paste issue, as I'd expect this to be newMCNode.Spec.ConfigImage.Desired, not newMCNode.Spec.ConfigVersion.Desired. However, do we want to make the config image values
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can fix the copy-paste issue. As for the config image value, I put it down as NotYetSet temporarily and depending on how the API changes are finalized, I planned on going back and updating it to empty. Do you think this would be a good approach?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, let's revisit once the API Is finalized. |
||
| } | ||
| } | ||
|
|
||
| if !needNewMCNode { | ||
| nodeRefApplyConfig := machineconfigurationv1.MCOObjectReference().WithName(newMCNode.Spec.Node.Name) | ||
| poolRefApplyConfig := machineconfigurationv1.MCOObjectReference().WithName(newMCNode.Spec.Pool.Name) | ||
| specconfigVersionApplyConfig := machineconfigurationv1.MachineConfigNodeSpecMachineConfigVersion().WithDesired(newMCNode.Spec.ConfigVersion.Desired) | ||
| specApplyConfig := machineconfigurationv1.MachineConfigNodeSpec().WithNode(nodeRefApplyConfig).WithPool(poolRefApplyConfig).WithConfigVersion(specconfigVersionApplyConfig) | ||
| specConfigImageApplyConfig := machineconfigurationv1.MachineConfigNodeSpecConfigImage().WithDesiredImage(newMCNode.Spec.ConfigImage.DesiredImage) | ||
| specApplyConfig := machineconfigurationv1.MachineConfigNodeSpec().WithNode(nodeRefApplyConfig).WithPool(poolRefApplyConfig).WithConfigVersion(specconfigVersionApplyConfig).WithConfigImage(specConfigImageApplyConfig) | ||
| mcnodeApplyConfig := machineconfigurationv1.MachineConfigNode(newMCNode.Name).WithSpec(specApplyConfig) | ||
| _, err := mcfgClient.MachineconfigurationV1().MachineConfigNodes().Apply(context.TODO(), mcnodeApplyConfig, metav1.ApplyOptions{FieldManager: "machine-config-operator", Force: true}) | ||
| if err != nil { | ||
|
|
@@ -397,17 +433,23 @@ func GenerateAndApplyMachineConfigNodeSpec(fgAccessor featuregates.FeatureGateAc | |
| return err | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // createOrGetMachineConfigNode gets the named MCN or returns a boolean indicating we need to create one | ||
| func createOrGetMachineConfigNode(mcfgClient mcfgclientset.Interface, node *corev1.Node) (*mcfgv1.MachineConfigNode, bool) { | ||
| mcNode, err := mcfgClient.MachineconfigurationV1().MachineConfigNodes().Get(context.TODO(), node.Name, metav1.GetOptions{}) | ||
| if mcNode.Name == "" || (err != nil && apierrors.IsNotFound(err)) { | ||
| if err != nil { | ||
| // no existing MCN found since no resource found, no error yet just create a new one | ||
| if apierrors.IsNotFound((err)) { | ||
| klog.V(4).Infof("MachineConfigNode for node %q not found, will create a new one", node.Name) | ||
| return mcNode, true | ||
| } | ||
| // true error getting existing MCN | ||
| klog.Errorf("error getting existing MCN: %v", err) | ||
| return mcNode, true | ||
| } | ||
|
|
||
| return mcNode, false | ||
| } | ||
|
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is responsible for extracting the ocl image from the mc if it exists. I think that function should work, buttt I'm not sure that this reporting should go here for a couple of reasons.
I think update is a good place to put this work but we just want to ensure the timing is correct!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add code to handle the empty string case but where do you recommend adding this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe after applyOSChanges has succeeded- meaning the image was pulled and the OS was rebased successfully.