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

Add AliasPrefix and AliasPrefixRouting types to networking API #372

Merged
merged 7 commits into from
May 2, 2022

Conversation

afritzler
Copy link
Member

@afritzler afritzler commented Apr 26, 2022

Proposed Changes

  • Add AliasPrefix and AliasPrefixRouting types to networking API
  • Add sample for AliasPrefix
  • Add validation and validation test
  • Fixed samples

Fixes #366 #367

@afritzler afritzler changed the title Add AliasPrefix and AliasPrefixRouting types to networking API WIP: Add AliasPrefix and AliasPrefixRouting types to networking API Apr 26, 2022
@afritzler afritzler force-pushed the enh/aliasprefix-type branch 8 times, most recently from 1c02e46 to a6fe24a Compare April 27, 2022 14:16
@afritzler afritzler changed the title WIP: Add AliasPrefix and AliasPrefixRouting types to networking API Add AliasPrefix and AliasPrefixRouting types to networking API Apr 27, 2022
@afritzler

This comment was marked as outdated.

@afritzler
Copy link
Member Author

Fixed the tests by increasing the runner cores to 4 + increasing the apiserver timeout to 5 mins.

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Apr 28, 2022
"github.com/onmetal/onmetal-api/apis/ipam"
)

type EphemeralPrefixSource struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was the signature of the EphemeralPrefixSource changed? Wouldn't this also alter the NetworkInterface type?
In k8s, for templated types, the structure is

type ...Source struct {
   ...Template ...Template
}

as well

Copy link
Member Author

Choose a reason for hiding this comment

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

That was the problem with the inline + pointer type. The api-server panics if I use something like this:

type EphemeralPrefixSource struct {
	PrefixTemplate *ipamv1alpha1.PrefixTemplateSpec `json:",inline"`
}

ipamv1alpha1 "github.com/onmetal/onmetal-api/apis/ipam/v1alpha1"
)

type EphemeralPrefixSource struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

Comment on lines 48 to 50
for _, msg := range apivalidation.NameIsDNSLabel(spec.NetworkRef.Name, false) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("networkRef").Child("name"), spec.NetworkRef.Name, msg))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this into the else block of the

if spec.NetworkRef ==

part. The apivalidation.NameIsDNSLabel already errors on empty names and error messages might be misleading.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

return allErrs
}

func validateAliasPrefixSources(prefixSource networking.PrefixSource, fldPath *field.Path) field.ErrorList {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add some validation in case somebody specifies both Value and EphemeralPrefix - this should be disallowed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

"k8s.io/apimachinery/pkg/util/validation/field"
)

type aliasPrefixRoutingSubsetKey struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why introduce this key type if it only contains commonv1alpha1.LocalUIDReference?
Also, the identity should be the name only, as we also don't want two entries that are equal in name but non-equal in UID.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

aliasPrefix := obj.(*networking.AliasPrefix)

cells = append(cells, name)
cells = append(cells, aliasPrefix.Status.Prefix)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a check if this is nil - then we should print something like <none> / None / <undefined> (have a look at the other table convertors.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

}

func (aliasPrefixStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return field.ErrorList{}
Copy link
Contributor

Choose a reason for hiding this comment

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

The update validation hook has to be added.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

}

func (REST) ShortNames() []string {
return []string{"apr"}
Copy link
Contributor

Choose a reason for hiding this comment

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

please also add aprouting

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

}, nil
}

type StatusREST struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

The StatusREST should be removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

objectMetaSwaggerDoc = metav1.ObjectMeta{}.SwaggerDoc()

headers = []metav1.TableColumnDefinition{
{Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]},
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a column of some sort that prints the targets / subsets.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@adracus adracus merged commit 8755cfb into main May 2, 2022
@adracus adracus deleted the enh/aliasprefix-type branch May 2, 2022 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add AliasPrefix type to networking API group
2 participants