Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Use the generic Serializer in libgitops, and fix some API machinery nits #257

Closed
wants to merge 25 commits into from

Conversation

luxas
Copy link
Contributor

@luxas luxas commented Jul 2, 2020

This builds upon #251

This PR

  • stops using the client-go scheme as a stop-gap for registering types, and instead creates our own similar dropin-package for that with all types we need/know of.
  • removes unused code
  • Adds a register.go file for v1alpha1 (for being able to decode old configs later, when needed)
  • Uses the Serializer in libgitops for parsing. Later we might want to use the more sophisticated features of it like preserving comments support
  • Replaces custom JSON parsing with kyaml usage
  • Fixing problems uncovered in the code that weren't spotted before due to non-strict decoding, etc.

This fixes some of the nits highlighted in #172
cc @bboreham

Copy link
Contributor

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

Excellent work, just a couple of notes and questions.

@@ -56,22 +53,6 @@ func NewCordonHelper(node *corev1.Node, desired DesiredCordonStatus) *CordonHelp
}
}

// NewCordonHelperFromRuntimeObject returns a new CordonHelper, or an error if given object is not a
// node or cannot be encoded as JSON
func NewCordonHelperFromRuntimeObject(nodeObject runtime.Object, scheme *runtime.Scheme, gvk schema.GroupVersionKind, desired DesiredCordonStatus) (*CordonHelper, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Apparently this code was copied here due to difficulties importing the library created here so maybe we could revisit whether that can be done now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I may open a dedicated PR to that refactor, as I'm not 100% sure how that drain code worked.

Comment on lines +78 to +79
private:
address: "172.17.8.101"
Copy link
Contributor

Choose a reason for hiding this comment

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

For the record this became an error after 8408805 and I missed the cleanup.

Comment on lines -294 to -297
authenticationWebhook:
cacheTTL: 2m0s
server:
url: http://127.0.0.1:5000/authenticate
Copy link
Contributor

Choose a reason for hiding this comment

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

These fields exist on BareMetalCluster so presumably some copy/paste error brought them here.

Comment on lines +32 to +34
infrastructureRef:
kind: BareMetalCluster
name: example
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we really testing anything, if this was not noticed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now we are, as we're using strict parsing. Before, we did non-strict parsing, so all of these just resulted in unset fields.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking again, the example is named "clusterMissingBareMetalClusterDefinition" so probably valid to have this wrong.

Comment on lines 826 to 830
// Create the secret to decode into
ss := &ssv1alpha1.SealedSecret{}
// Decode the Sealed Secret into the object
if err := scheme.Serializer.Decoder().DecodeInto(fr, ss); err != nil {
return nil, nil, "", nil, errors.Wrapf(err, "File %q does not contain a sealed secret, couldn't decode", secretFileName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously the code was set up to handle multiple kinds of secret, although it only actually handled one.
I guess we can punt that to the time when we need a second kind, though it might be nice to note this in the commit description or maybe a comment.

@luxas
Copy link
Contributor Author

luxas commented Jul 16, 2020

Failing at kubectl apply -f \\\"/tmp/03_secrets.yamlj9w2BC0l8O\\\" ) )'\"\nError from server (NotFound): error when creating \"/tmp/03_secrets.yamlj9w2BC0l8O\": namespaces \"weavek8sops\" not found

@luxas
Copy link
Contributor Author

luxas commented Jul 16, 2020

It was unexpected for me that the WithNamespace function also replaced the .metadata.name on Namespace kinds. Now should be fixed.

@luxas
Copy link
Contributor Author

luxas commented Jul 16, 2020

Hmm, next one:

level=error msg=Failed resource=\"kubectl:apply:cluster\"\nkubectl apply: failed to apply manifest /tmp/eS9GKlPCO4; output cluster.cluster.x-k8s.io/test-multimaster created\nThe BareMetalCluster \"test-multimaster\" is invalid: spec.sshKeyPath: Required value\n: command exited with 1
``

@luxas
Copy link
Contributor Author

luxas commented Jul 17, 2020

Closing in favor of: #273

@luxas luxas closed this Jul 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants