-
Notifications
You must be signed in to change notification settings - Fork 142
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
Make it easy to find out the k8s and flux version #2349
Make it easy to find out the k8s and flux version #2349
Conversation
ebe2afe
to
f81f64f
Compare
fluxVersion = u.GetLabels()["app.kubernetes.io/version"] | ||
} | ||
} | ||
} |
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.
@ozamosi @chanwit suggestions on how to simplify nested ifs here (looks similar to a "callback hell" in JS) welcome!
I don't want to return nil from GetVersion
on error when getting additional values, because I want to display at least available values (at least the values set at the build time) in the app for debug purposes.
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 lift this bit into a new function, return an error from there any time there's an error, and then this function only has one error to check?
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.
Thanks, good idea, will do it.
|
||
key := client.ObjectKey{ | ||
Name: ns, | ||
} |
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.
So, you're right that this can be pretty much any namespace - but I'm not sure the frontend knows what namespace to use 🤔
What if instead of Get
ing a specific namespace, we List
filtered by {"app.kuberenetes.io/part-of": "flux"}
and just grab the first result we find? After a bit of grepping - I think this helper does the filtering? https://github.com/weaveworks/weave-gitops/blob/main/core/server/server.go#L86
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.
OK, can do it.
From frontend we don't provide any namespace. This param was added just for passing the test (because when running the test it could not find the "flux-system" namespace). If the namespace is not provided (like when we make the request via the API, {}
with no args), we just default to "flux-system" (and while the app is running normally, the "flux-system" namespace is found). At least that was the idea. 🙂
I need to see if the list function will return the flux-system/flux-whatever namespace while running the test.
core/server/version.go
Outdated
if err != nil { | ||
return defaultVersion, fmt.Errorf("error getting object: %w", err) | ||
} else { | ||
return u.GetLabels()["app.kubernetes.io/version"], nil |
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.
u.GetLabels() may return nil
here.
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.
never mind me @opudrovs, if you chose to use the VersionLabelKey
instead.
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.
Thanks, will keep it in mind.
5c635c2
to
e59fb72
Compare
@ozamosi @chanwit added grabbing a namespace from the list of namespaces. For testing, I create a new namespace with required key because the Also moved creating scoped client, getting Flux and K8s version to separate functions, based on @ozamosi 's suggestion. Should the create scoped client function's name start with @chanwit just in case added checking for nil when getting the version from labels. @joshri I've added displaying Flux and Kubernetes versions in the footer. Also added Spaced and colored elements based on the quick design in the UI ticket description to make it consistent with current styling of the Footer component. Please let me know if styling/spacing/whatever is wrong. |
f7249b3
to
871c8e2
Compare
@ozamosi @chanwit 1) would it be possible to filter for Version label key with any value? Or only filtering by specific values is possible?
Right now I am filtering labels only by
|
155cb5e
to
ee45d46
Compare
fdfb6a5
to
8d7324c
Compare
I feel
I've not seen that, and a quick peek doesn't reveal anything. So, maybe not?
It's uncommon. I prefer to think of it as, go has exceptions, it's just that they don't bubble up automatically so you have to constantly wire them up manually. So every time I see That doesn't mean it's always wrong. But in this case, if the returned value is simply an empty string, then I'd write it so that the calling function sets the default instead of the called function - so the fall-back is implemented as an "exception handler". |
@ozamosi OK, thank you, got it, will add the changes now. |
@ozamosi added the fixes. |
a56b68e
to
4766770
Compare
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'm getting this back right now on the version request so nothing shows up in the page: branch: "" buildTime: "" commit: "" semver: "v0.0.0"
We might want to add a dash or something if no data comes through but the request was successful?
ui/components/Footer.tsx
Outdated
) : null; | ||
|
||
const kubeVersionText = versionData.kubeVersion; | ||
const kubeVersion = |
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.
fluxVersion and kubeVersion could potentially be combined into one component with props but I don't mind either way
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.
Good idea, will do it.
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.
Added the Version component with snapshot tests.
- Not sure if adding
attrs
when exported is still required, like recommended in the style.md doc, so still added it like that:
export default styled(Version).attrs({ className: Version.name })``;
- Footer versions are wrapped at narrow screens (see layout at 768 or 1000 px for example) , otherwise we would have to add a horiz scrollbar, preferably for the whole layout (or it looks ugly if added only to the footer).
Does this look OK?
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.
Three options that come to mind:
- Set everything to nowrap and just have it overflow the container
- Increase the minWidth of the container so we know we're always fitting the whole footer in
- Decrease font size on the footer?
Maybe we do a mix of all three?
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.
Used options 1 and 2: set the Version component text to nowrap and changed 768px in Layout.tsx from to 900px (conveniently, a Material-UI breakpoints).
Everything I tried with scrollbars in the footer and footer containers looked ugly. So, I've decided not to add overflow-x: auto
.
I think it's either these two applied fixes or we'd need to do a serious redesign of the footer (for example, move it under the whole app content or move content info + email text somewhere out of the footer), because the current footer text is really wide.
So, the current version looks best for now.
ui/components/Footer.tsx
Outdated
return ( | ||
<Flex as="footer" wide between className={className} role="footer"> | ||
<LeftFoot> | ||
<Text color="neutral30">Need help? Contact us at</Text> | ||
<Text>Need help? Contact us at</Text> |
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.
add the excellent noWrap
prop here
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.
Added.
ui/components/Footer.tsx
Outdated
)} | ||
<Spacer padding="xxs" /> | ||
<Text color="neutral30">© 2022 Weaveworks</Text> | ||
<Text>© 2022 Weaveworks</Text> |
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 - add the excellent noWrap
prop!!
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.
Added.
Did you open the app through Tilt or npm start? And are you sure you rebuilt everything and reloaded the app? Can you please try restarting Tilt?
Not a problem. Can add displaying the labels with dashes even if the Flux version and Kubernetes version are empty strings for any reason. But there should be fields |
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 had to update something...classic. Rebuilt and the footer looks good!
095f169
to
51d864d
Compare
Run `make proto`.
Add a discovery client to get the KUbernetes version. Fix error messages.
Add `Namespace` field to the `GetVersionRequest`.
Move creating scoped client to a separate function. Rework error handling. Fix getting the Flux version. Fix tests.
Rework error handling in `getFluxVersion` and `getKubeVersion` methods.
Update snapshot tests.
Increase min content width to 900px.
11fb4d3
to
46bf467
Compare
Closes #2285
Closes #2328
I've added a namespace to theGetVersionRequest
object to makeTestGetVersion
pass because it could not find theflux-system
namespace without it. So, for the test I create a new namespace or if the namespace is not provided default toflux-system
(wego.DefaultNamespace
constant). If anyone knows how to improve this and the issue with nested ifs (will add a comment), I'm all ears. 🙂UPDATE: Removed the namespace field from
GetVersionRequest
(switched to listing namespaces) and fixed nested ifs based on @ozamosi 's suggestions.GetImpersonatedDiscoveryClient
from the test forGetImpersonatedClient
. I am not sure what this API does and what exactly should be tested, maybe it should be modified.Also removed the following from the copied test, maybe it should be put back (this part was failing because the number of found namespaces in the copy-pasted part was 0 instead of 1 or 2):