meshsync icon indicating copy to clipboard operation
meshsync copied to clipboard

feature: 355: snapshot with local file: run meshery without nats, output results into local file

Open n2h9 opened this issue 10 months ago • 3 comments

Description

This PR implements #355

Continuation on https://github.com/meshery/meshsync/pull/364 and https://github.com/meshery/meshsync/pull/361

Notes for Reviewers

Was able to achieve Run meshsync without nats and output to file as json (instead of nats);

Import of result file into kanvas. ~~When I try to upload result file to kanvas -> it doesn't work, as kanvas expects file to be yml or yaml. Simple conversion in online editor from json to yaml didn't help, probably need to play a little with the format.~~

~~But If I take json of one resource (f.e. pod) andconvert it to yaml and import it to yaml -> it works.~~

~~So here need to output resource in the correct yaml list so that the output could be imported to kanvas directly.~~

Updated marshaling to yaml.

Signed commits

  • [x] Yes, I signed my commits.

n2h9 avatar Mar 23 '25 13:03 n2h9

Yay, your first pull request! :thumbsup: A contributor will be by to give feedback soon. In the meantime, please review the Layer5 Community Welcome Guide and sure to join the community Slack. Be sure to double-check that you have signed your commits. Here are instructions for making signing an implicit activity while peforming a commit.

welcome[bot] avatar Mar 23 '25 13:03 welcome[bot]

Hey hello, :wave: :innocent: !

Would appreciate if you @devhindo by chance have some comments on this :blush: thank you :bowing_woman:

n2h9 avatar Mar 23 '25 21:03 n2h9

Great Job

lekaf974 avatar Mar 30 '25 13:03 lekaf974

A few merge conflicts need to be addressed, but I think this PR is ready after that...

marblom007 avatar Apr 18 '25 16:04 marblom007

I merged these conflicts, @n2h9. I think that I did it correctly, but I see that the integration test is failing... 🤔

marblom007 avatar Apr 18 '25 16:04 marblom007

I merged these conflicts, @n2h9. I think that I did it correctly, but I see that the integration test is failing... 🤔

right, let me double check on this please . . .

n2h9 avatar Apr 18 '25 17:04 n2h9

I merged these conflicts, @n2h9. I think that I did it correctly, but I see that the integration test is failing... 🤔

right, let me double check on this please . . .

Hey @marblom007 hello :wave: :innocent: It was a missing import, updated, should be all right now :blush:

Thank you :bowing_woman:

--

Ha :smile: looks like it is still failing :cry: Let me triple check . . .

n2h9 avatar Apr 18 '25 18:04 n2h9

I merged these conflicts, @n2h9. I think that I did it correctly, but I see that the integration test is failing... 🤔

right, let me double check on this please . . .

Hey @marblom007 hello 👋 😇 It was a missing import, updated, should be all right now 😊

Thank you 🙇‍♀️

--

Ha 😄 looks like it is still failing 😢 Let me triple check . . .

Ok, this one is interesting:

=== RUN   TestWithNatsIntegration
time="2025-04-18T18:32:45Z" level=error msg="Missing or outdated CRD. " app=meshsync code=1000 probable-cause="Missing or outdated CRD." severity=2 short-description="Error while initializing MeshSync configuration. .Config File \"meshsync_config\" Not Found in \"[/home/runner/.meshery]\"" suggested-remediation="Confirm that meshsyncs custom resource is present in the cluster."

.Config File "meshsync_config" Not Found in "[/home/runner/.meshery]\

this is related to this comment in internal/config/config.go:16

I inherited this change from this pr: https://github.com/meshery/meshsync/pull/361

Let me double check with Lee if we need this and come back you @marblom007 :hugs:

n2h9 avatar Apr 18 '25 18:04 n2h9

.Config File "meshsync_config" Not Found in "[/home/runner/.meshery]\

this is related to this comment in internal/config/config.go:16

I inherited this change from this pr: #361

Let me double check with Lee if we need this and come back you @marblom007 🤗

I will probably need to add a code here, which creates the folder $HOME/.meshery. I mean not before test, but in the meshsync itself. And also there are fresh lint errors :slightly_smiling_face: Let me fix this two issues and come back to you with updates :innocent:

n2h9 avatar Apr 18 '25 19:04 n2h9

I will probably need to add a code here, which creates the folder $HOME/.meshery. I mean not before test, but in the meshsync itself. And also there are fresh lint errors 🙂 Let me fix this two issues and come back to you with updates 😇

Hey hello :wave: :innocent: !

I have updated as mentioned above to:

  • create $HOME/.meshery folder if it not exists;
  • and fixed lint errors;

and also added test cases to ensure current nats integration is not broken :smile:


I would like also:

  • to fix a cyclomatic complexity in main, as it is now huge after my changes (it was big but now huge :smile: )
  • to double check the actual functionality of output to local file, as I was mostly concentrated last couple days on how to check that existing set up is not broken;

so will keep it as draft for now for a little longer, will mark as ready soon :innocent:

thank you :bowing_woman:

n2h9 avatar Apr 20 '25 18:04 n2h9

to fix a cyclomatic complexity in main, as it is now huge after my changes (it was big but now huge 😄 )

I started to do it, and updated couple paths which was added by me, but probably better not to do it in this pr. As it will require almost complete refactoring of main file. Just to avoid possible regression, not related to functionality. Let's fix cyclomatic complexity in a separate pr when this one will be merged :innocent:

-- By the way the average complexity for the main package dropped below 7, so this one is done :white_check_mark:

n2h9 avatar Apr 21 '25 10:04 n2h9

Added couple test cases which do checks when output mode is file;

n2h9 avatar Apr 21 '25 12:04 n2h9

Some good progress here. 🥇

leecalcote avatar Apr 24 '25 19:04 leecalcote

Codecov Report

Attention: Patch coverage is 2.17391% with 360 lines in your changes missing coverage. Please review.

Project coverage is 4.46%. Comparing base (1b87068) to head (50449ad). Report is 87 commits behind head on master.

Files with missing lines Patch % Lines
main.go 0.00% 177 Missing :warning:
internal/output/inmemory_deduplicator.go 0.00% 38 Missing :warning:
internal/pipeline/handlers.go 0.00% 24 Missing :warning:
internal/file/file.go 0.00% 22 Missing :warning:
internal/file/yaml_writer.go 0.00% 18 Missing :warning:
internal/config/crd_config.go 34.78% 15 Missing :warning:
internal/output/composite.go 0.00% 15 Missing :warning:
internal/output/nats.go 0.00% 13 Missing :warning:
internal/output/file.go 0.00% 10 Missing :warning:
internal/config/config.go 0.00% 9 Missing :warning:
... and 6 more
Additional details and impacted files
@@            Coverage Diff            @@
##           master    #386      +/-   ##
=========================================
- Coverage    5.50%   4.46%   -1.05%     
=========================================
  Files          24      31       +7     
  Lines        1108    1411     +303     
=========================================
+ Hits           61      63       +2     
- Misses       1040    1341     +301     
  Partials        7       7              
Flag Coverage Δ
unittests 4.46% <2.17%> (-1.05%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Apr 26 '25 10:04 codecov[bot]

Docs forthcoming separately.

leecalcote avatar May 14 '25 13:05 leecalcote