-
Notifications
You must be signed in to change notification settings - Fork 49
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 virtual repo snapshot feature to tdnf #497
base: dev
Are you sure you want to change the base?
Conversation
Wow, that's a big change. It will take me a while to review this. I have a few question: What is the use case? Is it just for testing, for example test an upgrade scenario? Or do you want to tag a specific time for a stable build? Have you considered alternative approaches? For example, wouldn't it be easier to just create a "real" repository with all packages older than the snapshot time (if space is an issue, maybe just use symlinks?). I think this could be done using simple shell scripts, much simpler than this change. How reliable is the "file" attribute, which is set (I guess) by Have you thought about implementing this as a plugin? I know the plugin interface would probably need changes for this. But I think the use case is rather limited. |
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 just did one round of review. Need to understand the logic and usage better.
Some generic comments:
- Avoid sprintf, strcpy and prefer snprintf, strncpy
- Use already available tdnf APIs for memory allocations
- Make functions static if not used outside of file
- Add test cases and try to cover as various scenarios
Please sign the SLA before anything else.
// take command line over config if both are present | ||
for (pSetOpt = pTdnf->pArgs->pSetOpt; pSetOpt; pSetOpt = pSetOpt->pNext) | ||
{ | ||
if(strncmp(pSetOpt->pszOptName, TDNF_CONF_KEY_SNAPSHOT_TIME, strlen(TDNF_CONF_KEY_SNAPSHOT_TIME)) == 0) |
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.
store strlen(TDNF_CONF_KEY_SNAPSHOT_TIME)
in a variable before entering loop
} | ||
|
||
} | ||
else if (pTracking->nInPackage && !pTracking->nTimeFound) |
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.
Checking pTracking->nInPackage for non zero is redundant here.
BAIL_ON_TDNF_TIME_FILTER_ERROR(dwError); | ||
} | ||
} | ||
else if (pTracking->nInPackage && !pTracking->nTimeFound) |
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.
Checking pTracking->nInPackage for non zero is redundant here.
{ | ||
BAIL_ON_TDNF_TIME_FILTER_ERROR(dwError); | ||
} | ||
sprintf(*pszElementBuffer, "</%s>", pszElementName); |
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.
use snprintf
|
||
// allocate new string for linted string | ||
int nStrToLintLen = (strlen(pszStringToEscape) + 1); // add one for null char | ||
char * pszLintedStr = malloc(nStrToLintLen * sizeof(char)); |
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.
Use TDNFAllocateString
TDNFFilterData * pTracking = (TDNFFilterData *)userData; | ||
|
||
// decrement depth | ||
pTracking->nDepth -= 1; |
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.
pTracking->nDepth--;
makes i easy to read
{ | ||
BAIL_ON_TDNF_TIME_FILTER_ERROR(dwError); | ||
} | ||
fprintf(pbOutfile, "%s", pszEndElement); |
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.
have a wrapper function for this, repeated in many places
uint32_t | ||
printElementEndToFile(FILE * pbOutfile, const char * pszElementName) { | ||
uint32_t dwError = 0; | ||
if (pbOutfile == NULL) |
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.
check using IsNullOrEmptyString
int nEndElementLen = strlen(pszElementBuffer); | ||
|
||
dwError = checkAndResizeBuffer(&(pTracking->pszElementBuffer), &(pTracking->nBufferMaxLen), nEndElementLen); | ||
if (dwError) |
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 this check? BAIL_ON_TDNF_TIME_FILTER_ERROR does it already
// vars | ||
uint32_t dwError = 0; | ||
TDNFFilterData pData; | ||
bzero(&pData, sizeof(TDNFFilterData)); |
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 don't mix declarations and function calls
Hey @oliverkurth, I'll have some answers coming in soon. I was out of town with little internet access so, but back now to work through this larger change. I will sign the CLA as soon as I am able/allowed. @sshedi Thanks for the review I will consider the changes as we decide to move forward here and for future development within the tdnf repo. |
@oliverkurth here's some answers for your above questions. Let me know if anything is not particularly clear Use Case Alternate Approaches I've Considered
The "file" attribute is added by I did not consider a plugin implementation of this. Do you have an idea of what the changes might look like in that form? I don't quite see how a plugin interface would fit into this solution? |
Thanks for replying, @sameluch . I am not convinced that other approaches are more overhead. Here are some ideas:
What does "added" mean? Which time does |
What you can do is dump the set of installed packages, to json, like:
Then use a script, and install on the target with |
@sameluch, we have received your signed contributor license agreement. The review is usually completed within a week, but may take longer under certain circumstances. Another comment will be added to the pull request to notify you when the merge can proceed. |
@sameluch, VMware has approved your signed contributor license agreement. |
This PR adds some functionality built for Azure Linux to tdnf for the broader userbase, virtual repo snapshots. This is the ability to emulate an older snapshot of all enabled repos at a specific timestamp.
Added with this PR is a new config option
snapshottime=<posix_time>
which can be added to tdnf.conf to load as a global version of another added command line option--snapshottime=<posix_time>
. The snapshot emulates as if the command was run against repos at the given timestamp. All packages which are published to a repo with a timestamp later than the the specified--snapshottime
will be occluded from the solver and thus not considered for list, install, upgrade, and other commands which hit repositories.Additionally, if some repos are desired to be not snapshot while executing a given path
--snapshotexcluderepos=<repo_id1>[,<repo_id2>,...]
. Each repo specified in--snapshotexcluderepos
will NOT have the--snapshottime
applied to it, if applicable.