Skip to content

Conversation

@alexandrevicenzi
Copy link
Member

Zypper is capable of propagating error messages written to stderr if the application exits with a non-zero code.

This fixes #91.

Copy link
Collaborator

@dcermak dcermak left a comment

Choose a reason for hiding this comment

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

What happens now if the container-suseconnect plugin fails to obtain the repo for whatever reason? Will zypper ref fail completely or will the SLE_BCI repo still be usable on BCI?

@alexandrevicenzi
Copy link
Member Author

@dcermak according to my tests, if container-suseconnect fails for any reason, the plugin is skipped by Zypper.

zypper ref warns about the failure and skipping the plugin, continues to work as expected, but there won't be any new repositories, just the base BCI repo.

Copy link
Collaborator

@dcermak dcermak left a comment

Choose a reason for hiding this comment

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

LGTM, added two nitpicks that are non-blocking

@dcermak
Copy link
Collaborator

dcermak commented Aug 22, 2024

Ah, but please add an entry to the Changelog about this functionality change

@alexandrevicenzi
Copy link
Member Author

@dcermak the changelog is outdated or forgotten, the version there is 2.3, while the version released is 2.5.

I have so many changes in mind, plus a few changes in behavior like this PR, that I'm considering the next version to be 3.0, not sure if 2.6 would fit such changes.

GitHub releases have the entire changelog and OBS can fetch that, perhaps not worth having an extra file.

WDYT?

@dcermak
Copy link
Collaborator

dcermak commented Aug 22, 2024

@dcermak the changelog is outdated or forgotten, the version there is 2.3, while the version released is 2.5.

I have so many changes in mind, plus a few changes in behavior like this PR, that I'm considering the next version to be 3.0, not sure if 2.6 would fit such changes.

I'm fine with a new major version, that's warranted given the bigger changes.

GitHub releases have the entire changelog and OBS can fetch that, perhaps not worth having an extra file.

WDYT?

Github releases will by default only list the commit log, which is not suitable for end user consumption. I think a user consumable changelog still provides value.

@alexandrevicenzi
Copy link
Member Author

@dcermak I'll try to keep the changelog, but I'll update it in a future PR with all changes that are going in the next release.

@alexandrevicenzi alexandrevicenzi force-pushed the zypper-log-error branch 2 times, most recently from 920e907 to 6c4951c Compare August 26, 2024 12:54
}
func TestIsValidLogPathFromRegularFile(t *testing.T) {
tempFile, err := os.CreateTemp("", "prefix")
assert.Nil(t, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

iirc assert is for tests, require is for prerequisites

Suggested change
assert.Nil(t, err)
require.Nil(t, err)

Copy link
Member Author

Choose a reason for hiding this comment

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

require is just a wrapper around assert that calls t.FailNow. I don't see any value in this change to be honest.

Am I missing something?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If the creation of the temporary directory fails, then there's really no value in continuing to execute the test, as it is already clear that it will fail too. That was my rationale, why require should be used here

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll make a few tests, but for now I'll leave it like this. My idea is to rework other tests to use this library as it makes it easier to test and clearer to understand.

testLogger(t, "suse.log", "suse.log", true)
func TestIsValidLogPathFromValidDir(t *testing.T) {
dir, err := os.MkdirTemp("", "")
assert.Nil(t, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
assert.Nil(t, err)
require.Nil(t, err)


func TestIsValidLogPathFromMissingDir(t *testing.T) {
dir, err := os.MkdirTemp("", "")
assert.Nil(t, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
assert.Nil(t, err)
require.Nil(t, err)

Always write logs to both a file and Stderr as it makes easier to debug
issues.

Signed-off-by: Alexandre Vicenzi <[email protected]>
There's no reason to hide such an error from the user. Users must be
aware that a container has no valid credentials.

Zypper will forward any errors encountered in plugins, allowing users to
be fully aware why repos and packages are not showing up.

Signed-off-by: Alexandre Vicenzi <[email protected]>
Copy link
Collaborator

@dcermak dcermak left a comment

Choose a reason for hiding this comment

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

Looks much better now, thanks!

@alexandrevicenzi alexandrevicenzi merged commit 0643543 into SUSE:master Aug 30, 2024
@alexandrevicenzi alexandrevicenzi deleted the zypper-log-error branch August 30, 2024 12:44
alexandrevicenzi added a commit to alexandrevicenzi/container-suseconnect that referenced this pull request Jul 1, 2025
This reverts SUSE#93 partially because it causes zyppers to log errors every
time it fails to locate credentials files.

Failures are still logged to a file, but not propagated to zypper.
alexandrevicenzi added a commit to alexandrevicenzi/container-suseconnect that referenced this pull request Jul 9, 2025
This reverts SUSE#93 partially because it causes zyppers to log errors every
time it fails to locate credentials files.

Failures are still logged to a file, but not propagated to zypper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logging behavior

2 participants