-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
AliasPrefix
and AliasPrefixRouting
types to networking APIAliasPrefix
and AliasPrefixRouting
types to networking API
1c02e46
to
a6fe24a
Compare
AliasPrefix
and AliasPrefixRouting
types to networking APIAliasPrefix
and AliasPrefixRouting
types to networking API
This comment was marked as outdated.
This comment was marked as outdated.
a6fe24a
to
f1d2ebc
Compare
- Add validation and validation test - Fixed samples
f1d2ebc
to
dc92177
Compare
b81f263
to
825458b
Compare
Fixed the tests by increasing the runner cores to 4 + increasing the apiserver timeout to 5 mins. |
"github.com/onmetal/onmetal-api/apis/ipam" | ||
) | ||
|
||
type EphemeralPrefixSource struct { |
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.
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
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.
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 { |
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.
Same as above.
for _, msg := range apivalidation.NameIsDNSLabel(spec.NetworkRef.Name, false) { | ||
allErrs = append(allErrs, field.Invalid(fldPath.Child("networkRef").Child("name"), spec.NetworkRef.Name, msg)) | ||
} |
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.
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.
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.
Fixed.
return allErrs | ||
} | ||
|
||
func validateAliasPrefixSources(prefixSource networking.PrefixSource, fldPath *field.Path) field.ErrorList { |
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.
Please add some validation in case somebody specifies both Value
and EphemeralPrefix
- this should be disallowed.
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.
Fixed.
"k8s.io/apimachinery/pkg/util/validation/field" | ||
) | ||
|
||
type aliasPrefixRoutingSubsetKey struct { |
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.
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
.
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.
Fixed.
aliasPrefix := obj.(*networking.AliasPrefix) | ||
|
||
cells = append(cells, name) | ||
cells = append(cells, aliasPrefix.Status.Prefix) |
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.
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.
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.
Fixed.
} | ||
|
||
func (aliasPrefixStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { | ||
return field.ErrorList{} |
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.
The update validation hook has to be added.
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.
Fixed.
} | ||
|
||
func (REST) ShortNames() []string { | ||
return []string{"apr"} |
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.
please also add aprouting
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.
Fixed.
}, nil | ||
} | ||
|
||
type StatusREST struct { |
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.
The StatusREST
should be removed.
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.
Fixed.
objectMetaSwaggerDoc = metav1.ObjectMeta{}.SwaggerDoc() | ||
|
||
headers = []metav1.TableColumnDefinition{ | ||
{Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]}, |
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.
Please add a column of some sort that prints the targets / subsets.
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.
Fixed.
6e19465
to
1ab546c
Compare
Proposed Changes
AliasPrefix
andAliasPrefixRouting
types to networking APIAliasPrefix
Fixes #366 #367